From 06187405c19727c5e20248a3b3515adb67842ef1 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Thu, 22 Jan 2015 11:43:25 +0100 Subject: [PATCH] [FIX] purchase: do not erase description when change quantity Add a flag to replace or not the previous product description. Apply the same logic than in sale. Change the description field on a purchase line only when the product is changed. opw 620093 Clean the views and replace wrong parameter in warning --- addons/purchase/purchase.py | 15 ++++++++------- addons/purchase/purchase_view.xml | 22 ++++++++++++++++++---- addons/warning/warning.py | 4 ++-- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index 088688fbb97..5f17edb1604 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1026,7 +1026,7 @@ class purchase_order_line(osv.osv): context = dict(context, purchase_uom_check=True) return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id, date_order=date_order, fiscal_position_id=fiscal_position_id, date_planned=date_planned, - name=name, price_unit=price_unit, state=state, context=context) + name=name, price_unit=price_unit, state=state, replace=False, context=context) def _get_date_planned(self, cr, uid, supplier_info, date_order_str, context=None): """Return the datetime value to use as Schedule Date (``date_planned``) for @@ -1058,7 +1058,7 @@ class purchase_order_line(osv.osv): def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id, partner_id, date_order=False, fiscal_position_id=False, date_planned=False, - name=False, price_unit=False, state='draft', context=None): + name=False, price_unit=False, state='draft', replace=True, context=None): """ onchange handler of product_id. """ @@ -1088,11 +1088,12 @@ class purchase_order_line(osv.osv): lang = res_partner.browse(cr, uid, partner_id).lang context_partner.update( {'lang': lang, 'partner_id': partner_id} ) product = product_product.browse(cr, uid, product_id, context=context_partner) - #call name_get() with partner in the context to eventually match name and description in the seller_ids field - dummy, name = product_product.name_get(cr, uid, product_id, context=context_partner)[0] - if product.description_purchase: - name += '\n' + product.description_purchase - res['value'].update({'name': name}) + if replace: + #call name_get() with partner in the context to eventually match name and description in the seller_ids field + dummy, name = product_product.name_get(cr, uid, product_id, context=context_partner)[0] + if product.description_purchase: + name += '\n' + product.description_purchase + res['value'].update({'name': name}) # - set a domain on product_uom res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]} diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 57389d65349..7d2f9b1dd90 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -239,12 +239,19 @@ - + - + @@ -422,10 +429,17 @@ + on_change="onchange_product_id(parent.pricelist_id, product_id, 0, False, + parent.partner_id, parent.date_order, parent.fiscal_position, date_planned, + name, False, 'draft', True, context)" + context="{'partner_id': parent.partner_id}"/>