From e678571316569ddda52825d2cd8cd72b5e20ab22 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Mon, 25 Jul 2011 15:44:24 +0530 Subject: [PATCH] [IMP] account_anglo_saxon: Improve code bzr revid: mra@mra-laptop-20110725101424-q3zlft8s7tsz8dys --- addons/account_anglo_saxon/invoice.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/addons/account_anglo_saxon/invoice.py b/addons/account_anglo_saxon/invoice.py index e8a650e6a50..2bdac8b01fe 100644 --- a/addons/account_anglo_saxon/invoice.py +++ b/addons/account_anglo_saxon/invoice.py @@ -134,14 +134,13 @@ class account_invoice_line(osv.osv): 'taxes':line.get('taxes',[]), }) res += diff_res - return res - - def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None): - if not product: - return super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) - else: - res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) + return res + def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None, company_id=None): + fiscal_pool = self.pool.get('account.fiscal.position') + res = super(account_invoice_line, self).product_id_change(cr, uid, ids, product, uom, qty, name, type, partner_id, fposition_id, price_unit, address_invoice_id, currency_id, context, company_id) + if not product: + return res if type in ('in_invoice','in_refund'): product_obj = self.pool.get('product.product').browse(cr, uid, product, context=context) if type == 'in_invoice': @@ -153,11 +152,11 @@ class account_invoice_line(osv.osv): if not oa: oa = product_obj.categ_id.property_stock_account_output_categ and product_obj.categ_id.property_stock_account_output_categ.id if oa: - fpos = fposition_id and self.pool.get('account.fiscal.position').browse(cr, uid, fposition_id, context=context) or False - a = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, oa) - res['value'].update({'account_id':a}) + fpos = fposition_id and fiscal_pool.browse(cr, uid, fposition_id, context=context) or False + a = fiscal_pool.map_account(cr, uid, fpos, oa) + res['value'].update({'account_id':a}) return res - + account_invoice_line() class account_invoice(osv.osv): @@ -180,6 +179,6 @@ class account_invoice(osv.osv): line.update({'account_id': (account_data['id'],account_data['name'])}) res = super(account_invoice,self)._refund_cleanup_lines(cr, uid, lines) return res - + account_invoice() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: