From e488f9b5682cd1599b3df0c26aee44e6b48539c1 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Tue, 11 Sep 2012 19:17:17 +0530 Subject: [PATCH] [FIX]: Fix bug:1043181 : remove so line invoice after giving advance percentage payment bzr revid: atp@tinyerp.com-20120911134717-vfdhltg2lno13nqf --- .../sale/wizard/sale_make_invoice_advance.py | 21 ++++++++++++++++++- addons/sale_stock/sale_stock.py | 2 -- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 7c35e411876..91f9c78eb05 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -43,6 +43,26 @@ class sale_advance_payment_inv(osv.osv_memory): help="The amount to be invoiced in advance."), } + + def fields_view_get(self, cr, uid, view_id=None, view_type=False, context=None, toolbar=False, submenu=False): + if context is None:context = {} + user_obj = self.pool.get('res.users') + res = super(sale_advance_payment_inv, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu) + active_ids = context.get('active_ids', False) + invoice_obj = self.pool.get('account.invoice') + model = context.get('active_model', '') + model_obj = self.pool.get(model) + if context.get('active_model', '') in ['sale.order'] and context.get('active_ids', []): + order_data = model_obj.read(cr, uid, context.get('active_ids'), ['invoice_ids'])[0] + for inv in invoice_obj.browse(cr, uid, order_data.get('invoice_ids')): + for line in inv.invoice_line: + # if percentage(Advance payment) is given then remove sale order lines option.. + if str(line.name).startswith("Advance of"): + for field in res['fields']: + if field == 'advance_payment_method': + res['fields'][field]['selection'] = [('all', 'Invoice all the Sale Order'), ('percentage', 'Percentage'), ('fixed', 'Fixed Price'),] + return res + def _get_advance_product(self, cr, uid, context=None): try: product = self.pool.get('ir.model.data').get_object(cr, uid, 'sale', 'advance_product_0') @@ -93,7 +113,6 @@ class sale_advance_payment_inv(osv.osv_memory): 'search_default_order_id': sale_ids and sale_ids[0] or False, } return res - assert wizard.advance_payment_method in ('fixed', 'percentage') inv_ids = [] diff --git a/addons/sale_stock/sale_stock.py b/addons/sale_stock/sale_stock.py index b3a44117453..415410e0ca6 100644 --- a/addons/sale_stock/sale_stock.py +++ b/addons/sale_stock/sale_stock.py @@ -685,8 +685,6 @@ class sale_advance_payment_inv(osv.osv_memory): sale_line_obj = self.pool.get('sale.order.line') wizard = self.browse(cr, uid, ids[0], context) sale_ids = context.get('active_ids', []) - - assert wizard.advance_payment_method in ('fixed', 'percentage') inv_ids = [] for sale in sale_obj.browse(cr, uid, sale_ids, context=context): if sale.order_policy == 'postpaid':