Merge lp:~bas-solutions/margin-analysis/6.1-product_cost_incl_costs into lp:~margin-analysis-core-editors/margin-analysis/6.1

Proposed by Erwin van der Ploeg (BAS Solutions)
Status: Merged
Merged at revision: 45
Proposed branch: lp:~bas-solutions/margin-analysis/6.1-product_cost_incl_costs
Merge into: lp:~margin-analysis-core-editors/margin-analysis/6.1
Diff against target: 448 lines (+395/-0)
10 files modified
product_cost_incl_costs_with_bom/__init__.py (+24/-0)
product_cost_incl_costs_with_bom/__openerp__.py (+41/-0)
product_cost_incl_costs_with_bom/i18n/nl.po (+41/-0)
product_cost_incl_costs_with_bom/product.py (+51/-0)
product_cost_incl_costs_with_bom/product_view.xml (+54/-0)
product_cost_incl_costs_without_bom/__init__.py (+23/-0)
product_cost_incl_costs_without_bom/__openerp__.py (+39/-0)
product_cost_incl_costs_without_bom/i18n/nl.po (+41/-0)
product_cost_incl_costs_without_bom/product.py (+27/-0)
product_cost_incl_costs_without_bom/product_view.xml (+54/-0)
To merge this branch: bzr merge lp:~bas-solutions/margin-analysis/6.1-product_cost_incl_costs
Reviewer Review Type Date Requested Status
Alexandre Fayolle - camptocamp code review, no test Approve
Guewen Baconnier @ Camptocamp code review, no test Approve
Review via email: mp+141486@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hello,

Do you have to choose between product_cost_incl_costs_with_bom and product_cost_incl_costs_without_bom?
What happens if you install both?

review: Needs Information
Revision history for this message
Erwin van der Ploeg (BAS Solutions) (erwin-bassolutions-deactivatedaccount) wrote :

Haven't tried to install both. Best is to choose. Then you can deside if the extra costs (exaple, delivery costs of supplier) will be added to the product, on top of the BoM calculation, or just a cost, without a BoM (We often don't install this module, due to the extra complexity)

Erwin

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

9+# Copyright 2012 Camptocamp SA
Why is there a copyright attribution to Camptocamp ?

26+# -*- coding: utf-8 -*-
No meaning here

65
'if the is a BoM'?
s/calcyulated/calculated

171,389: 'method=True' is now useless

173: no spaces around the = in method keyword arguments

179,395 +product_product()
The instanciation of the models is now useless

235,451: <!-- FIXME groups setting! -->
groups to fix or comment to remove?

369
from openerp.tools.translate import _

378,379 couldn't this debug logging be removed?

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

175: s/it take also/it also takes/
     s/all standard price/all standard prices/

please use a consistent casing for "BoM" throughout the strings in the code.

164: use +=

217: use '!=' rather than "&lt;&gt;'

294: syntax error. You probably never were able to install this module because of this one.

386: the field should be named "fixed_cost_price" and not "fix_cost_price" (does not mean the same thing in English)

review: Needs Fixing (code review, no test)
46. By Erwin van der Ploeg (BAS Solutions)

Review changes

Revision history for this message
Erwin van der Ploeg (BAS Solutions) (erwin-bassolutions-deactivatedaccount) wrote :

Think I have all the review comments. Thanks

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

I just noticed one more thing:

387 + help=_("The cost price is the standard price unless you install the product_cost_incl_bom module."))

The help message should not be translated using _(). They are automatically translated.

(it also means that you can remove the import of _)

review: Needs Fixing
47. By Erwin van der Ploeg (BAS Solutions)

Delete translation using _()

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks, LGTM

