Valencia Rodrigues (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/5.0-bug-776644-vro into 
lp:openobject-addons/5.0.

Requested reviews:
  Jay Vora (OpenERP) (jvo-openerp)
  Anup(OpenERP) (ach-openerp)
Related bugs:
  Bug #776644 in OpenERP Addons: "[V5]Invoiced Repair Orders"
  https://bugs.launchpad.net/openobject-addons/+bug/776644

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/5.0-bug-776644-vro/+merge/66779

An error is encountered when multiple repair orders are invoiced.

Steps to generate the error:
1. Create 2 repair orders for the same partner. Set the 'Invoice Method' as 
'After Repair'. In the repair lines, set 'To Invoice' to 'True'.
2. Start and end the repairs such that the final state of both the orders are 
"To be invoiced".
3. From the tree view, select these 2 orders and trigger the action 'Create 
invoices'.
4. Set 'Group by partner invoice address' to 'True'. Click 'Create invoices'.

An error is thrown stating the 'invoice_obj' does not exist. This fixes the 
issue.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/5.0-bug-776644-vro/+merge/66779
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/5.0-bug-776644-vro.
=== modified file 'mrp_repair/mrp_repair.py'
--- mrp_repair/mrp_repair.py	2010-09-27 11:47:42 +0000
+++ mrp_repair/mrp_repair.py	2011-07-04 11:51:15 +0000
@@ -255,6 +255,7 @@
     def action_invoice_create(self, cr, uid, ids, group=False, context=None):
         res={}
         invoices_group = {}
+        inv_obj = self.pool.get('account.invoice')
         for repair in self.browse(cr, uid, ids, context=context):
             res[repair.id]=False
             if repair.state in ('draft','cancel') or repair.invoice_id:
@@ -265,13 +266,13 @@
             if (repair.invoice_method != 'none'):
                 if group and repair.partner_invoice_id.id in invoices_group:
                     inv_id= invoices_group[repair.partner_invoice_id.id]
-                    invoice=invoice_obj.browse(cr, uid,inv_id)
+                    invoice=inv_obj.browse(cr, uid,inv_id)
                     invoice_vals = {
                         'name': invoice.name +', '+repair.name,
                         'origin': invoice.origin+', '+repair.name,
                         'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''),
                     }
-                    invoice_obj.write(cr, uid, [inv_id],invoice_vals,context=context)
+                    inv_obj.write(cr, uid, [inv_id],invoice_vals,context=context)
                 else:
                     if not repair.partner_id.property_account_receivable:
                         raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name )
@@ -287,7 +288,6 @@
                         'comment': repair.quotation_notes,
                         'fiscal_position': repair.partner_id.property_account_position.id
                     }
-                    inv_obj = self.pool.get('account.invoice')
                     inv_id = inv_obj.create(cr, uid, inv)
                     invoices_group[repair.partner_invoice_id.id] = inv_id
                 self.write(cr, uid, repair.id , {'invoiced':True,'invoice_id' : inv_id})

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to