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
1=== modified file 'purchase_extended/model/purchase_order.py'
2--- purchase_extended/model/purchase_order.py 2013-11-01 11:44:19 +0000
3+++ purchase_extended/model/purchase_order.py 2013-11-13 09:00:09 +0000
4@@ -242,11 +242,11 @@
5
6 def onchange_product_id(self, cr, uid, ids, pricelist_id, product_id, qty, uom_id,
7 partner_id, date_order=False, fiscal_position_id=False, date_planned=False,
8- name=False, price_unit=False, state='draft', context=None):
9+ name=False, price_unit=False, context=None, state='draft', type='rfq', **kwargs):
10 res = super(purchase_order_line, self).onchange_product_id(cr, uid, ids,
11 pricelist_id, product_id, qty, uom_id, partner_id, date_order,
12- fiscal_position_id, date_planned, name, price_unit, state, context)
13- if state == 'draft':
14+ fiscal_position_id, date_planned, name, price_unit, context)
15+ if state == 'draft' and type == 'bid':
16 res['value'].update({'price_unit': 0})
17 elif state in ('sent', 'draftbid', 'bid'):
18 if 'price_unit' in res['value']:
19
20=== modified file 'purchase_extended/view/purchase_order.xml'
21--- purchase_extended/view/purchase_order.xml 2013-08-13 13:20:04 +0000
22+++ purchase_extended/view/purchase_order.xml 2013-11-13 09:00:09 +0000
23@@ -56,6 +56,12 @@
24 <button name="draft_po" states="draft" string="Convert to PO"/>
25 <button name="draft_po" states="bid" string="Convert to PO" class="oe_highlight"/>
26 </xpath>
27+ <field name="product_id" position="replace">
28+ <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)"/>
29+ </field>
30+ <field name="product_qty" position="replace">
31+ <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)"/>
32+ </field>
33 </field>
34 </record>
35 <record id="purchase.purchase_rfq" model="ir.actions.act_window">
36@@ -76,5 +82,19 @@
37 </xpath>
38 </field>
39 </record>
40+
41+ <record id="on_change_on_po_line_form" model="ir.ui.view">
42+ <field name="name">on change on po line form</field>
43+ <field name="model">purchase.order.line</field>
44+ <field name="inherit_id" ref="purchase.purchase_order_line_form" />
45+ <field name="arch" type="xml">
46+ <field name="product_id" position="replace">
47+ <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)"/>
48+ </field>
49+ <field name="product_qty" position="replace">
50+ <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)"/>
51+ </field>
52+ </field>
53+ </record>
54 </data>
55 </openerp>

Subscribers

People subscribed via source and target branches