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
=== 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 @@
255 def action_invoice_create(self, cr, uid, ids, group=False, context=None):255 def action_invoice_create(self, cr, uid, ids, group=False, context=None):
256 res={}256 res={}
257 invoices_group = {}257 invoices_group = {}
258 inv_obj = self.pool.get('account.invoice')
258 for repair in self.browse(cr, uid, ids, context=context):259 for repair in self.browse(cr, uid, ids, context=context):
259 res[repair.id]=False260 res[repair.id]=False
260 if repair.state in ('draft','cancel') or repair.invoice_id:261 if repair.state in ('draft','cancel') or repair.invoice_id:
@@ -265,13 +266,13 @@
265 if (repair.invoice_method != 'none'):266 if (repair.invoice_method != 'none'):
266 if group and repair.partner_invoice_id.id in invoices_group:267 if group and repair.partner_invoice_id.id in invoices_group:
267 inv_id= invoices_group[repair.partner_invoice_id.id]268 inv_id= invoices_group[repair.partner_invoice_id.id]
268 invoice=invoice_obj.browse(cr, uid,inv_id)269 invoice=inv_obj.browse(cr, uid,inv_id)
269 invoice_vals = {270 invoice_vals = {
270 'name': invoice.name +', '+repair.name,271 'name': invoice.name +', '+repair.name,
271 'origin': invoice.origin+', '+repair.name,272 'origin': invoice.origin+', '+repair.name,
272 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''),273 'comment':(comment and (invoice.comment and invoice.comment+"\n"+comment or comment)) or (invoice.comment and invoice.comment or ''),
273 }274 }
274 invoice_obj.write(cr, uid, [inv_id],invoice_vals,context=context)275 inv_obj.write(cr, uid, [inv_id],invoice_vals,context=context)
275 else:276 else:
276 if not repair.partner_id.property_account_receivable:277 if not repair.partner_id.property_account_receivable:
277 raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name )278 raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name )
@@ -287,7 +288,6 @@
287 'comment': repair.quotation_notes,288 'comment': repair.quotation_notes,
288 'fiscal_position': repair.partner_id.property_account_position.id289 'fiscal_position': repair.partner_id.property_account_position.id
289 }290 }
290 inv_obj = self.pool.get('account.invoice')
291 inv_id = inv_obj.create(cr, uid, inv)291 inv_id = inv_obj.create(cr, uid, inv)
292 invoices_group[repair.partner_invoice_id.id] = inv_id292 invoices_group[repair.partner_invoice_id.id] = inv_id
293 self.write(cr, uid, repair.id , {'invoiced':True,'invoice_id' : inv_id})293 self.write(cr, uid, repair.id , {'invoiced':True,'invoice_id' : inv_id})