Ravi Gohil (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/6.0-opw-381574-rgo into 
lp:openobject-addons/6.0.

Requested reviews:
  Naresh(OpenERP) (nch-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-381574-rgo/+merge/92004

Hello,

Steps to reproduce:

* Add a new line (product) to either a sale.order or purchase.order
* Save
* Re-open the line item for editing and change the Unit Price of the product
* Save
* Re-open the line item for editing and change the quantity.
* Save

The Unit Price of the item has reverted to the original product price.

This fix fixes this issue with minimal changes.

Kindly review this,

Thanks.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/6.0-opw-381574-rgo/+merge/92004
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/6.0-opw-381574-rgo.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py	2011-12-06 16:23:01 +0000
+++ purchase/purchase.py	2012-02-08 10:36:20 +0000
@@ -737,6 +737,15 @@
         res['domain'] = domain
         return res
 
+    def product_qty_change(self, cr, uid, ids, pricelist, product, qty, uom,
+            partner_id, date_order=False, fiscal_position=False, date_planned=False,
+            name=False, price_unit=False, notes=False):
+        
+        data = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom, partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned, name=name, price_unit=price_unit, notes=notes)
+        #This will keep modified Unit Price for this order line when the quantity is changed
+        data['value']['price_unit'] = price_unit
+        return data
+
     def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom,
             partner_id, date_order=False, fiscal_position=False, date_planned=False,
             name=False, price_unit=False, notes=False):
@@ -751,7 +760,7 @@
         if not uom:
             res['value']['price_unit'] = 0.0
         return res
-
+  
     def action_confirm(self, cr, uid, ids, context=None):
         self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)
         return True

=== modified file 'purchase/purchase_view.xml'
--- purchase/purchase_view.xml	2011-02-24 19:57:10 +0000
+++ purchase/purchase_view.xml	2012-02-08 10:36:20 +0000
@@ -317,7 +317,7 @@
                     <notebook colspan="4">
                         <page string="Order Line">
                             <field name="product_id" colspan="4" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
-                            <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_id_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
+                            <field name="product_qty" context="partner_id=parent.partner_id,quantity=product_qty,pricelist=parent.pricelist_id,uom=product_uom,warehouse=parent.warehouse_id" on_change="product_qty_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
                             <field name="product_uom" on_change="product_uom_change(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes)"/>
                             <field colspan="4" name="name"/>
                             <field name="date_planned" widget="date"/>

=== modified file 'sale/sale.py'
--- sale/sale.py	2011-09-22 10:28:12 +0000
+++ sale/sale.py	2012-02-08 10:36:20 +0000
@@ -1145,6 +1145,15 @@
                 result.update({'price_unit': price})
         return {'value': result, 'domain': domain, 'warning': warning}
 
+    def product_qty_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, price_unit=False):
+
+        data = self.product_id_change(cr, uid, ids, pricelist, product, qty=qty, uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, lang=lang, update_tax=update_tax, date_order=date_order, packaging=packaging, fiscal_position=fiscal_position, flag=flag)
+        #This will keep modified Unit Price for this order line when the quantity is changed
+        data['value']['price_unit'] = price_unit
+        return data
+            
     def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0,
             uom=False, qty_uos=0, uos=False, name='', partner_id=False,
             lang=False, update_tax=True, date_order=False):

=== modified file 'sale/sale_view.xml'
--- sale/sale_view.xml	2011-07-08 10:51:30 +0000
+++ sale/sale_view.xml	2012-02-08 10:36:20 +0000
@@ -133,7 +133,7 @@
                                             <field
                                                 context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
                                                 name="product_uom_qty"
-                                                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, True)"
+                                                on_change="product_qty_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, True, price_unit)"
                                                 />
                                                 <field groups="product.group_uos" name="product_uos_qty"/>
                                                 <field groups="product.group_uos" name="product_uos"/>

=== modified file 'sale_layout/sale_layout_view.xml'
--- sale_layout/sale_layout_view.xml	2011-01-14 00:11:01 +0000
+++ sale_layout/sale_layout_view.xml	2012-02-08 10:36:20 +0000
@@ -28,7 +28,7 @@
 					                        context="partner_id=parent.partner_id,quantity=product_uom_qty,pricelist=parent.pricelist_id,shop=parent.shop_id,uom=product_uom"
 					                        name="product_uom_qty"
 					                        attrs="{'readonly':[('layout_type','!=','article')]}"
-					                        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)"
+					                        on_change="product_qty_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, flag, price_unit)"
 					                        select="1"/>
 					                    <field name="product_uom"
 					                  		 required="0"

_______________________________________________
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