From 11bd7a6774a17216bbb04afcbedf3b5c9eebee89 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 16 Feb 2015 14:18:43 +0100 Subject: [PATCH] [FIX] purchase: order line description being reset on qty change The name must be changed when changing of product, but not for other changes, quantity for instance. The 'or not uom_id' is just for retro-compatibility concerns uom_id being False actually means we just changed of product, and the name must therefore be changed name as been set as False in the onchange call in the view for the product_id field, in this rev., so the name being False now means th change of product Nevertheless, existing databases for which the view is not up to date won't have this change and we therefore have to rely on something else to know when the product has been changed or not. fixes #5295 opw-628138 --- addons/purchase/purchase.py | 10 ++++++---- addons/purchase/purchase_view.xml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/purchase/purchase.py b/addons/purchase/purchase.py index eea61a7b3c9..accce18ddbb 100644 --- a/addons/purchase/purchase.py +++ b/addons/purchase/purchase.py @@ -1007,10 +1007,12 @@ class purchase_order_line(osv.osv): 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 not name or not uom_id: + # The 'or not uom_id' part of the above condition can be removed in master. See commit message of the rev. introducing this line. + 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 3c8afceb6e7..41088f998a9 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -205,7 +205,7 @@ - +