Ujjvala Collins (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-bug-795487-uco into 
lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)
Related bugs:
  Bug #795487 in OpenERP Addons: "can't unselect/make empty packaging field in 
the sale order line"
  https://bugs.launchpad.net/openobject-addons/+bug/795487

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-795487-uco/+merge/65440

[FIX] sale:
----------------
* Solved problem of packaging field not being empty on sale order line. 
(lp:795487)
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-795487-uco/+merge/65440
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-bug-795487-uco.
=== modified file 'sale/sale.py'
--- sale/sale.py	2011-05-18 16:45:45 +0000
+++ sale/sale.py	2011-06-22 06:03:24 +0000
@@ -1013,9 +1013,11 @@
 
     def product_id_change(self, cr, uid, ids, pricelist, product, qty=0,
             uom=False, qty_uos=0, uos=False, name='', partner_id=False,
-            lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False):
+            lang=False, update_tax=True, date_order=False, packaging=False, fiscal_position=False, flag=False, context=None):
         if not  partner_id:
             raise osv.except_osv(_('No Customer Defined !'), _('You have to select a customer in the sales form !\nPlease set one customer before choosing a product.'))
+        if not context:
+            context = {}
         warning = {}
         warning_msgs = ''
         product_uom_obj = self.pool.get('product.uom')
@@ -1023,7 +1025,7 @@
         product_obj = self.pool.get('product.product')
         if partner_id:
             lang = partner_obj.browse(cr, uid, partner_id).lang
-        context = {'lang': lang, 'partner_id': partner_id}
+        context.update({'lang': lang, 'partner_id': partner_id})
 
         if not product:
             return {'value': {'th_weight': 0, 'product_packaging': False,
@@ -1034,7 +1036,8 @@
 
         result = {}
         product_obj = product_obj.browse(cr, uid, product, context=context)
-        if not packaging and product_obj.packaging:
+        from_packaging = context.get('from_packaging', False)
+        if not packaging and product_obj.packaging and not from_packaging:
             packaging = product_obj.packaging[0].id
             result['product_packaging'] = packaging
         

=== modified file 'sale/sale_view.xml'
--- sale/sale_view.xml	2011-06-15 13:48:31 +0000
+++ sale/sale_view.xml	2011-06-22 06:03:24 +0000
@@ -142,7 +142,7 @@
                                             <field
                                                 name="product_packaging"
                                                 context="{'partner_id':parent.partner_id, 'quantity':product_uom_qty, 'pricelist':parent.pricelist_id, 'shop':parent.shop_id, 'uom':product_uom}"
-                                                on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position, False)"
+                                                on_change="product_id_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, 'lang' in context and context['lang'], False, parent.date_order, product_packaging, parent.fiscal_position, False, {'from_packaging': True})"
                                                 domain="[('product_id','=',product_id)]"
                                                 groups="base.group_extended"/>
 

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to