review: Approve (code review, no test)
Revision history for this message
Alexandre Fayolle - camptocamp (alexandre-fayolle-c2c) :
review: Approve (code review, no test)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'product_cost_incl_costs_with_bom'
2=== added file 'product_cost_incl_costs_with_bom/__init__.py'
3--- product_cost_incl_costs_with_bom/__init__.py 1970-01-01 00:00:00 +0000
4+++ product_cost_incl_costs_with_bom/__init__.py 2013-02-04 08:46:31 +0000
5@@ -0,0 +1,24 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Copyright 2012 Camptocamp SA
10+# Copyright 2012 Endian Solutions BV
11+#
12+# This program is free software: you can redistribute it and/or modify
13+# it under the terms of the GNU Affero General Public License as
14+# published by the Free Software Foundation, either version 3 of the
15+# License, or (at your option) any later version.
16+#
17+# This program is distributed in the hope that it will be useful,
18+# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+# GNU Affero General Public License for more details.
21+#
22+# You should have received a copy of the GNU Affero General Public License
23+# along with this program. If not, see <http://www.gnu.org/licenses/>.
24+#
25+##############################################################################
26+
27+import product
28+
29+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
30
31=== added file 'product_cost_incl_costs_with_bom/__openerp__.py'
32--- product_cost_incl_costs_with_bom/__openerp__.py 1970-01-01 00:00:00 +0000
33+++ product_cost_incl_costs_with_bom/__openerp__.py 2013-02-04 08:46:31 +0000
34@@ -0,0 +1,41 @@
35+# -*- coding: utf-8 -*-
36+##############################################################################
37+#
38+# Copyright 2012 Camptocamp SA
39+# Copyright 2012 Endian Solutions BV
40+#
41+# This program is free software: you can redistribute it and/or modify
42+# it under the terms of the GNU Affero General Public License as
43+# published by the Free Software Foundation, either version 3 of the
44+# License, or (at your option) any later version.
45+#
46+# This program is distributed in the hope that it will be useful,
47+# but WITHOUT ANY WARRANTY; without even the implied warranty of
48+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49+# GNU Affero General Public License for more details.
50+#
51+# You should have received a copy of the GNU Affero General Public License
52+# along with this program. If not, see <http://www.gnu.org/licenses/>.
53+#
54+##############################################################################
55+{'name' : 'Product Cost field',
56+ 'version' : '0.1',
57+ 'author' : 'Grishma Shukla',
58+ 'maintainer': 'Endian Solutions',
59+ 'category': 'Products',
60+ 'complexity': "normal",
61+ 'depends' : ['product_cost_incl_bom',
62+ ],
63+ 'description': """
64+ This module adds an Fixed cost field to the product form. So you can calculate a costprice with added costs.
65+ This module depends on the module product_cost_incl_bom. If the is a BoM, the added costs are added to the calculated cost price of the BoM.
66+ """,
67+ 'website': 'www.endiansolutions.nl',
68+ 'init_xml': [],
69+ 'update_xml': ['product_view.xml'],
70+ 'demo_xml': [],
71+ 'tests': [],
72+ 'installable': True,
73+ 'license': 'AGPL-3',
74+ 'application': False
75+ }
76
77=== added directory 'product_cost_incl_costs_with_bom/i18n'
78=== added file 'product_cost_incl_costs_with_bom/i18n/nl.po'
79--- product_cost_incl_costs_with_bom/i18n/nl.po 1970-01-01 00:00:00 +0000
80+++ product_cost_incl_costs_with_bom/i18n/nl.po 2013-02-04 08:46:31 +0000
81@@ -0,0 +1,41 @@
82+# Translation of OpenERP Server.
83+# This file contains the translation of the following modules:
84+# * product_cost_incl_costs
85+#
86+msgid ""
87+msgstr ""
88+"Project-Id-Version: OpenERP Server 6.1\n"
89+"Report-Msgid-Bugs-To: \n"
90+"POT-Creation-Date: 2012-12-23 12:21+0000\n"
91+"PO-Revision-Date: 2012-12-23 13:21+0100\n"
92+"Last-Translator: Erwin van der Ploeg | Endian Solutions "
93+"<erwin@endiansolutions.nl>\n"
94+"Language-Team: \n"
95+"MIME-Version: 1.0\n"
96+"Content-Type: text/plain; charset=UTF-8\n"
97+"Content-Transfer-Encoding: 8bit\n"
98+"Plural-Forms: \n"
99+"X-Generator: Poedit 1.5.4\n"
100+
101+#. module: product_cost_incl_costs
102+#: model:ir.model,name:product_cost_incl_costs.model_product_product
103+msgid "Product"
104+msgstr "Product"
105+
106+#. module: product_cost_incl_costs
107+#: constraint:product.product:0
108+msgid "Error: Invalid ean code"
109+msgstr "Fout: ongeldige ean code"
110+
111+#. module: product_cost_incl_costs
112+#: field:product.product,fix_cost_price:0
113+msgid "Fix Cost Price"
114+msgstr "Vaste kosten"
115+
116+#. module: product_get_cost_field
117+#: help:product.product,cost_price:0
118+msgid ""
119+"The cost price is the standard price or, if the product has a bom, the sum "
120+"of all standard price of its components. it take also care of the bom "
121+"costing like cost per cylce."
122+msgstr "Dit is de kostrpijs inclusief eventuele kosten."
123
124=== added file 'product_cost_incl_costs_with_bom/product.py'
125--- product_cost_incl_costs_with_bom/product.py 1970-01-01 00:00:00 +0000
126+++ product_cost_incl_costs_with_bom/product.py 2013-02-04 08:46:31 +0000
127@@ -0,0 +1,51 @@
128+# -*- coding: utf-8 -*-
129+##############################################################################
130+#
131+# Copyright 2012 Camptocamp SA
132+# Copyright 2012 Endian Solutions BV
133+#
134+# This program is free software: you can redistribute it and/or modify
135+# it under the terms of the GNU Affero General Public License as
136+# published by the Free Software Foundation, either version 3 of the
137+# License, or (at your option) any later version.
138+#
139+# This program is distributed in the hope that it will be useful,
140+# but WITHOUT ANY WARRANTY; without even the implied warranty of
141+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142+# GNU Affero General Public License for more details.
143+#
144+# You should have received a copy of the GNU Affero General Public License
145+# along with this program. If not, see <http://www.gnu.org/licenses/>.
146+#
147+##############################################################################
148+
149+from openerp.osv.orm import Model
150+from openerp.osv import fields
151+import decimal_precision as dp
152+
153+class product_product(Model):
154+ _inherit = 'product.product'
155+
156+ def _cost_price(self, cr, uid, ids, field_name, arg, context=None):
157+ if context is None:
158+ context = {}
159+ product_uom = context.get('product_uom')
160+ bom_properties = context.get('properties')
161+ res = self._compute_purchase_price(cr, uid, ids, product_uom,
162+ bom_properties)
163+ for self_obj in self.browse(cr, uid, ids, context=context):
164+ res[self_obj.id] = res[self_obj.id] + self_obj.fixed_cost_price
165+ return res
166+
167+ _columns = {
168+ 'fixed_cost_price': fields.float(
169+ 'Fixed Cost Price', digits_compute = dp.get_precision('Sale Price')),
170+ 'cost_price': fields.function(_cost_price,
171+ string='Cost Price (incl. BoM)',
172+ digits_compute=dp.get_precision('Sale Price'),
173+ help="The cost price is the standard price or, if the product has a BoM, "
174+ "the sum of all standard prices of its components. It also takes care of the "
175+ "BoM costing like cost per cylce.")
176+ }
177+
178+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
179
180=== added file 'product_cost_incl_costs_with_bom/product_view.xml'
181--- product_cost_incl_costs_with_bom/product_view.xml 1970-01-01 00:00:00 +0000
182+++ product_cost_incl_costs_with_bom/product_view.xml 2013-02-04 08:46:31 +0000
183@@ -0,0 +1,54 @@
184+<?xml version="1.0" encoding="utf-8"?>
185+<openerp>
186+ <data>
187+ <record model="ir.ui.view" id="product_cost_incl_costs_form">
188+ <field name="name">product.product_cost_incl_costs.view.form</field>
189+ <field name="type">form</field>
190+ <field name="model">product.product</field>
191+ <field name="priority" eval="800"/>
192+ <field name="inherit_id" ref="product.product_normal_form_view" />
193+ <field name="arch" type="xml">
194+ <field name="cost_price" position="replace">
195+ </field>
196+ <field name="list_price" position="replace"/>
197+ <label string="Cost Price :" align="1.0" position="replace"/>
198+ <field name="standard_price"
199+ attrs="{'readonly':[('cost_method','=','average')]}"
200+ groups="base.group_extended"
201+ position="replace"/>
202+ <button name="%(stock.action_view_change_standard_price)d" string="Update"
203+ type="action" icon="gtk-execute"
204+ attrs="{'invisible':[('cost_method','&lt;&gt;','average')]}"
205+ position="replace"/>
206+ <field name="cost_method" groups="base.group_extended" position="replace">
207+ <group col="2" colspan="2">
208+ <field name="list_price"/>
209+ <field name="cost_method" groups="base.group_extended" />
210+ <label string="Cost Price :" align="1.0"/>
211+ <group col="2" colspan="1">
212+ <field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}" nolabel="1"/>
213+ <button name="%(stock.action_view_change_standard_price)d" string="Update"
214+ type="action" icon="gtk-execute" attrs="{'invisible':[('cost_method','!=','average')]}"/>
215+ </group>
216+ <field name="fixed_cost_price" />
217+ <field name="cost_price"/>
218+ </group>
219+ </field>
220+
221+ </field>
222+ </record>
223+
224+ <record model="ir.ui.view" id="product_cost_incl_costs_tree">
225+ <field name="name">product.product_cost_incl_costs.view.tree</field>
226+ <field name="type">tree</field>
227+ <field name="model">product.product</field>
228+ <field name="priority" eval="80"/>
229+ <field name="inherit_id" ref="product.product_product_tree_view" />
230+ <field name="arch" type="xml">
231+ <field name="cost_price" position="before">
232+ <field name="fixed_cost_price"/>
233+ </field>
234+ </field>
235+ </record>
236+ </data>
237+</openerp>
238
239=== added directory 'product_cost_incl_costs_without_bom'
240=== added file 'product_cost_incl_costs_without_bom/__init__.py'
241--- product_cost_incl_costs_without_bom/__init__.py 1970-01-01 00:00:00 +0000
242+++ product_cost_incl_costs_without_bom/__init__.py 2013-02-04 08:46:31 +0000
243@@ -0,0 +1,23 @@
244+# -*- coding: utf-8 -*-
245+##############################################################################
246+#
247+# Copyright 2012 Camptocamp SA
248+# Copyright 2012 Endian Solutions BV
249+#
250+# This program is free software: you can redistribute it and/or modify
251+# it under the terms of the GNU Affero General Public License as
252+# published by the Free Software Foundation, either version 3 of the
253+# License, or (at your option) any later version.
254+#
255+# This program is distributed in the hope that it will be useful,
256+# but WITHOUT ANY WARRANTY; without even the implied warranty of
257+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
258+# GNU Affero General Public License for more details.
259+#
260+# You should have received a copy of the GNU Affero General Public License
261+# along with this program. If not, see <http://www.gnu.org/licenses/>.
262+#
263+##############################################################################
264+import product
265+
266+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
267
268=== added file 'product_cost_incl_costs_without_bom/__openerp__.py'
269--- product_cost_incl_costs_without_bom/__openerp__.py 1970-01-01 00:00:00 +0000
270+++ product_cost_incl_costs_without_bom/__openerp__.py 2013-02-04 08:46:31 +0000
271@@ -0,0 +1,39 @@
272+# -*- coding: utf-8 -*-
273+##############################################################################
274+#
275+# Copyright 2012 Camptocamp SA
276+# Copyright 2012 Endian Solutions BV
277+#
278+# This program is free software: you can redistribute it and/or modify
279+# it under the terms of the GNU Affero General Public License as
280+# published by the Free Software Foundation, either version 3 of the
281+# License, or (at your option) any later version.
282+#
283+# This program is distributed in the hope that it will be useful,
284+# but WITHOUT ANY WARRANTY; without even the implied warranty of
285+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
286+# GNU Affero General Public License for more details.
287+#
288+# You should have received a copy of the GNU Affero General Public License
289+# along with this program. If not, see <http://www.gnu.org/licenses/>.
290+#
291+##############################################################################
292+{'name' : 'Product Cost field',
293+ 'version' : '0.1',
294+ 'author' : 'Grishma Shukla',
295+ 'maintainer': 'Endian Solutions',
296+ 'category': 'Products',
297+ 'complexity': "normal",
298+ 'depends' : ['product_get_cost_field',
299+ ],
300+ 'description': """
301+ This module adds an Fixed cost field to the product form. So you can calculate a costprice with added costs, without the use of a BoM.
302+ """,
303+ 'website': 'www.endiansolutions.nl',
304+ 'init_xml': [],
305+ 'update_xml': ['product_view.xml'],
306+ 'demo_xml': [],
307+ 'tests': [],
308+ 'installable': True,
309+ 'application': False
310+ }
311
312=== added directory 'product_cost_incl_costs_without_bom/i18n'
313=== added file 'product_cost_incl_costs_without_bom/i18n/nl.po'
314--- product_cost_incl_costs_without_bom/i18n/nl.po 1970-01-01 00:00:00 +0000
315+++ product_cost_incl_costs_without_bom/i18n/nl.po 2013-02-04 08:46:31 +0000
316@@ -0,0 +1,41 @@
317+# Translation of OpenERP Server.
318+# This file contains the translation of the following modules:
319+# * product_cost_incl_costs
320+#
321+msgid ""
322+msgstr ""
323+"Project-Id-Version: OpenERP Server 6.1\n"
324+"Report-Msgid-Bugs-To: \n"
325+"POT-Creation-Date: 2012-12-23 12:21+0000\n"
326+"PO-Revision-Date: 2012-12-23 14:20+0100\n"
327+"Last-Translator: Erwin van der Ploeg | Endian Solutions "
328+"<erwin@endiansolutions.nl>\n"
329+"Language-Team: \n"
330+"MIME-Version: 1.0\n"
331+"Content-Type: text/plain; charset=UTF-8\n"
332+"Content-Transfer-Encoding: 8bit\n"
333+"Plural-Forms: \n"
334+"X-Generator: Poedit 1.5.4\n"
335+
336+#. module: product_cost_incl_costs
337+#: model:ir.model,name:product_cost_incl_costs.model_product_product
338+msgid "Product"
339+msgstr "Product"
340+
341+#. module: product_cost_incl_costs
342+#: constraint:product.product:0
343+msgid "Error: Invalid ean code"
344+msgstr "Fout: ongeldige ean code"
345+
346+#. module: product_cost_incl_costs
347+#: field:product.product,fix_cost_price:0
348+msgid "Fix Cost Price"
349+msgstr "Vaste kosten"
350+
351+#. module: product_get_cost_field
352+#: help:product.product,cost_price:0
353+msgid ""
354+"The cost price is the standard price or, if the product has a bom, the sum "
355+"of all standard price of its components. it take also care of the bom "
356+"costing like cost per cylce."
357+msgstr "Dit is de kostprijs inclusief eventuele kosten."
358
359=== added file 'product_cost_incl_costs_without_bom/product.py'
360--- product_cost_incl_costs_without_bom/product.py 1970-01-01 00:00:00 +0000
361+++ product_cost_incl_costs_without_bom/product.py 2013-02-04 08:46:31 +0000
362@@ -0,0 +1,27 @@
363+# -*- coding: utf-8 -*-
364+from openerp.osv.orm import Model
365+from openerp.osv import fields
366+import decimal_precision as dp
367+import logging
368+
369+class product_product(Model):
370+ _inherit = 'product.product'
371+
372+ def _cost_price(self, cr, uid, ids, field_name, arg, context=None):
373+ if context is None:
374+ context = {}
375+ res = {}
376+ for product in self.browse(cr, uid, ids):
377+ res[product.id] = product.standard_price + product.fixed_cost_price
378+ return res
379+
380+ _columns = {
381+ 'fixed_cost_price': fields.float(
382+ 'Fixed Cost Price', digits_compute = dp.get_precision('Sale Price')),
383+ 'cost_price': fields.function(_cost_price,
384+ string='Cost Price',
385+ digits_compute=dp.get_precision('Sale Price'),
386+ help="The cost price is the standard price unless you install the product_cost_incl_bom module.")
387+ }
388+
389+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
390
391=== added file 'product_cost_incl_costs_without_bom/product_view.xml'
392--- product_cost_incl_costs_without_bom/product_view.xml 1970-01-01 00:00:00 +0000
393+++ product_cost_incl_costs_without_bom/product_view.xml 2013-02-04 08:46:31 +0000
394@@ -0,0 +1,54 @@
395+<?xml version="1.0" encoding="utf-8"?>
396+<openerp>
397+ <data>
398+ <record model="ir.ui.view" id="product_cost_incl_costs_form">
399+ <field name="name">product.product_cost_incl_costs.view.form</field>
400+ <field name="type">form</field>
401+ <field name="model">product.product</field>
402+ <field name="priority" eval="800"/>
403+ <field name="inherit_id" ref="product.product_normal_form_view" />
404+ <field name="arch" type="xml">
405+ <field name="cost_price" position="replace">
406+ </field>
407+ <field name="list_price" position="replace"/>
408+ <label string="Cost Price :" align="1.0" position="replace"/>
409+ <field name="standard_price"
410+ attrs="{'readonly':[('cost_method','=','average')]}"
411+ groups="base.group_extended"
412+ position="replace"/>
413+ <button name="%(stock.action_view_change_standard_price)d" string="Update"
414+ type="action" icon="gtk-execute"
415+ attrs="{'invisible':[('cost_method','&lt;&gt;','average')]}"
416+ position="replace"/>
417+ <field name="cost_method" groups="base.group_extended" position="replace">
418+ <group col="2" colspan="2">
419+ <field name="list_price"/>
420+ <field name="cost_method" groups="base.group_extended" />
421+ <label string="Cost Price :" align="1.0"/>
422+ <group col="2" colspan="1">
423+ <field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}" nolabel="1"/>
424+ <button name="%(stock.action_view_change_standard_price)d" string="Update"
425+ type="action" icon="gtk-execute" attrs="{'invisible':[('cost_method','&lt;&gt;','average')]}"/>
426+ </group>
427+ <field name="fixed_cost_price" />
428+ <field name="cost_price"/>
429+ </group>
430+ </field>
431+
432+ </field>
433+ </record>
434+
435+ <record model="ir.ui.view" id="product_cost_incl_costs_tree">
436+ <field name="name">product.product_cost_incl_costs.view.tree</field>
437+ <field name="type">tree</field>
438+ <field name="model">product.product</field>
439+ <field name="priority" eval="80"/>
440+ <field name="inherit_id" ref="product.product_product_tree_view" />
441+ <field name="arch" type="xml">
442+ <field name="cost_price" position="before">
443+ <field name="fixed_cost_price"/><!-- FIXME groups setting! -->
444+ </field>
445+ </field>
446+ </record>
447+ </data>
448+</openerp>

Subscribers

People subscribed via source and target branches