← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-757687-ara into lp:openobject-addons

 

Ashvin Rathod (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-757687-ara into lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #757687 in OpenERP Addons: "Wrong account for invoice lines created from delivery for service products"
  https://bugs.launchpad.net/openobject-addons/+bug/757687

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-757687-ara/+merge/57626

Hello,

Fix: Wrong account for invoice lines created from delivery for service products

Thanks,
Ashvin Rathod
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-757687-ara/+merge/57626
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-757687-ara.
=== modified file 'sale/stock.py'
--- sale/stock.py	2011-02-23 10:22:43 +0000
+++ sale/stock.py	2011-04-14 06:04:24 +0000
@@ -119,6 +119,8 @@
         invoice_obj = self.pool.get('account.invoice')
         picking_obj = self.pool.get('stock.picking')
         invoice_line_obj = self.pool.get('account.invoice.line')
+        fiscal_position_obj = self.pool.get('account.fiscal.position')
+        order_line_obj = self.pool.get('sale.order.line')
 
         result = super(stock_picking, self).action_invoice_create(cursor, user,
                 ids, journal_id=journal_id, group=group, type=type,
@@ -144,6 +146,8 @@
                 invoice_obj.write(cursor, user, [invoice_created.id], {'name': inv_name}, context=context)
             for sale_line in sale_lines:
                 if sale_line.product_id.type == 'service' and sale_line.invoiced == False:
+                    if not type:
+                        type = context.get('inv_type', False)
                     if group:
                         name = picking.name + '-' + sale_line.name
                     else:
@@ -168,7 +172,7 @@
                     account_analytic_id = self._get_account_analytic_invoice(cursor,
                             user, picking, sale_line)
 
-                    account_id = self.pool.get('account.fiscal.position').map_account(cursor, user, picking.sale_id.partner_id.property_account_position, account_id)
+                    account_id = fiscal_position_obj.map_account(cursor, user, picking.sale_id.partner_id.property_account_position, account_id)
                     invoice = invoices[result[picking.id]]
                     invoice_line_id = invoice_line_obj.create(cursor, user, {
                         'name': name,
@@ -183,7 +187,7 @@
                         'account_analytic_id': account_analytic_id,
                         'notes':sale_line.notes
                     }, context=context)
-                    self.pool.get('sale.order.line').write(cursor, user, [sale_line.id], {'invoiced': True,
+                    order_line_obj.write(cursor, user, [sale_line.id], {'invoiced': True,
                         'invoice_lines': [(6, 0, [invoice_line_id])],
                     })
         return result


Follow ups