Ravi Gohil (OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/6.1-opw-381574-rgo into
lp:openobject-addons/6.1.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-381574-rgo/+merge/93978
Hello,
There are several issues with sale/purchase order line:
-> When we have modified Unit Price for a product in order line and if we
change the Quantity, the modified price is reverted,
-> When we have a product configured with 'Sales/Purchase Description' and
selecting this product in order line sets the description in 'Notes' field of
order line, and this value stays even if we select the other product without
sales/purchase description,
-> When add extra text to the Description field of order line and if we change
the product UOM, the modified Description is reverted,
This fix fixes the above issues,
Kindly review it,
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/6.1-opw-381574-rgo/+merge/93978
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/6.1-opw-381574-rgo.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2012-02-16 12:34:08 +0000
+++ purchase/purchase.py 2012-02-21 12:35:27 +0000
@@ -704,10 +704,12 @@
onchange handler of product_uom.
"""
if not uom_id:
- return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or'', 'product_uom' : uom_id or False}}
- return self.onchange_product_id(cr, uid, ids, pricelist_id, product_id, qty, uom_id,
+ return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom_id or False}}
+ res = 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, notes=notes, context=context)
+ res['value']['name'] = name
+ return res
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
@@ -724,6 +726,19 @@
supplier_delay = int(supplier_info.delay) if supplier_info else 0
return datetime.strptime(date_order_str, DEFAULT_SERVER_DATE_FORMAT) + relativedelta(days=supplier_delay)
+ def onchange_product_qty(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, notes=False, context=None):
+
+ data = self.product_id_change(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, notes=notes, context=context)
+ #This will keep modified Unit Price and Description for this order line when the quantity is changed
+ data['value']['price_unit'] = price_unit
+ data['value']['name'] = name
+
+ return data
+
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, notes=False, context=None):
@@ -733,9 +748,9 @@
if context is None:
context = {}
- res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom_id or False}}
+ res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': '', 'product_uom' : uom_id or False}}
if not product_id:
- return res
+ return {'value': {'price_unit': 0.0, 'name': '', 'notes': '', 'product_qty': 1.0, 'date_planned': False}}
product_product = self.pool.get('product.product')
product_uom = self.pool.get('product.uom')
@@ -804,6 +819,7 @@
product_id_change = onchange_product_id
product_uom_change = onchange_product_uom
+ product_qty_change = onchange_product_qty
def action_confirm(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'confirmed'}, context=context)
=== modified file 'purchase/purchase_view.xml'
--- purchase/purchase_view.xml 2012-02-07 13:17:19 +0000
+++ purchase/purchase_view.xml 2012-02-21 12:35:27 +0000
@@ -360,7 +360,7 @@
<notebook colspan="4">
<page string="Order Line">
<field name="product_id" colspan="4" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)" required="1"/>
- <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
+ <field name="product_qty" on_change="onchange_product_qty(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
<field name="product_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/>
<field colspan="4" name="name"/>
<field name="date_planned" widget="date"/>
=== modified file 'sale/sale.py'
--- sale/sale.py 2012-02-16 16:52:53 +0000
+++ sale/sale.py 2012-02-21 12:35:27 +0000
@@ -1204,7 +1204,7 @@
if not product:
return {'value': {'th_weight': 0, 'product_packaging': False,
- 'product_uos_qty': qty}, 'domain': {'product_uom': [],
+ 'product_uos_qty': 1.0, 'notes': '', 'price_unit': 0.0, 'product_uom_qty': 1.0, 'name': ''}, 'domain': {'product_uom': [],
'product_uos': []}}
if not date_order:
date_order = time.strftime(DEFAULT_SERVER_DATE_FORMAT)
@@ -1304,6 +1304,23 @@
}
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, context=None):
+
+ 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, context=context)
+ #This will keep modified Unit Price, Description and notes for this order line when the quantity is changed
+ data['value']['price_unit'] = price_unit
+ data['value']['name'] = name
+ if 'notes' in data['value']:
+ del data['value']['notes']
+ 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, context=None):
@@ -1317,6 +1334,10 @@
del res['value']['product_uom']
if not uom:
res['value']['price_unit'] = 0.0
+ if 'name' in res['value']:
+ del res['value']['name']
+ if 'notes' in res['value']:
+ del res['value']['notes']
return res
def unlink(self, cr, uid, ids, context=None):
=== modified file 'sale/sale_view.xml'
--- sale/sale_view.xml 2012-01-31 13:36:57 +0000
+++ sale/sale_view.xml 2012-02-21 12:35:27 +0000
@@ -136,7 +136,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, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, context)"/>
+ on_change="product_qty_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, price_unit, context)"/>
<field name="product_uom"
on_change="product_uom_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, context)"
nolabel="1"/>
=== modified file 'sale_layout/sale_layout_view.xml'
--- sale_layout/sale_layout_view.xml 2011-12-21 13:10:28 +0000
+++ sale_layout/sale_layout_view.xml 2012-02-21 12:35:27 +0000
@@ -34,7 +34,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="{'invisible':[('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, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, context)"/>
+ on_change="product_qty_change(parent.pricelist_id,product_id,product_uom_qty,product_uom,product_uos_qty,product_uos,name,parent.partner_id, False, False, parent.date_order, product_packaging, parent.fiscal_position, True, price_unit, context)"/>
<field name="product_uom"
nolabel="1"
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