From 123cb46c6c36bc22eea1bbce33dc5fdf41dfa579 Mon Sep 17 00:00:00 2001 From: "Jay (OpenERP)" <> Date: Tue, 11 May 2010 14:45:36 +0530 Subject: [PATCH] =?UTF-8?q?[FIX]=C2=A0(5.0=20-=206.0)Mrp=5Frepair=C2=A0:?= =?UTF-8?q?=C2=A0Corrected=C2=A0make=C2=A0invoice=C2=A0process=C2=A0and?= =?UTF-8?q?=C2=A0Quotation=C2=A0report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bzr revid: vra@tinyerp.com-20100511091536-vroh7w7yr2cmo33s --- addons/mrp_repair/mrp_repair.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/mrp_repair/mrp_repair.py b/addons/mrp_repair/mrp_repair.py index f59da6a751c..3cff3741c7d 100644 --- a/addons/mrp_repair/mrp_repair.py +++ b/addons/mrp_repair/mrp_repair.py @@ -346,12 +346,14 @@ class mrp_repair(osv.osv): } invoice_obj.write(cr, uid, [inv_id], invoice_vals, context=context) else: - a = repair.partner_id.property_account_receivable.id + if not repair.partner_id.property_account_receivable: + raise osv.except_osv(_('Error !'), _('No account defined for partner "%s".') % repair.partner_id.name ) + account_id = repair.partner_id.property_account_receivable.id inv = { 'name': repair.name, 'origin':repair.name, 'type': 'out_invoice', - 'account_id': a, + 'account_id': account_id, 'partner_id': repair.partner_id.id, 'address_invoice_id': repair.address_id.id, 'currency_id': repair.pricelist_id.currency_id.id, @@ -368,11 +370,19 @@ class mrp_repair(osv.osv): name = repair.name + '-' + operation.name else: name = operation.name + + if operation.product_id.property_account_income: + account_id = operation.product_id.property_account_income + elif operation.product_id.categ_id.property_account_income_categ: + account_id = operation.product_id.categ_id.property_account_income_categ.id + else: + raise osv.except_osv(_('Error !'), _('No account defined for product "%s".') % operation.product_id.name ) + invoice_line_id = inv_line_obj.create(cr, uid, { 'invoice_id': inv_id, 'name': name, 'origin': repair.name, - 'account_id': operation.product_id and operation.product_id.property_account_income and operation.product_id.property_account_income.id, + 'account_id': account_id, 'quantity': operation.product_uom_qty, 'invoice_line_tax_id': [(6,0,[x.id for x in operation.tax_id])], 'uos_id': operation.product_uom.id,