Merge lp:~openerp-dev/openobject-addons/5.0-bug-776644-vro into lp:openobject-addons/5.0

Proposed by Valencia Rodrigues (OpenERP)
Status: Merged
Approved by: Jay Vora (Serpent Consulting Services)
Approved revision: no longer in the source branch.
Merged at revision: 2915
Proposed branch: lp:~openerp-dev/openobject-addons/5.0-bug-776644-vro
Merge into: lp:openobject-addons/5.0
Diff against target: 35 lines (+3/-3)
1 file modified
mrp_repair/mrp_repair.py (+3/-3)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/5.0-bug-776644-vro
Reviewer Review Type Date Requested Status
Anup(SerpentCS) (community) Approve
Jay Vora (Serpent Consulting Services) Pending
Review via email: mp+66779@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Anup(SerpentCS) (anup-serpent) wrote :

Hello Valencia,

   It does solve the issue.

Thanks for the fix.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'mrp_repair/mrp_repair.py'
2--- mrp_repair/mrp_repair.py 2010-09-27 11:47:42 +0000
3+++ mrp_repair/mrp_repair.py 2011-07-04 11:51:15 +0000
4@@ -255,6 +255,7 @@
5 def action_invoice_create(self, cr, uid, ids, group=False, context=None):
6 res={}
7 invoices_group = {}
8+ inv_obj = self.pool.get('account.invoice')
9 for repair in self.browse(cr, uid, ids, context=context):
10 res[repair.id]=False
11 if repair.state in ('draft','cancel') or repair.invoice_id:
12@@ -265,13 +266,13 @@
13 if (repair.invoice_method != 'none'):
14 if group and repair.partner_invoice_id.id in invoices_group:
15 inv_id= invoices_group[repair.partner_invoice_id.id]
16- invoice=invoice_obj.browse(cr, uid,inv_id)
17+ invoice=inv_obj.browse(cr, uid,inv_id)
18 invoice_vals = {
19 'name': invoice.name +', '+repair.name,
20 'origin': invoice.origin+', '+repair.name,
21 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''),
22 }
23- invoice_obj.write(cr, uid, [inv_id],invoice_vals,context=context)
24+ inv_obj.write(cr, uid, [inv_id],invoice_vals,context=context)
25 else:
26 if not repair.partner_id.property_account_receivable:
27 raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name )
28@@ -287,7 +288,6 @@
29 'comment': repair.quotation_notes,
30 'fiscal_position': repair.partner_id.property_account_position.id
31 }
32- inv_obj = self.pool.get('account.invoice')
33 inv_id = inv_obj.create(cr, uid, inv)
34 invoices_group[repair.partner_invoice_id.id] = inv_id
35 self.write(cr, uid, repair.id , {'invoiced':True,'invoice_id' : inv_id})