Merge lp:~camptocamp/sale-financial/7.0-port-sale_line_watcher into lp:~sale-core-editors/sale-financial/7.0

Proposed by Yannick Vaucher @ Camptocamp
Status: Needs review
Proposed branch: lp:~camptocamp/sale-financial/7.0-port-sale_line_watcher
Merge into: lp:~sale-core-editors/sale-financial/7.0
Diff against target: 158 lines (+47/-41)
3 files modified
sale_line_watcher/__openerp__.py (+25/-7)
sale_line_watcher/sale_view.xml (+13/-19)
sale_line_watcher/sale_watcher.py (+9/-15)
To merge this branch: bzr merge lp:~camptocamp/sale-financial/7.0-port-sale_line_watcher
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp Needs Resubmitting
Raphaël Valyi - http://www.akretion.com Approve
Pedro Manuel Baeza Abstain
Review via email: mp+214058@code.launchpad.net

Commit message

Portage to v7 of module sale_line_watcher

Description of the change

Portage of module sale_line_watcher to v7

Rewritten using web_context_tunnel

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Yannick, several things:

- Instead of replacing a field, it's better to put position="attributes" and only overwrite attribute on_change, so that you don't replace another attributes of the field.

- I think it's better to use module web_context_tunnel to avoid changes on the signature of the method that provokes incompatibilities between modules.

Regards.

review: Needs Fixing (code review)
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

Thanks Pedro I wasn't aware of web_context_tunnel. This is indeed the right time to use it.

It would make this module obsolete.

Back to WIP

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

I rewrite all modules sale_line_watcher, sale_line_floor and sale_markup using web_context_tunnel.

It allowed me to break the dependancy from sale_markup on sale_line_floor

Looking for reviewers !

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Yannick, thanks for the changes. Do you it's worth while to keep this module instead of dropping it and implementing corresponding on_change when needed on dependant modules? One of the advantages of web_context_tunnel is that the context dictionary passed on each on_change is aggregated to previous ones, so there will not be possible incompatibilities (except a reuse of a key name with different meaning).

Regards.

review: Needs Information
Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

How would I call super() in onchange if it doesn't exist ?

My intend was to break dependency of sale_markup on sale_floor_price but both use those on_changes which doesn't exists.

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Why don't you check super method existence?:

parent = super(children, self)
if hasattr(parent, 'method') and callable(getattr(parent, 'method')):
    parent.method(cr, uid, ...

This seems a little tricky, but it removes the needed of the glue module. What do you think?

Regards.

Revision history for this message
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote :

In that case this module is providing an interface to declare the onchanges it seems cleaner to me.

Cheers

Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

I think on contrary, but let others give their opinion.

Regards.

review: Abstain
Revision history for this message
Raphaël Valyi - http://www.akretion.com (rvalyi) wrote :

I tend to agree with Pedro.

But I would say, given that Yannick refactored several modules to use this interface and that it seems working.

I would say, let's approve that 1st change and get the stuff working. Next, if somebody finds it useful to kill that module and refactor dependent modules in v8 and if that stays simple I would approve such new change.

But meanwhile, I approve this change because it's already an improvement and it's there.

review: Approve
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) wrote :

Hello,

The management of the project has moved to Github: https://github.com/OCA/sale-financial

Please migrate your merge proposal to Github. You may want to check https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub for an explanation on how to proceed.

Thanks for contributing to the project

review: Needs Resubmitting

Unmerged revisions

24. By Yannick Vaucher @ Camptocamp on 2014-04-04

improve imports

23. By Yannick Vaucher @ Camptocamp on 2014-04-04

improve module description

22. By Yannick Vaucher @ Camptocamp on 2014-04-04

Rewrite onchange to use web_context_tunnel module

21. By Yannick Vaucher @ Camptocamp on 2014-04-03

