Merge lp:~agilebg/sale-wkfl/adding_sale_line_quantity_properties_based_7 into lp:~sale-core-editors/sale-wkfl/7.0

Proposed by Alex Comba - Agile BG
Status: Work in progress
Proposed branch: lp:~agilebg/sale-wkfl/adding_sale_line_quantity_properties_based_7
Merge into: lp:~sale-core-editors/sale-wkfl/7.0
Diff against target: 655 lines (+607/-0)
9 files modified
sale_line_quantity_properties_based/__init__.py (+22/-0)
sale_line_quantity_properties_based/__openerp__.py (+107/-0)
sale_line_quantity_properties_based/i18n/it.po (+100/-0)
sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot (+85/-0)
sale_line_quantity_properties_based/mrp_view.xml (+29/-0)
sale_line_quantity_properties_based/sale.py (+150/-0)
sale_line_quantity_properties_based/sale_view.xml (+43/-0)
sale_line_quantity_properties_based/security/ir.model.access.csv (+3/-0)
sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml (+68/-0)
To merge this branch: bzr merge lp:~agilebg/sale-wkfl/adding_sale_line_quantity_properties_based_7
Reviewer Review Type Date Requested Status
Lorenzo Battistini (community) Disapprove
Sale Core Editors Pending
Review via email: mp+223538@code.launchpad.net

Commit message

 [ADD] module 'sale_line_quantity_properties_based'

Description of the change

This branch adds the module 'sale_line_quantity_properties_based' which allows the calculation of the product quantity on the basis of a formula that considers the properties specified by the user on the sale order line and on the quantity (UoS).

The module description contains an example to explain how this module works.

To post a comment you must log in.
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Thanks Alex, just 1 diff remark

review: Approve
75. By Alex Comba - Agile BG

[REM] trailing whitespaces

76. By Alex Comba - Agile BG

[FIX] typo in description

77. By Alex Comba - Agile BG

[IMP] module description

Revision history for this message
Lorenzo Battistini (elbati) wrote :

Setting WIP because this will need refactoring after https://github.com/eLBati/sale-workflow/tree/7.0_add_price_propreties_based

review: Abstain
Revision history for this message
Lorenzo Battistini (elbati) wrote :
review: Disapprove

Unmerged revisions

77. By Alex Comba - Agile BG

[IMP] module description

76. By Alex Comba - Agile BG

[FIX] typo in description

75. By Alex Comba - Agile BG

[REM] trailing whitespaces

74. By Lorenzo Battistini

[IMP] product_id_change comment

73. By Lorenzo Battistini

[IMP] properties creation

72. By Alex Comba - Agile BG

[FIX] pot file

71. By Alex Comba - Agile BG

[IMP] it translation file

70. By Alex Comba - Agile BG

[FIX] module description

69. By Alex Comba - Agile BG

[IMP] module description

68. By Alex Comba - Agile BG

