← Back to team overview

openerp-community-reviewer team mailing list archive

lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_1250507-nbi into lp:openerp-humanitarian-ngo/purchase-wkfl

 

Nicolas Bessi - Camptocamp has proposed merging lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_1250507-nbi into lp:openerp-humanitarian-ngo/purchase-wkfl.

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/purchase-wkfl-fix_1250507-nbi/+merge/195006

Fix the onchange_product_id that did not take in account the type of the PO. It breaks the possibility to make a standard requisition.

The code in pruchase extended is was a duplicate of modified purchase addon. Duplicate has bee remove from original addons backport.

We also try to find the less nasty 'non viable' solution to handle onchange, by putting required new args after context.
It should preserve other addons that override the same onchange but does not depends on purchase-extended.

fix bug 1250507
-- 
https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_1250507-nbi/+merge/195006
Your team OpenERP for Humanitarian Core Editors is requested to review the proposed merge of lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_1250507-nbi into lp:openerp-humanitarian-ngo/purchase-wkfl.
=== modified file 'purchase_extended/model/purchase_order.py'
--- purchase_extended/model/purchase_order.py	2013-11-01 11:44:19 +0000
+++ purchase_extended/model/purchase_order.py	2013-11-13 09:00:09 +0000
@@ -242,11 +242,11 @@
 
     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, state='draft', type='rfq', **kwargs):
         res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids,
                 pricelist_id, product_id, qty, uom_id, partner_id, date_order,
-                fiscal_position_id, date_planned, name, price_unit, state, context)
-        if state == 'draft':
+                fiscal_position_id, date_planned, name, price_unit, context)
+        if state == 'draft' and type == 'bid':
             res['value'].update({'price_unit': 0})
         elif state in ('sent', 'draftbid', 'bid'):
             if 'price_unit' in res['value']:

=== modified file 'purchase_extended/view/purchase_order.xml'
--- purchase_extended/view/purchase_order.xml	2013-08-13 13:20:04 +0000
+++ purchase_extended/view/purchase_order.xml	2013-11-13 09:00:09 +0000
@@ -56,6 +56,12 @@
                     <button name="draft_po" states="draft" string="Convert to PO"/>
                     <button name="draft_po" states="bid" string="Convert to PO" class="oe_highlight"/>
                 </xpath>
+                <field name="product_id" position="replace">
+                    <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,parent.state,parent.type)"/>
+                </field>
+                <field name="product_qty" position="replace">
+                    <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,parent.state,parent.type)"/>
+                </field>
             </field>
         </record>
         <record id="purchase.purchase_rfq" model="ir.actions.act_window">
@@ -76,5 +82,19 @@
                 </xpath>
             </field>
         </record>
+
+        <record id="on_change_on_po_line_form" model="ir.ui.view">
+          <field name="name">on change on po line form</field>
+          <field name="model">purchase.order.line</field>
+          <field name="inherit_id" ref="purchase.purchase_order_line_form" />
+          <field name="arch" type="xml">
+              <field name="product_id" position="replace">
+                  <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,parent.state,parent.type)"/>
+              </field>
+              <field name="product_qty" position="replace">
+                  <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,parent.state,parent.type)"/>
+              </field>
+          </field>
+        </record>
     </data>
 </openerp>


Follow ups