openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #01337
lp:~camptocamp/openerp-humanitarian-ngo/addons-backport-improve_on_change-nbi into lp:openerp-humanitarian-ngo/addons-backport
Nicolas Bessi - Camptocamp has proposed merging lp:~camptocamp/openerp-humanitarian-ngo/addons-backport-improve_on_change-nbi into lp:openerp-humanitarian-ngo/addons-backport.
Requested reviews:
OpenERP for Humanitarian Core Editors (humanitarian-core-editors)
Related bugs:
Bug #1250507 in OpenERP for Humanitarian NGOs: "purchase-extended breaks PO unit price"
https://bugs.launchpad.net/openerp-humanitarian-ngo/+bug/1250507
For more details, see:
https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/addons-backport-improve_on_change-nbi/+merge/195007
Fix onchange_product_id on purchase order line that has a changed signature.
On change modification was not propagated on every addons and will
breaks community addons compatibility.
State validation has also be extracted and put in purchase extented.
This will allows to have standard PO to work too.
It will also help to get rid of this specific addons branch if possible at middle term
fix bug 1250507
--
https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/addons-backport-improve_on_change-nbi/+merge/195007
Your team OpenERP for Humanitarian Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-humanitarian-ngo/addons-backport-improve_on_change-nbi into lp:openerp-humanitarian-ngo/addons-backport.
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2013-08-29 11:44:33 +0000
+++ purchase/purchase.py 2013-11-13 09:03:21 +0000
@@ -943,7 +943,7 @@
return {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'product_uom' : uom_id or False}}
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, context=context, state=state,)
def _get_date_planned(self, cr, uid, supplier_info, date_order_str, lead_time, context=None):
"""Return the datetime value to use as Schedule Date (``date_planned``) for
@@ -970,7 +970,7 @@
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, context=None):
"""
onchange handler of product_id.
"""
@@ -1048,14 +1048,12 @@
product_lead_time = supplierinfo.delay if supplierinfo else 0
res['value'].update({'product_lead_time': product_lead_time})
price = price_unit
- if state not in ('sent','bid'):
- # - determine price_unit and taxes_id
- if pricelist_id:
- price = product_pricelist.price_get(cr, uid, [pricelist_id],
- product.id, qty or 1.0, partner_id or False, {'uom': uom_id, 'date': date_order})[pricelist_id]
- else:
- price = product.standard_price
-
+ # - determine price_unit and taxes_id
+ if pricelist_id:
+ price = product_pricelist.price_get(cr, uid, [pricelist_id],
+ product.id, qty or 1.0, partner_id or False, {'uom': uom_id, 'date': date_order})[pricelist_id]
+ else:
+ price = product.standard_price
taxes = account_tax.browse(cr, uid, map(lambda x: x.id, product.supplier_taxes_id))
fpos = fiscal_position_id and account_fiscal_position.browse(cr, uid, fiscal_position_id, context=context) or False
taxes_ids = account_fiscal_position.map_tax(cr, uid, fpos, taxes)
=== modified file 'purchase/purchase_view.xml'
--- purchase/purchase_view.xml 2013-08-29 11:44:33 +0000
+++ purchase/purchase_view.xml 2013-11-13 09:03:21 +0000
@@ -206,13 +206,13 @@
<page string="Products">
<field name="order_line">
<tree string="Purchase Order Lines" editable="bottom">
- <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,parent.state,context)"/>
+ <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
<field name="name"/>
<field name="date_planned"/>
<field name="product_lead_time" on_change="onchange_lead_time(parent.date_order,date_planned,product_lead_time,context)" />
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
<field name="account_analytic_id" groups="purchase.group_analytic_accounting" domain="[('type','not in',('view','template'))]"/>
- <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,parent.state,context)"/>
+ <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,context)"/>
<field name="product_uom" groups="product.group_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,parent.state,context)"/>
<field name="price_unit"/>
<field name="taxes_id" widget="many2many_tags" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/>
@@ -393,11 +393,11 @@
<sheet>
<group>
<group>
- <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,'draft',context)"/>
+ <field name="product_id" on_change="onchange_product_id(parent.pricelist_id,product_id,0,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,context)"/>
<label for="product_qty"/>
<div>
- <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,'draft',context)" class="oe_inline"/>
- <field name="product_uom" groups="product.group_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,'draft',context)" class="oe_inline"/>
+ <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,context)" class="oe_inline"/>
+ <field name="product_uom" groups="product.group_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,context)" class="oe_inline"/>
</div>
<field name="price_unit"/>
</group>
Follow ups