Portage of module sale_line_watcher

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'sale_line_watcher/__openerp__.py'
2--- sale_line_watcher/__openerp__.py 2013-11-14 08:16:22 +0000
3+++ sale_line_watcher/__openerp__.py 2014-04-04 14:22:40 +0000
4@@ -23,19 +23,37 @@
5 'author' : 'Camptocamp',
6 'maintainer': 'Camptocamp',
7 'category': 'Hidden',
8- 'complexity': "normal", # easy, normal, expert
9- 'depends' : ['base', 'sale'],
10- 'description': """Add new base onchange methods on sale_order class
11-
12- onchange_price_unit and onchange_discount both accept the following arguments:
13- (self, cr, uid, ids, price_unit, product_id, discount, product_uom, pricelist, **kwargs)
14+ 'complexity': "normal",
15+ 'depends' : ['base', 'sale', 'web_context_tunnel'],
16+ 'description': """
17+Sale order line watcher
18+=======================
19+
20+Add new base onchange methods on Sale Order Line form.
21+
22+`onchange_price_unit` and `onchange_discount`
23+
24+Those onchanges can be extendend with additionnal contexts using
25+`web_context_tunnel` module
26+
27+Dependencies
28+------------
29+
30+`web_context_tunnel` module from lp:server-env-tools branch
31+
32+Contributors
33+------------
34+
35+* Nicolas Bessi <nicolas.bessi@camptocamp.com>
36+* Yannick Vaucher <yannick.vaucher@camptocamp.com>
37+
38 """,
39 'website': 'http://www.camptocamp.com',
40 'init_xml': [],
41 'update_xml': ['sale_view.xml'],
42 'demo_xml': [],
43 'tests': [],
44- 'installable': False,
45+ 'installable': True,
46 'auto_install': False,
47 'license': 'AGPL-3',
48 'application': True}
49
50=== modified file 'sale_line_watcher/sale_view.xml'
51--- sale_line_watcher/sale_view.xml 2012-05-29 07:06:32 +0000
52+++ sale_line_watcher/sale_view.xml 2014-04-04 14:22:40 +0000
53@@ -3,27 +3,24 @@
54 <data>
55 <record model="ir.ui.view" id="sale_watcher_sale_order_line_form2">
56 <field name="name">sales_line_watcher.view.form2</field>
57- <field name="type">form</field>
58 <field name="model">sale.order.line</field>
59 <field name="inherit_id" ref="sale.view_order_line_form2" />
60 <field name="arch" type="xml">
61- <xpath expr="//field[@name='price_unit']" position="replace">
62- <field name="price_unit"
63- on_change="onchange_price_unit(price_unit ,product_id, discount, product_uom_qty, parent.pricelist_id)"
64- select="2"/>
65+ <xpath expr="//field[@name='price_unit']" position="attributes">
66+ <attribute name="context">{}</attribute>
67+ <attribute name="on_change">onchange_price_unit(context)</attribute>
68 </xpath>
69 </field>
70 </record>
71
72 <record model="ir.ui.view" id="sale_watcher_sale_order_line_form3">
73 <field name="name">sales_line_watcher.view.form3</field>
74- <field name="type">form</field>
75 <field name="model">sale.order.line</field>
76 <field name="inherit_id" ref="sale.view_order_line_form2" />
77 <field name="arch" type="xml">
78- <xpath expr="//field[@name='discount']" position="replace">
79- <field name="discount"
80- on_change="onchange_discount(price_unit, product_id, discount, product_uom_qty, parent.pricelist_id)"/>
81+ <xpath expr="//field[@name='discount']" position="attributes">
82+ <attribute name="context">{}</attribute>
83+ <attribute name="on_change">onchange_discount(context)</attribute>
84 </xpath>
85 </field>
86 </record>
87@@ -32,25 +29,22 @@
88 <field name="name">sales_line_watcher.form.floorprice</field>
89 <field name="model">sale.order</field>
90 <field name="inherit_id" ref="sale.view_order_form" />
91- <field name="type">form</field>
92 <field name="arch" type="xml">
93- <field name="discount" position="replace">
94- <field name="discount"
95- on_change="onchange_discount(price_unit, product_id,discount, product_uom_qty, parent.pricelist_id)"/>
96+ <field name="discount" position="attributes">
97+ <attribute name="context">{}</attribute>
98+ <attribute name="on_change">onchange_discount(context)</attribute>
99 </field>
100 </field>
101- </record>w
102+ </record>
103
104 <record id="sale_watcher_order_form2" model="ir.ui.view">
105 <field name="name">sales_line_watcher.form.floorprice</field>
106 <field name="model">sale.order</field>
107 <field name="inherit_id" ref="sale.view_order_form" />
108- <field name="type">form</field>
109 <field name="arch" type="xml">
110- <field name="price_unit" position="replace">
111- <field name="price_unit"
112- on_change="onchange_price_unit(price_unit ,product_id ,discount, product_uom_qty, parent.pricelist_id)"
113- select="2"/>
114+ <field name="price_unit" position="attributes">
115+ <attribute name="context">{}</attribute>
116+ <attribute name="on_change">onchange_price_unit(context)</attribute>
117 </field>
118 </field>
119 </record>
120
121=== modified file 'sale_line_watcher/sale_watcher.py'
122--- sale_line_watcher/sale_watcher.py 2012-05-29 07:06:32 +0000
123+++ sale_line_watcher/sale_watcher.py 2014-04-04 14:22:40 +0000
124@@ -19,26 +19,20 @@
125 #
126 ##############################################################################
127
128-from osv.orm import Model
129+from openerp.osv.orm import Model
130
131 class SaleOrderLine(Model):
132 _inherit = 'sale.order.line'
133
134- def onchange_price_unit(self, cr, uid, ids,
135- price_unit, product_id, discount, product_uom, pricelist,
136- **kwargs):
137- '''
138+ def onchange_price_unit(self, cr, uid, ids, context=None):
139+ """
140 Place holder function for onchange unit price
141- '''
142- res = {}
143- return res
144+ """
145+ return {}
146
147- def onchange_discount(self, cr, uid, ids,
148- price_unit, product_id, discount, product_uom, pricelist,
149- **kwargs):
150- '''
151+ def onchange_discount(self, cr, uid, ids, context=None):
152+ """
153 Place holder function for onchange discount
154- '''
155- res = {}
156- return res
157+ """
158+ return {}
159

Subscribers

People subscribed via source and target branches

to all changes: