Merge lp:~camptocamp/margin-analysis/7.0-port-product_historical_margin-xml-retab-yvr into lp:~margin-analysis-core-editors/margin-analysis/7.0
- 7.0-port-product_historical_margin-xml-retab-yvr
- Merge into 7.0
Status: | Merged |
---|---|
Merged at revision: | 50 |
Proposed branch: | lp:~camptocamp/margin-analysis/7.0-port-product_historical_margin-xml-retab-yvr |
Merge into: | lp:~margin-analysis-core-editors/margin-analysis/7.0 |
Diff against target: |
285 lines (+118/-119) 4 files modified
product_historical_margin/account_invoice_view.xml (+74/-75) product_historical_margin/invoice.py (+4/-3) product_historical_margin/product_view.xml (+2/-2) product_historical_margin/wizard/historical_margin_view.xml (+38/-39) |
To merge this branch: | bzr merge lp:~camptocamp/margin-analysis/7.0-port-product_historical_margin-xml-retab-yvr |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Pedro Manuel Baeza | code review, no test | Needs Information | |
Joël Grand-Guillaume @ camptocamp | code review, no tests | Approve | |
Review via email: mp+190350@code.launchpad.net |
Commit message
Description of the change
Pre-portage only retabing XML for readability
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Hi, Yannick, thank you very much for the cleaning.
I wonder, because we have never discussed this before, what is the correct space indentation for XML. In Python it is used 4 spaces. I have seen that you have used 2 spaces. I see this a little short, but I would like to know the opinion of others.
Regards.
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
Hi,
We do not really define anything regarding the XML file... I will be in favor of having the same space identation : 4 spaces.
Regards,
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
I prefer 2 spaces indentations as in xml you can have a lot of indentation levels
In python with max width of 80 or 100 and for readability you better have a maximum of 5 indentation level and can have only 3 levels.
class:
4s def:
8s code
12s nested code
In XML if you want to do inheritance you will need at least 6 levels
<openerp>
4s <data>
8s <record id=
12s <field name="arch"
16s <xpath
20s <field name="my_new_field"
Furthermore, with html and v7 style you get even more indentation levels
Let's take the kanban view of res.partner as a bad example:
line 237 in res_partner_
it begins at columns 77
(19 levels of indentation and if should be 20 levels as sheet tag isn't properly indented)
In my opinion, 2 spaces in XML doesn't make it less readable.
But I don't intend to indent by 2 if we choose 4 for our code.
3 spaces would be a compromise and tabs would let people decide how to display it and reduce file size.
But let's keep the discution on 2 or 4 as it would start being more philosophical :)
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
I vote then for 2 spaces
Pedro Manuel Baeza (pedro.baeza) wrote : | # |
Then maybe we have to tell to whole community and get an agreement to use this convention across all the contributions. Don't you think?
Regards.
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
+1 to add this in the community docs Maxime wrote a little while ago.
On Thu, Oct 17, 2013 at 1:35 PM, Pedro Manuel Baeza
<email address hidden>wrote:
> Then maybe we have to tell to whole community and get an agreement to use
> this convention across all the contributions. Don't you think?
>
> Regards.
> --
>
> https:/
> You are reviewing the proposed merge of
> lp:~camptocamp/margin-analysis/7.0-port-product_historical_margin-xml-retab-yvr
> into lp:margin-analysis.
>
--
*camptocamp*
INNOVATIVE SOLUTIONS
BY OPEN SOURCE EXPERTS
*Joël Grand-Guillaume*
Division Manager
Business Solutions
+41 21 619 10 28
www.camptocamp.com
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
With regards to XML tab width: the defacto standard in official addons is 4 throughout even if there are some inconsistencies. I vote for sticking to 4 for that reason, even if 2 would have been more practical.
Yannick Vaucher @ Camptocamp (yvaucher-c2c) wrote : | # |
About OpenERP "standard" of former code we also have import with bad namespace, use of class alias and useless class instanciations.
In OpenERP coding guidelines nothing is clearly said about XML indentation:
https:/
As you said, this is defacto
Nevertheless, my opinion is that we shouldn't say "this is a standard" if there are no obvious reasons beside it.
So what will be the community standard we will decide and why?
By the way, readability counts
(Does it also counts on code review in lp?)
David BEAL (ak) (davidbeal) wrote : | # |
I vote then for 2 spaces
more readeable for new use case (kanban, futures cases)
Bogdan Stanciu (bstanciu) wrote : | # |
2 spaces for reasons given above. thanks
Ronald Portier (ronald-portier) wrote : | # |
I also vote for 2 spaces.
Also please: if there is more then one attribute, have each attribute on a new line.
(Unfortunately OpenERP will break if you spread attributes over multiple lines, even where this would be perfectly logical, as with long domain expressions).
Having each attribute on a new line will make changes much more "diff friendly". if you change one attribute, instead of having to scan a very long line where exactly anything changed, this will be immediately obvious.
- 48. By Joël Grand-Guillaume @ camptocamp
-
[FIX] Function signature addiing context
Joël Grand-Guillaume @ camptocamp (jgrandguillaume-c2c) wrote : | # |
We go for 2 spaces then it seems. Can we go further on this merge please ?
Preview Diff
1 | === modified file 'product_historical_margin/account_invoice_view.xml' |
2 | --- product_historical_margin/account_invoice_view.xml 2012-07-12 13:56:17 +0000 |
3 | +++ product_historical_margin/account_invoice_view.xml 2013-11-14 15:32:34 +0000 |
4 | @@ -1,81 +1,80 @@ |
5 | <?xml version="1.0" encoding="utf-8"?> |
6 | <openerp> |
7 | <data> |
8 | - |
9 | - <record id="view_invoice_line_tree_from_product" model="ir.ui.view"> |
10 | - <field name="name">account.invoice.line.from.product.tree</field> |
11 | - <field name="model">account.invoice.line</field> |
12 | - <field name="type">tree</field> |
13 | - <field name="priority">20</field> |
14 | - <field name="arch" type="xml"> |
15 | - <tree string="Invoice Line"> |
16 | - <field name="invoice_type"/> |
17 | - <field name="partner_id"/> |
18 | - <field name="invoice_user_id"/> |
19 | - <field name="invoice_id"/> |
20 | - <field name="invoice_date"/> |
21 | - <field name="name" invisible="1"/> |
22 | - <field name="product_id"/> |
23 | - <field name="account_id" invisible="1"/> |
24 | - <field name="quantity"/> |
25 | - <field name="uos_id"/> |
26 | - <field name="price_unit" invisible="1"/> |
27 | - <field name="discount" invisible="1"/> |
28 | - <field name="price_subtotal" invisible="1"/> |
29 | - <field name="subtotal_cost_price" invisible="1"/> |
30 | - <field name="company_id" invisible="1"/> |
31 | - <field name="subtotal_company"/> |
32 | - <field name="subtotal_cost_price_company"/> |
33 | - <field name="margin_absolute"/> |
34 | - <field name="margin_relative" invisible="context.get('group_by',False)"/> |
35 | - </tree> |
36 | - </field> |
37 | - </record> |
38 | - |
39 | - |
40 | - <record id="view_account_invoice_line_filter" model="ir.ui.view"> |
41 | - <field name="name">account.invoice.line.select</field> |
42 | - <field name="model">account.invoice.line</field> |
43 | - <field name="type">search</field> |
44 | - <field name="arch" type="xml"> |
45 | - <search string="Search Invoice Line"> |
46 | - <group> |
47 | - <filter icon="terp-go-year" string="Year" |
48 | - name="year" |
49 | - domain="[('invoice_date','<=', time.strftime('%%Y-%%m-%%d')),('invoice_date','>=',time.strftime('%%Y-01-01'))]" |
50 | - help="year"/> |
51 | - <separator orientation="vertical"/> |
52 | - <filter icon="terp-go-month" string="Month" |
53 | - name="month" |
54 | - domain="[('invoice_date','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('invoice_date','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]" |
55 | - help="current month"/> |
56 | - <filter icon="terp-go-month" string="Month-1" |
57 | - domain="[('invoice_date','<=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('invoice_date','>=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]" |
58 | - help="last month"/> |
59 | - <separator orientation="vertical"/> |
60 | - <field name="product_id"/> |
61 | - <field name="invoice_type"/> |
62 | - <field name="partner_id"/> |
63 | - <field name="invoice_user_id"/> |
64 | - <field name="invoice_date"/> |
65 | - <field name="account_id"/> |
66 | - <field name="company_id"/> |
67 | - </group> |
68 | - <newline/> |
69 | - <group expand="1" string="Group By..."> |
70 | - <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> |
71 | - <filter string="Salesman" name='user' icon="terp-personal" context="{'group_by':'invoice_user_id'}"/> |
72 | - <separator orientation="vertical"/> |
73 | - <filter string="Account" icon="terp-folder-orange" domain="[]" context="{'group_by':'account_id'}"/> |
74 | - <filter string="Invoice" icon="terp-folder-orange" domain="[]" context="{'group_by':'invoice_id'}"/> |
75 | - <separator orientation="vertical"/> |
76 | - <filter string="Invoice Type" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'invoice_type'}"/> |
77 | - <filter name="product" string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/> |
78 | - </group> |
79 | - </search> |
80 | - </field> |
81 | - </record> |
82 | + |
83 | + <record id="view_invoice_line_tree_from_product" model="ir.ui.view"> |
84 | + <field name="name">account.invoice.line.from.product.tree</field> |
85 | + <field name="model">account.invoice.line</field> |
86 | + <field name="type">tree</field> |
87 | + <field name="priority">20</field> |
88 | + <field name="arch" type="xml"> |
89 | + <tree string="Invoice Line"> |
90 | + <field name="invoice_type"/> |
91 | + <field name="partner_id"/> |
92 | + <field name="invoice_user_id"/> |
93 | + <field name="invoice_id"/> |
94 | + <field name="invoice_date"/> |
95 | + <field name="name" invisible="1"/> |
96 | + <field name="product_id"/> |
97 | + <field name="account_id" invisible="1"/> |
98 | + <field name="quantity"/> |
99 | + <field name="uos_id"/> |
100 | + <field name="price_unit" invisible="1"/> |
101 | + <field name="discount" invisible="1"/> |
102 | + <field name="price_subtotal" invisible="1"/> |
103 | + <field name="subtotal_cost_price" invisible="1"/> |
104 | + <field name="company_id" invisible="1"/> |
105 | + <field name="subtotal_company"/> |
106 | + <field name="subtotal_cost_price_company"/> |
107 | + <field name="margin_absolute"/> |
108 | + <field name="margin_relative" invisible="context.get('group_by',False)"/> |
109 | + </tree> |
110 | + </field> |
111 | + </record> |
112 | + |
113 | + |
114 | + <record id="view_account_invoice_line_filter" model="ir.ui.view"> |
115 | + <field name="name">account.invoice.line.select</field> |
116 | + <field name="model">account.invoice.line</field> |
117 | + <field name="type">search</field> |
118 | + <field name="arch" type="xml"> |
119 | + <search string="Search Invoice Line"> |
120 | + <group> |
121 | + <filter icon="terp-go-year" string="Year" |
122 | + name="year" |
123 | + domain="[('invoice_date','<=', time.strftime('%%Y-%%m-%%d')),('invoice_date','>=',time.strftime('%%Y-01-01'))]" |
124 | + help="year"/> |
125 | + <separator orientation="vertical"/> |
126 | + <filter icon="terp-go-month" string="Month" |
127 | + name="month" |
128 | + domain="[('invoice_date','<=',(datetime.date.today()+relativedelta(day=31)).strftime('%%Y-%%m-%%d')),('invoice_date','>=',(datetime.date.today()-relativedelta(day=1)).strftime('%%Y-%%m-%%d'))]" |
129 | + help="current month"/> |
130 | + <filter icon="terp-go-month" string="Month-1" |
131 | + domain="[('invoice_date','<=', (datetime.date.today() - relativedelta(day=31, months=1)).strftime('%%Y-%%m-%%d')),('invoice_date','>=',(datetime.date.today() - relativedelta(day=1,months=1)).strftime('%%Y-%%m-%%d'))]" |
132 | + help="last month"/> |
133 | + <separator orientation="vertical"/> |
134 | + <field name="product_id"/> |
135 | + <field name="invoice_type"/> |
136 | + <field name="partner_id"/> |
137 | + <field name="invoice_user_id"/> |
138 | + <field name="invoice_date"/> |
139 | + <field name="account_id"/> |
140 | + <field name="company_id"/> |
141 | + </group> |
142 | + <newline/> |
143 | + <group expand="1" string="Group By..."> |
144 | + <filter string="Partner" icon="terp-partner" domain="[]" context="{'group_by':'partner_id'}"/> |
145 | + <filter string="Salesman" name='user' icon="terp-personal" context="{'group_by':'invoice_user_id'}"/> |
146 | + <separator orientation="vertical"/> |
147 | + <filter string="Account" icon="terp-folder-orange" domain="[]" context="{'group_by':'account_id'}"/> |
148 | + <filter string="Invoice" icon="terp-folder-orange" domain="[]" context="{'group_by':'invoice_id'}"/> |
149 | + <separator orientation="vertical"/> |
150 | + <filter string="Invoice Type" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'invoice_type'}"/> |
151 | + <filter name="product" string="Product" icon="terp-accessories-archiver" context="{'group_by':'product_id'}"/> |
152 | + </group> |
153 | + </search> |
154 | + </field> |
155 | + </record> |
156 | |
157 | </data> |
158 | </openerp> |
159 | - |
160 | |
161 | === modified file 'product_historical_margin/invoice.py' |
162 | --- product_historical_margin/invoice.py 2012-11-14 15:53:00 +0000 |
163 | +++ product_historical_margin/invoice.py 2013-11-14 15:32:34 +0000 |
164 | @@ -26,10 +26,11 @@ |
165 | class account_invoice(Model): |
166 | _inherit = 'account.invoice' |
167 | |
168 | - def _refund_cleanup_lines(self, cr, uid, lines): |
169 | + def _refund_cleanup_lines(self, cr, uid, lines, context=None): |
170 | for line in lines: |
171 | - del line['invoice_user_id'] |
172 | - return super(account_invoice, self)._refund_cleanup_lines(cr, uid, lines) |
173 | + line.invoice_user_id = False |
174 | + return super(account_invoice, self)._refund_cleanup_lines(cr, uid, |
175 | + lines, context=context) |
176 | |
177 | |
178 | class account_invoice_line(Model): |
179 | |
180 | === modified file 'product_historical_margin/product_view.xml' |
181 | --- product_historical_margin/product_view.xml 2012-11-14 15:53:00 +0000 |
182 | +++ product_historical_margin/product_view.xml 2013-11-14 15:32:34 +0000 |
183 | @@ -9,8 +9,8 @@ |
184 | <field name="type">form</field> |
185 | <field name="arch" type="xml"> |
186 | <field name="standard_margin_rate" position="after"> |
187 | - <field name="margin_absolute" /> |
188 | - <field name="margin_relative" /> |
189 | + <field name="margin_absolute" /> |
190 | + <field name="margin_relative" /> |
191 | </field> |
192 | </field> |
193 | </record> |
194 | |
195 | === modified file 'product_historical_margin/wizard/historical_margin_view.xml' |
196 | --- product_historical_margin/wizard/historical_margin_view.xml 2012-07-12 13:56:17 +0000 |
197 | +++ product_historical_margin/wizard/historical_margin_view.xml 2013-11-14 15:32:34 +0000 |
198 | @@ -1,43 +1,42 @@ |
199 | <?xml version="1.0" encoding="utf-8"?> |
200 | - |
201 | <openerp> |
202 | - <data> |
203 | - <record id="view_historical_margin" model="ir.ui.view"> |
204 | - <field name="name">historical.margin.form</field> |
205 | - <field name="model">historical.margin</field> |
206 | - <field name="type">form</field> |
207 | - <field name="arch" type="xml"> |
208 | - <form string="Historical Margin Properties"> |
209 | - <group colspan="4"> |
210 | - <field name="from_date" /> |
211 | - <field name="to_date"/> |
212 | - <field name="product_ids" invisible="1"/> |
213 | - </group> |
214 | - <separator string="" colspan="4"/> |
215 | - <group colspan="4" col="6"> |
216 | - <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
217 | - <button icon="terp-gtk-go-back-rtl" string="Compute margins" name="action_open_window" type="object"/> |
218 | - </group> |
219 | - </form> |
220 | - </field> |
221 | - </record> |
222 | - |
223 | - <record id="action_product_margin_view" model="ir.actions.act_window"> |
224 | - <field name="name">Product Historical Margin</field> |
225 | - <field name="res_model">historical.margin</field> |
226 | - <field name="view_type">form</field> |
227 | - <field name="view_mode">tree,form</field> |
228 | - <field name="view_id" ref="view_historical_margin"/> |
229 | - <field name="target">new</field> |
230 | - </record> |
231 | - |
232 | - |
233 | - <menuitem icon="STOCK_INDENT" action="action_product_margin_view" |
234 | - id="menu_action_product_margin_tree" |
235 | - parent="account.menu_finance_statistic_report_statement" /> |
236 | - |
237 | - |
238 | - <!-- Remove it for right management <act_window name="Product Historical Margins" |
239 | + <data> |
240 | + <record id="view_historical_margin" model="ir.ui.view"> |
241 | + <field name="name">historical.margin.form</field> |
242 | + <field name="model">historical.margin</field> |
243 | + <field name="type">form</field> |
244 | + <field name="arch" type="xml"> |
245 | + <form string="Historical Margin Properties"> |
246 | + <group colspan="4"> |
247 | + <field name="from_date" /> |
248 | + <field name="to_date"/> |
249 | + <field name="product_ids" invisible="1"/> |
250 | + </group> |
251 | + <separator string="" colspan="4"/> |
252 | + <group colspan="4" col="6"> |
253 | + <button icon="gtk-cancel" special="cancel" string="Cancel"/> |
254 | + <button icon="terp-gtk-go-back-rtl" string="Compute margins" name="action_open_window" type="object"/> |
255 | + </group> |
256 | + </form> |
257 | + </field> |
258 | + </record> |
259 | + |
260 | + <record id="action_product_margin_view" model="ir.actions.act_window"> |
261 | + <field name="name">Product Historical Margin</field> |
262 | + <field name="res_model">historical.margin</field> |
263 | + <field name="view_type">form</field> |
264 | + <field name="view_mode">tree,form</field> |
265 | + <field name="view_id" ref="view_historical_margin"/> |
266 | + <field name="target">new</field> |
267 | + </record> |
268 | + |
269 | + |
270 | + <menuitem icon="STOCK_INDENT" action="action_product_margin_view" |
271 | + id="menu_action_product_margin_tree" |
272 | + parent="account.menu_finance_statistic_report_statement" /> |
273 | + |
274 | + |
275 | + <!-- Remove it for right management <act_window name="Product Historical Margins" |
276 | res_model="historical.margin" |
277 | src_model="product.product" |
278 | view_mode="form" |
279 | @@ -46,5 +45,5 @@ |
280 | id="historical_margin_act_window"/> --> |
281 | |
282 | |
283 | - </data> |
284 | + </data> |
285 | </openerp> |
LGTM, Thanks !