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

Proposed by Nicolas Bessi - Camptocamp
Status: Merged
Merged at revision: 72
Proposed branch: lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_1250507-nbi
Merge into: lp:openerp-humanitarian-ngo/purchase-wkfl
Diff against target: 55 lines (+23/-3)
2 files modified
purchase_extended/model/purchase_order.py (+3/-3)
purchase_extended/view/purchase_order.xml (+20/-0)
To merge this branch: bzr merge lp:~camptocamp/openerp-humanitarian-ngo/purchase-wkfl-fix_1250507-nbi
Reviewer Review Type Date Requested Status
Joël Grand-Guillaume @ camptocamp code review + test Approve
Romain Deheele - Camptocamp (community) code review and test Approve
Review via email: mp+195006@code.launchpad.net

Description of the change

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

Depends on https://code.launchpad.net/~camptocamp/openerp-humanitarian-ngo/addons-backport-improve_on_change-nbi/+merge/195007

To post a comment you must log in.
Revision history for this message
Romain Deheele - Camptocamp (romaindeheele) wrote :

Hi,

LGTM,

Romain

review: Approve (code review and test)
Revision history for this message
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote :

LGTM, thanks !

review: Approve (code review + test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== 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 @@
242242
243 def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,243 def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
244 partner_id, date_order=False, fiscal_position_id=False, date_planned=False,244 partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
245 name=False, price_unit=False, state='draft', context=None):245 name=False, price_unit=False, context=None, state='draft', type='rfq', **kwargs):
246 res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids,246 res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids,
247 pricelist_id, product_id, qty, uom_id, partner_id, date_order,247 pricelist_id, product_id, qty, uom_id, partner_id, date_order,
248 fiscal_position_id, date_planned, name, price_unit, state, context)248 fiscal_position_id, date_planned, name, price_unit, context)
249 if state == 'draft':249 if state == 'draft' and type == 'bid':
250 res['value'].update({'price_unit': 0})250 res['value'].update({'price_unit': 0})
251 elif state in ('sent', 'draftbid', 'bid'):251 elif state in ('sent', 'draftbid', 'bid'):
252 if 'price_unit' in res['value']:252 if 'price_unit' in res['value']:
253253
=== 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 @@
56 <button name="draft_po" states="draft" string="Convert to PO"/>56 <button name="draft_po" states="draft" string="Convert to PO"/>
57 <button name="draft_po" states="bid" string="Convert to PO" class="oe_highlight"/>57 <button name="draft_po" states="bid" string="Convert to PO" class="oe_highlight"/>
58 </xpath>58 </xpath>
59 <field name="product_id" position="replace">
60 <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)"/>
61 </field>
62 <field name="product_qty" position="replace">
63 <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)"/>
64 </field>
59 </field>65 </field>
60 </record>66 </record>
61 <record id="purchase.purchase_rfq" model="ir.actions.act_window">67 <record id="purchase.purchase_rfq" model="ir.actions.act_window">
@@ -76,5 +82,19 @@
76 </xpath>82 </xpath>
77 </field>83 </field>
78 </record>84 </record>
85
86 <record id="on_change_on_po_line_form" model="ir.ui.view">
87 <field name="name">on change on po line form</field>
88 <field name="model">purchase.order.line</field>
89 <field name="inherit_id" ref="purchase.purchase_order_line_form" />
90 <field name="arch" type="xml">
91 <field name="product_id" position="replace">
92 <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)"/>
93 </field>
94 <field name="product_qty" position="replace">
95 <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)"/>
96 </field>
97 </field>
98 </record>
79 </data>99 </data>
80</openerp>100</openerp>

Subscribers

People subscribed via source and target branches