[ADD] me as contributor

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'sale_line_quantity_properties_based'
2=== added file 'sale_line_quantity_properties_based/__init__.py'
3--- sale_line_quantity_properties_based/__init__.py 1970-01-01 00:00:00 +0000
4+++ sale_line_quantity_properties_based/__init__.py 2014-07-04 07:24:04 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+##############################################################################
8+#
9+# Author: Alex Comba <alex.comba@agilebg.com>
10+# Copyright (C) 2014 Agile Business Group sagl
11+# (<http://www.agilebg.com>)
12+#
13+# This program is free software: you can redistribute it and/or modify
14+# it under the terms of the GNU Affero General Public License as published
15+# by the Free Software Foundation, either version 3 of the License, or
16+# (at your option) any later version.
17+#
18+# This program is distributed in the hope that it will be useful,
19+# but WITHOUT ANY WARRANTY; without even the implied warranty of
20+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21+# GNU Affero General Public License for more details.
22+#
23+# You should have received a copy of the GNU Affero General Public License
24+# along with this program. If not, see <http://www.gnu.org/licenses/>.
25+#
26+##############################################################################
27+from . import sale
28
29=== added file 'sale_line_quantity_properties_based/__openerp__.py'
30--- sale_line_quantity_properties_based/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ sale_line_quantity_properties_based/__openerp__.py 2014-07-04 07:24:04 +0000
32@@ -0,0 +1,107 @@
33+# -*- coding: utf-8 -*-
34+##############################################################################
35+#
36+# Author: Alex Comba <alex.comba@agilebg.com>
37+# Copyright (C) 2014 Agile Business Group sagl
38+# (<http://www.agilebg.com>)
39+#
40+# This program is free software: you can redistribute it and/or modify
41+# it under the terms of the GNU Affero General Public License as published
42+# by the Free Software Foundation, either version 3 of the License, or
43+# (at your option) any later version.
44+#
45+# This program is distributed in the hope that it will be useful,
46+# but WITHOUT ANY WARRANTY; without even the implied warranty of
47+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48+# GNU Affero General Public License for more details.
49+#
50+# You should have received a copy of the GNU Affero General Public License
51+# along with this program. If not, see <http://www.gnu.org/licenses/>.
52+#
53+##############################################################################
54+{
55+ 'name': "Sale line quantity properties based",
56+ 'version': '0.1',
57+ 'category': 'Sales Management',
58+ 'description': """
59+Sale line quantity based on line properties
60+===========================================
61+
62+*This module allows the calculation of the product quantity on the basis of a
63+formula that considers the properties specified by the user on the sale order
64+line and on the quantity (UoS).*
65+
66+Example
67+--------
68+
69+Provided the sale of a given number of pieces (shelves), that may be
70+’x’ meter long and ’y’ meter large, the formula enables the calculation of the
71+total area sold expressed in square meters:
72+ 10 [pcs of] (4 m x 0.5 m) shelves = 20 m² of wood
73+
74+In order to have this function working, it is necessary to have the user
75+proceeding as follows:
76+
77+before starting, s/he has to belong to **sale.group_mrp_properties** by
78+selecting the option "Invoice products in a different unit of measure than the
79+sales order" in the following menu:
80+**Settings --> Configuration --> Warehouse**
81+
82+Then s/he shall create properties such as ‘length 4’, ‘width 0.5’.
83+
84+Properties must respond the following criteria:
85+
86+ * Name: ‘length 1’, ‘length 4’, ‘width 0.5’
87+ * Property Group : either ‘length’ or ‘width’
88+ * Description : the corresponding quantity (1, 4, 0.5...)
89+
90+Property 'length 4'
91+ * Name: ‘length 4’
92+ * Property Group : ‘length’
93+ * Description : 4
94+
95+Property 'width 0.5'
96+ * Name: ‘width 0.5’
97+ * Property Group : ‘width’
98+ * Description : 0.5
99+
100+**Note**: provided the existence of the group 'width', the properties inherent
101+that group, can be created while registering the order by simply digiting the
102+word 'width' followed by a space and then by the desired quantity, example:
103+'width 6'. In this way the system will automatically generate a property of
104+group 'width' with value '6'.
105+
106+After this, the formula 'surface' must be created:
107+
108+**P['length'] * P['width']**
109+whereas P is a mandatory element and 'length' and 'width' must be provided
110+in square brackets **[ ]**
111+
112+This is possible by using the menu:
113+**Manufacturing --> Configuration--> Formulas**
114+
115+Upon the registering of the order, the user will apply in the properties field
116+the desired properties (in this example the ‘lenght 4’ and ‘width 2’), the
117+needed formula (in this example 'surface') and last the quantity (UoS).
118+
119+Contributors
120+------------
121+* Alex Comba <alex.comba@agilebg.com>
122+* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
123+""",
124+ 'author': 'Agile Business Group',
125+ 'website': 'http://www.agilebg.com',
126+ 'license': 'AGPL-3',
127+ 'depends': [
128+ 'sale_mrp',
129+ ],
130+ 'data': [
131+ 'sale_view.xml',
132+ 'mrp_view.xml',
133+ 'security/ir.model.access.csv',
134+ ],
135+ 'test': [
136+ 'test/sale_line_quantity_properties_based.yml',
137+ ],
138+ 'installable': True
139+}
140
141=== added directory 'sale_line_quantity_properties_based/i18n'
142=== added file 'sale_line_quantity_properties_based/i18n/it.po'
143--- sale_line_quantity_properties_based/i18n/it.po 1970-01-01 00:00:00 +0000
144+++ sale_line_quantity_properties_based/i18n/it.po 2014-07-04 07:24:04 +0000
145@@ -0,0 +1,100 @@
146+# Translation of OpenERP Server.
147+# This file contains the translation of the following modules:
148+# * sale_line_quantity_properties_based
149+#
150+msgid ""
151+msgstr ""
152+"Project-Id-Version: OpenERP Server 7.0\n"
153+"Report-Msgid-Bugs-To: \n"
154+"POT-Creation-Date: 2014-06-18 12:36+0000\n"
155+"PO-Revision-Date: 2014-06-18 14:40+0100\n"
156+"Last-Translator: Alex Comba <alex.comba@agilebg.com>\n"
157+"Language-Team: \n"
158+"MIME-Version: 1.0\n"
159+"Content-Type: text/plain; charset=UTF-8\n"
160+"Content-Transfer-Encoding: 8bit\n"
161+"Plural-Forms: \n"
162+"X-Generator: Poedit 1.5.4\n"
163+
164+#. module: sale_line_quantity_properties_based
165+#: model:ir.actions.act_window,name:sale_line_quantity_properties_based.mrp_formula_action
166+#: model:ir.ui.menu,name:sale_line_quantity_properties_based.menu_mrp_formula_group_action
167+msgid "Formulas"
168+msgstr "Formule"
169+
170+#. module: sale_line_quantity_properties_based
171+#: code:addons/sale_line_quantity_properties_based/sale.py:48
172+#, python-format
173+msgid "The property %s has the field description not filled"
174+msgstr "La proprietà %s ha il campo descrizione non compilato"
175+
176+#. module: sale_line_quantity_properties_based
177+#: field:sale.order.line.quantity.formula,name:0
178+msgid "Name"
179+msgstr "Nome"
180+
181+#. module: sale_line_quantity_properties_based
182+#: code:addons/sale_line_quantity_properties_based/sale.py:38
183+#, python-format
184+msgid "Formula Error!"
185+msgstr "Errore Formula!"
186+
187+#. module: sale_line_quantity_properties_based
188+#: model:ir.actions.act_window,help:sale_line_quantity_properties_based.mrp_formula_action
189+msgid ""
190+"<p class=\"oe_view_nocontent_create\">\n"
191+" Click to create a new formula.\n"
192+" </p><p>\n"
193+" The formulas are used to automatically compute the product "
194+"quantity on the basis of the properties specified by the user\n"
195+" on the sale order line and on the quantity (UoS)\n"
196+" </p>\n"
197+" "
198+msgstr ""
199+"<p class=\"oe_view_nocontent_create\">\n"
200+" Clicca per creare una nuova formula.\n"
201+" </p><p>\n"
202+" Le formule vengono usate per calcolare in modo automatico la "
203+"quantità del prodotto in base alle proprietà specificate dall'utente\n"
204+" sulla riga dell'ordine di vendita e in base alla quantità "
205+"(Unità di Vendita)\n"
206+" </p>\n"
207+" "
208+
209+#. module: sale_line_quantity_properties_based
210+#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line_quantity_formula
211+msgid "sale.order.line.quantity.formula"
212+msgstr "sale.order.line.quantity.formula"
213+
214+#. module: sale_line_quantity_properties_based
215+#: code:addons/sale_line_quantity_properties_based/sale.py:54
216+#, python-format
217+msgid ""
218+"The formula %s cannot work since there are more than one property belong to "
219+"the same group"
220+msgstr ""
221+"La formula %s non può funzionare perchè sono presenti più di una proprietà "
222+"apparteneti allo stesso gruppo"
223+
224+#. module: sale_line_quantity_properties_based
225+#: field:sale.order.line,formula_id:0
226+#: field:sale.order.line.quantity.formula,formula_text:0
227+msgid "Formula"
228+msgstr "Formula"
229+
230+#. module: sale_line_quantity_properties_based
231+#: code:addons/sale_line_quantity_properties_based/sale.py:83
232+#, python-format
233+msgid "%s is not a valid formula. Reason: %s"
234+msgstr "%s non è valida. Motivo: %s"
235+
236+#. module: sale_line_quantity_properties_based
237+#: code:addons/sale_line_quantity_properties_based/sale.py:67
238+#, python-format
239+msgid "%s is not a valid value for the property %s, it must be a number"
240+msgstr "%s non è un valore valido per la proprietà %s, deve essere un numero"
241+
242+#. module: sale_line_quantity_properties_based
243+#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
244+msgid "Sales Order Line"
245+msgstr "Linea d'ordine di vendita"
246
247=== added file 'sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot'
248--- sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot 1970-01-01 00:00:00 +0000
249+++ sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot 2014-07-04 07:24:04 +0000
250@@ -0,0 +1,85 @@
251+# Translation of OpenERP Server.
252+# This file contains the translation of the following modules:
253+# * sale_line_quantity_properties_based
254+#
255+msgid ""
256+msgstr ""
257+"Project-Id-Version: OpenERP Server 7.0\n"
258+"Report-Msgid-Bugs-To: \n"
259+"POT-Creation-Date: 2014-06-18 12:43+0000\n"
260+"PO-Revision-Date: 2014-06-18 12:43+0000\n"
261+"Last-Translator: <>\n"
262+"Language-Team: \n"
263+"MIME-Version: 1.0\n"
264+"Content-Type: text/plain; charset=UTF-8\n"
265+"Content-Transfer-Encoding: \n"
266+"Plural-Forms: \n"
267+
268+#. module: sale_line_quantity_properties_based
269+#: model:ir.actions.act_window,name:sale_line_quantity_properties_based.mrp_formula_action
270+#: model:ir.ui.menu,name:sale_line_quantity_properties_based.menu_mrp_formula_group_action
271+msgid "Formulas"
272+msgstr ""
273+
274+#. module: sale_line_quantity_properties_based
275+#: code:addons/sale_line_quantity_properties_based/sale.py:48
276+#, python-format
277+msgid "The property %s has the field description not filled"
278+msgstr ""
279+
280+#. module: sale_line_quantity_properties_based
281+#: field:sale.order.line.quantity.formula,name:0
282+msgid "Name"
283+msgstr ""
284+
285+#. module: sale_line_quantity_properties_based
286+#: code:addons/sale_line_quantity_properties_based/sale.py:38
287+#, python-format
288+msgid "Formula Error!"
289+msgstr ""
290+
291+#. module: sale_line_quantity_properties_based
292+#: model:ir.actions.act_window,help:sale_line_quantity_properties_based.mrp_formula_action
293+msgid "<p class=\"oe_view_nocontent_create\">\n"
294+" Click to create a new formula.\n"
295+" </p><p>\n"
296+" The formulas are used to automatically compute the product quantity on the basis of the properties specified by the user\n"
297+" on the sale order line and on the quantity (UoS)\n"
298+" </p>\n"
299+" "
300+msgstr ""
301+
302+#. module: sale_line_quantity_properties_based
303+#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line_quantity_formula
304+msgid "sale.order.line.quantity.formula"
305+msgstr ""
306+
307+#. module: sale_line_quantity_properties_based
308+#: code:addons/sale_line_quantity_properties_based/sale.py:54
309+#, python-format
310+msgid "The formula %s cannot work since there are more than one property belong to the same group"
311+msgstr ""
312+
313+#. module: sale_line_quantity_properties_based
314+#: field:sale.order.line,formula_id:0
315+#: field:sale.order.line.quantity.formula,formula_text:0
316+msgid "Formula"
317+msgstr ""
318+
319+#. module: sale_line_quantity_properties_based
320+#: code:addons/sale_line_quantity_properties_based/sale.py:83
321+#, python-format
322+msgid "%s is not a valid formula. Reason: %s"
323+msgstr ""
324+
325+#. module: sale_line_quantity_properties_based
326+#: code:addons/sale_line_quantity_properties_based/sale.py:67
327+#, python-format
328+msgid "%s is not a valid value for the property %s, it must be a number"
329+msgstr ""
330+
331+#. module: sale_line_quantity_properties_based
332+#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
333+msgid "Sales Order Line"
334+msgstr ""
335+
336
337=== added file 'sale_line_quantity_properties_based/mrp_view.xml'
338--- sale_line_quantity_properties_based/mrp_view.xml 1970-01-01 00:00:00 +0000
339+++ sale_line_quantity_properties_based/mrp_view.xml 2014-07-04 07:24:04 +0000
340@@ -0,0 +1,29 @@
341+<?xml version="1.0" encoding="utf-8"?>
342+<openerp>
343+ <data>
344+
345+ <record id="mrp_formula_action" model="ir.actions.act_window">
346+ <field name="name">Formulas</field>
347+ <field name="type">ir.actions.act_window</field>
348+ <field name="res_model">sale.order.line.quantity.formula</field>
349+ <field name="view_type">form</field>
350+ <field name="view_mode">tree,form</field>
351+ <field name="help" type="html">
352+ <p class="oe_view_nocontent_create">
353+ Click to create a new formula.
354+ </p><p>
355+ The formulas are used to automatically compute the product quantity on the basis of the properties specified by the user
356+ on the sale order line and on the quantity (UoS)
357+ </p>
358+ </field>
359+ </record>
360+
361+ <menuitem
362+ action="mrp_formula_action"
363+ parent="mrp.menu_mrp_configuration"
364+ groups="base.group_no_one,product.group_mrp_properties"
365+ id="menu_mrp_formula_group_action"
366+ sequence="40"/>
367+
368+ </data>
369+</openerp>
370
371=== added file 'sale_line_quantity_properties_based/sale.py'
372--- sale_line_quantity_properties_based/sale.py 1970-01-01 00:00:00 +0000
373+++ sale_line_quantity_properties_based/sale.py 2014-07-04 07:24:04 +0000
374@@ -0,0 +1,150 @@
375+# -*- coding: utf-8 -*-
376+##############################################################################
377+#
378+# Author: Alex Comba <alex.comba@agilebg.com>
379+# Copyright (C) 2014 Agile Business Group sagl
380+# (<http://www.agilebg.com>)
381+#
382+# This program is free software: you can redistribute it and/or modify
383+# it under the terms of the GNU Affero General Public License as published
384+# by the Free Software Foundation, either version 3 of the License, or
385+# (at your option) any later version.
386+#
387+# This program is distributed in the hope that it will be useful,
388+# but WITHOUT ANY WARRANTY; without even the implied warranty of
389+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
390+# GNU Affero General Public License for more details.
391+#
392+# You should have received a copy of the GNU Affero General Public License
393+# along with this program. If not, see <http://www.gnu.org/licenses/>.
394+#
395+##############################################################################
396+
397+from openerp.osv import orm, fields
398+from openerp.tools.translate import _
399+import traceback
400+
401+
402+class sale_order_line(orm.Model):
403+ _inherit = 'sale.order.line'
404+
405+ def onchange_formula(
406+ self, cr, uid, ids,
407+ formula_id, property_ids, product_uos_qty, context=None
408+ ):
409+ res = {}
410+ properties = {}
411+ warning_msg = ''
412+ warning = {'title': _('Formula Error!')}
413+ if formula_id and property_ids:
414+ formula = self.pool.get('sale.order.line.quantity.formula').browse(
415+ cr, uid, formula_id, context=context)
416+ formula_text = formula.formula_text
417+ mrp_property_obj = self.pool.get('mrp.property')
418+ for mrp_property_id in property_ids[0][2]:
419+ mrp_property = mrp_property_obj.browse(
420+ cr, uid, mrp_property_id, context=context)
421+ if not mrp_property.description:
422+ warning_msg = _(
423+ u"The property %s has the field description "
424+ u"not filled" % mrp_property.name
425+ )
426+ break
427+ if mrp_property.group_id.name in properties:
428+ warning_msg = _(
429+ u"The formula %s cannot work since "
430+ u"there are more than one property belong "
431+ u"to the same group" % formula_text
432+ )
433+ break
434+ try:
435+ properties[mrp_property.group_id.name] = float(
436+ mrp_property.description)
437+ except ValueError:
438+ warning_msg = _(
439+ u"%s is not a valid value for the "
440+ u"property %s, it must be a number"
441+ % (
442+ mrp_property.description,
443+ mrp_property.group_id.name
444+ )
445+ )
446+ break
447+ if warning_msg:
448+ warning.update({'message': warning_msg})
449+ return {'warning': warning}
450+ try:
451+ res['product_uom_qty'] = eval(formula_text.replace(
452+ 'P', 'properties')) * product_uos_qty
453+ except Exception:
454+ formatted_lines = traceback.format_exc().splitlines()
455+ warning_msg = _(
456+ u"%s is not a valid formula. Reason: %s"
457+ % (
458+ formula_text,
459+ formatted_lines[-1]
460+ )
461+ )
462+ warning.update({'message': warning_msg})
463+ return {'warning': warning}
464+ return {'value': res}
465+
466+ _columns = {
467+ 'formula_id': fields.many2one(
468+ 'sale.order.line.quantity.formula', 'Formula',),
469+ }
470+
471+ def product_id_change(
472+ self, cr, uid, ids, pricelist, product, qty=0,
473+ uom=False, qty_uos=0, uos=False, name='', partner_id=False,
474+ lang=False, update_tax=True, date_order=False, packaging=False,
475+ fiscal_position=False, flag=False, context=None
476+ ):
477+ """
478+ Removing product_uos_qty is needed because it is now used to compute
479+ the real quantity.
480+ Otherwise it would be recomputed after the quantity changed.
481+ See the automated test for the use case.
482+ """
483+ res = super(sale_order_line, self).product_id_change(
484+ cr, uid, ids, pricelist, product, qty=qty,
485+ uom=uom, qty_uos=qty_uos, uos=uos, name=name,
486+ partner_id=partner_id, lang=lang, update_tax=update_tax,
487+ date_order=date_order, packaging=packaging,
488+ fiscal_position=fiscal_position, flag=flag, context=context
489+ )
490+ if 'value' in res and 'product_uos_qty' in res['value']:
491+ del res['value']['product_uos_qty']
492+ return res
493+
494+
495+class sale_order_line_quantity_formula(orm.Model):
496+ _name = "sale.order.line.quantity.formula"
497+
498+ _columns = {
499+ 'name': fields.char('Name', size=32),
500+ 'formula_text': fields.text('Formula'),
501+ }
502+
503+
504+class mrp_property(orm.Model):
505+ _inherit = 'mrp.property'
506+
507+ def name_create(self, cr, uid, name, context=None):
508+ """
509+ This allows the user to digit 'width 0.5' and the system will
510+ automatically create a property of group 'width' with value '0.5'
511+ """
512+ splitted_name = name.split(' ')
513+ if len(splitted_name) == 2:
514+ group_ids = self.pool['mrp.property.group'].search(
515+ cr, uid, [('name', '=', splitted_name[0])], context=context)
516+ if group_ids and len(group_ids) == 1:
517+ rec_id = self.create(cr, uid, {
518+ 'name': name,
519+ 'group_id': group_ids[0],
520+ 'description': splitted_name[1]
521+ }, context=context)
522+ return self.name_get(cr, uid, [rec_id], context)[0]
523+ return super(mrp_property, self).name_create(
524+ cr, uid, name, context=context)
525
526=== added file 'sale_line_quantity_properties_based/sale_view.xml'
527--- sale_line_quantity_properties_based/sale_view.xml 1970-01-01 00:00:00 +0000
528+++ sale_line_quantity_properties_based/sale_view.xml 2014-07-04 07:24:04 +0000
529@@ -0,0 +1,43 @@
530+<?xml version="1.0" encoding="utf-8"?>
531+<openerp>
532+ <data>
533+
534+ <record id="view_order_form_inherit" model="ir.ui.view">
535+ <field name="name">sale.order.form.sale.stock</field>
536+ <field name="model">sale.order</field>
537+ <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>
538+ <field name="arch" type="xml">
539+ <xpath expr="//field[@name='property_ids']" position="replace"/>
540+ <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="after">
541+ <field name="property_ids" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)" widget="many2many_tags"/>
542+ </xpath>
543+ </field>
544+ </record>
545+
546+ <record id="view_order_form" model="ir.ui.view">
547+ <field name="name">sale.order.form</field>
548+ <field name="model">sale.order</field>
549+ <field name="inherit_id" ref="sale.view_order_form"/>
550+ <field name="arch" type="xml">
551+ <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/label[@for='product_uos_qty']" position="replace">
552+ </xpath>
553+ <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/div[@groups='product.group_uos']" position="replace">
554+ </xpath>
555+ <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='price_unit']" position="replace">
556+ </xpath>
557+ <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="after">
558+ <field name="formula_id" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)"/>
559+ <label for="product_uos_qty"/>
560+ <div>
561+ <field name="product_uos_qty" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)" class="oe_inline"/>
562+ <field name="product_uos" class="oe_inline"/>
563+ </div>
564+ </xpath>
565+ <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='address_allotment_id']" position="after">
566+ <field name="price_unit"/>
567+ </xpath>
568+ </field>
569+ </record>
570+
571+ </data>
572+</openerp>
573
574=== added directory 'sale_line_quantity_properties_based/security'
575=== added file 'sale_line_quantity_properties_based/security/ir.model.access.csv'
576--- sale_line_quantity_properties_based/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
577+++ sale_line_quantity_properties_based/security/ir.model.access.csv 2014-07-04 07:24:04 +0000
578@@ -0,0 +1,3 @@
579+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
580+access_sale_order_line_quantity_formula_user,sale.order.line.quantity.formula.user,model_sale_order_line_quantity_formula,base.group_sale_salesman,1,0,0,0
581+access_sale_order_line_quantity_formula_manager,sale.order.line.quantity.formula salemanager,model_sale_order_line_quantity_formula,base.group_sale_manager,1,1,1,1
582
583=== added directory 'sale_line_quantity_properties_based/test'
584=== added file 'sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml'
585--- sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml 1970-01-01 00:00:00 +0000
586+++ sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml 2014-07-04 07:24:04 +0000
587@@ -0,0 +1,68 @@
588+-
589+ In order to test the sale_line_quantity_properties_based,
590+ I start by creating a new unit of measure category 'Surface'
591+-
592+ !record {model: product.uom.categ, id: product_uom_categ_area}:
593+ name: Surface
594+-
595+ I create the unit of measure square meter
596+-
597+ !record {model: product.uom, id: product_uom_m2}:
598+ name: m²
599+ category_id: product_uom_categ_area
600+-
601+ I create a product 'shelf'
602+-
603+ !record {model: product.product, id: product_product_shelf}:
604+ categ_id: product.product_category_all
605+ name: shelf
606+ type: product
607+ uom_id: product_uom_m2
608+ list_price: 1.0
609+-
610+ I create a property group 'length'
611+-
612+ !record {model: mrp.property.group, id: mrp_property_group_length}:
613+ name: length
614+-
615+ I create a property group 'width'
616+-
617+ !record {model: mrp.property.group, id: mrp_property_group_width}:
618+ name: width
619+-
620+ I create a property 'length 4'
621+-
622+ !record {model: mrp.property, id: mrp_property_length_4}:
623+ name: length 4
624+ group_id: mrp_property_group_length
625+ description: 4
626+-
627+ I create a property 'width 0.5'
628+-
629+ !record {model: mrp.property, id: mrp_property_length_width_05}:
630+ name: width 0.5
631+ group_id: mrp_property_group_width
632+ description: 0.5
633+-
634+ I create the formula surface
635+-
636+ !record {model: sale.order.line.quantity.formula, id: sale_order_line_quantity_formula_surface}:
637+ name: surface
638+ formula_text: P['width'] * P['length']
639+-
640+ Now i create a sale order with an order line that uses properties and formula previously created
641+-
642+ !record {model: sale.order, id: sale_order_formula}:
643+ partner_id: base.res_partner_1
644+ order_line:
645+ - product_id: product_product_shelf
646+ property_ids:
647+ - mrp_property_length_4
648+ - mrp_property_length_width_05
649+ formula_id: sale_order_line_quantity_formula_surface
650+ product_uos_qty: 6
651+-
652+ I verify that the quantity product has been correctly calculated using the formula
653+-
654+ !assert {model: sale.order, id: sale_order_formula, string: The formula was not correctly calculated}:
655+ - order_line[0].product_uom_qty == 4 * 0.5 * 6

Subscribers

People subscribed via source and target branches