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
=== added directory 'sale_line_quantity_properties_based'
=== added file 'sale_line_quantity_properties_based/__init__.py'
--- sale_line_quantity_properties_based/__init__.py 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/__init__.py 2014-07-04 07:24:04 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Alex Comba <alex.comba@agilebg.com>
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22from . import sale
023
=== added file 'sale_line_quantity_properties_based/__openerp__.py'
--- sale_line_quantity_properties_based/__openerp__.py 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/__openerp__.py 2014-07-04 07:24:04 +0000
@@ -0,0 +1,107 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Alex Comba <alex.comba@agilebg.com>
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22{
23 'name': "Sale line quantity properties based",
24 'version': '0.1',
25 'category': 'Sales Management',
26 'description': """
27Sale line quantity based on line properties
28===========================================
29
30*This module allows the calculation of the product quantity on the basis of a
31formula that considers the properties specified by the user on the sale order
32line and on the quantity (UoS).*
33
34Example
35--------
36
37Provided the sale of a given number of pieces (shelves), that may be
38’x’ meter long and ’y’ meter large, the formula enables the calculation of the
39total area sold expressed in square meters:
40 10 [pcs of] (4 m x 0.5 m) shelves = 20 m² of wood
41
42In order to have this function working, it is necessary to have the user
43proceeding as follows:
44
45before starting, s/he has to belong to **sale.group_mrp_properties** by
46selecting the option "Invoice products in a different unit of measure than the
47sales order" in the following menu:
48**Settings --> Configuration --> Warehouse**
49
50Then s/he shall create properties such as ‘length 4’, ‘width 0.5’.
51
52Properties must respond the following criteria:
53
54 * Name: ‘length 1’, ‘length 4’, ‘width 0.5’
55 * Property Group : either ‘length’ or ‘width’
56 * Description : the corresponding quantity (1, 4, 0.5...)
57
58Property 'length 4'
59 * Name: ‘length 4’
60 * Property Group : ‘length’
61 * Description : 4
62
63Property 'width 0.5'
64 * Name: ‘width 0.5’
65 * Property Group : ‘width’
66 * Description : 0.5
67
68**Note**: provided the existence of the group 'width', the properties inherent
69that group, can be created while registering the order by simply digiting the
70word 'width' followed by a space and then by the desired quantity, example:
71'width 6'. In this way the system will automatically generate a property of
72group 'width' with value '6'.
73
74After this, the formula 'surface' must be created:
75
76**P['length'] * P['width']**
77whereas P is a mandatory element and 'length' and 'width' must be provided
78in square brackets **[ ]**
79
80This is possible by using the menu:
81**Manufacturing --> Configuration--> Formulas**
82
83Upon the registering of the order, the user will apply in the properties field
84the desired properties (in this example the ‘lenght 4’ and ‘width 2’), the
85needed formula (in this example 'surface') and last the quantity (UoS).
86
87Contributors
88------------
89* Alex Comba <alex.comba@agilebg.com>
90* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
91""",
92 'author': 'Agile Business Group',
93 'website': 'http://www.agilebg.com',
94 'license': 'AGPL-3',
95 'depends': [
96 'sale_mrp',
97 ],
98 'data': [
99 'sale_view.xml',
100 'mrp_view.xml',
101 'security/ir.model.access.csv',
102 ],
103 'test': [
104 'test/sale_line_quantity_properties_based.yml',
105 ],
106 'installable': True
107}
0108
=== added directory 'sale_line_quantity_properties_based/i18n'
=== added file 'sale_line_quantity_properties_based/i18n/it.po'
--- sale_line_quantity_properties_based/i18n/it.po 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/i18n/it.po 2014-07-04 07:24:04 +0000
@@ -0,0 +1,100 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * sale_line_quantity_properties_based
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-06-18 12:36+0000\n"
10"PO-Revision-Date: 2014-06-18 14:40+0100\n"
11"Last-Translator: Alex Comba <alex.comba@agilebg.com>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"Plural-Forms: \n"
17"X-Generator: Poedit 1.5.4\n"
18
19#. module: sale_line_quantity_properties_based
20#: model:ir.actions.act_window,name:sale_line_quantity_properties_based.mrp_formula_action
21#: model:ir.ui.menu,name:sale_line_quantity_properties_based.menu_mrp_formula_group_action
22msgid "Formulas"
23msgstr "Formule"
24
25#. module: sale_line_quantity_properties_based
26#: code:addons/sale_line_quantity_properties_based/sale.py:48
27#, python-format
28msgid "The property %s has the field description not filled"
29msgstr "La proprietà %s ha il campo descrizione non compilato"
30
31#. module: sale_line_quantity_properties_based
32#: field:sale.order.line.quantity.formula,name:0
33msgid "Name"
34msgstr "Nome"
35
36#. module: sale_line_quantity_properties_based
37#: code:addons/sale_line_quantity_properties_based/sale.py:38
38#, python-format
39msgid "Formula Error!"
40msgstr "Errore Formula!"
41
42#. module: sale_line_quantity_properties_based
43#: model:ir.actions.act_window,help:sale_line_quantity_properties_based.mrp_formula_action
44msgid ""
45"<p class=\"oe_view_nocontent_create\">\n"
46" Click to create a new formula.\n"
47" </p><p>\n"
48" The formulas are used to automatically compute the product "
49"quantity on the basis of the properties specified by the user\n"
50" on the sale order line and on the quantity (UoS)\n"
51" </p>\n"
52" "
53msgstr ""
54"<p class=\"oe_view_nocontent_create\">\n"
55" Clicca per creare una nuova formula.\n"
56" </p><p>\n"
57" Le formule vengono usate per calcolare in modo automatico la "
58"quantità del prodotto in base alle proprietà specificate dall'utente\n"
59" sulla riga dell'ordine di vendita e in base alla quantità "
60"(Unità di Vendita)\n"
61" </p>\n"
62" "
63
64#. module: sale_line_quantity_properties_based
65#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line_quantity_formula
66msgid "sale.order.line.quantity.formula"
67msgstr "sale.order.line.quantity.formula"
68
69#. module: sale_line_quantity_properties_based
70#: code:addons/sale_line_quantity_properties_based/sale.py:54
71#, python-format
72msgid ""
73"The formula %s cannot work since there are more than one property belong to "
74"the same group"
75msgstr ""
76"La formula %s non può funzionare perchè sono presenti più di una proprietà "
77"apparteneti allo stesso gruppo"
78
79#. module: sale_line_quantity_properties_based
80#: field:sale.order.line,formula_id:0
81#: field:sale.order.line.quantity.formula,formula_text:0
82msgid "Formula"
83msgstr "Formula"
84
85#. module: sale_line_quantity_properties_based
86#: code:addons/sale_line_quantity_properties_based/sale.py:83
87#, python-format
88msgid "%s is not a valid formula. Reason: %s"
89msgstr "%s non è valida. Motivo: %s"
90
91#. module: sale_line_quantity_properties_based
92#: code:addons/sale_line_quantity_properties_based/sale.py:67
93#, python-format
94msgid "%s is not a valid value for the property %s, it must be a number"
95msgstr "%s non è un valore valido per la proprietà %s, deve essere un numero"
96
97#. module: sale_line_quantity_properties_based
98#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
99msgid "Sales Order Line"
100msgstr "Linea d'ordine di vendita"
0101
=== added file 'sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot'
--- sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/i18n/sale_line_quantity_properties_based.pot 2014-07-04 07:24:04 +0000
@@ -0,0 +1,85 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * sale_line_quantity_properties_based
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2014-06-18 12:43+0000\n"
10"PO-Revision-Date: 2014-06-18 12:43+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: sale_line_quantity_properties_based
19#: model:ir.actions.act_window,name:sale_line_quantity_properties_based.mrp_formula_action
20#: model:ir.ui.menu,name:sale_line_quantity_properties_based.menu_mrp_formula_group_action
21msgid "Formulas"
22msgstr ""
23
24#. module: sale_line_quantity_properties_based
25#: code:addons/sale_line_quantity_properties_based/sale.py:48
26#, python-format
27msgid "The property %s has the field description not filled"
28msgstr ""
29
30#. module: sale_line_quantity_properties_based
31#: field:sale.order.line.quantity.formula,name:0
32msgid "Name"
33msgstr ""
34
35#. module: sale_line_quantity_properties_based
36#: code:addons/sale_line_quantity_properties_based/sale.py:38
37#, python-format
38msgid "Formula Error!"
39msgstr ""
40
41#. module: sale_line_quantity_properties_based
42#: model:ir.actions.act_window,help:sale_line_quantity_properties_based.mrp_formula_action
43msgid "<p class=\"oe_view_nocontent_create\">\n"
44" Click to create a new formula.\n"
45" </p><p>\n"
46" The formulas are used to automatically compute the product quantity on the basis of the properties specified by the user\n"
47" on the sale order line and on the quantity (UoS)\n"
48" </p>\n"
49" "
50msgstr ""
51
52#. module: sale_line_quantity_properties_based
53#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line_quantity_formula
54msgid "sale.order.line.quantity.formula"
55msgstr ""
56
57#. module: sale_line_quantity_properties_based
58#: code:addons/sale_line_quantity_properties_based/sale.py:54
59#, python-format
60msgid "The formula %s cannot work since there are more than one property belong to the same group"
61msgstr ""
62
63#. module: sale_line_quantity_properties_based
64#: field:sale.order.line,formula_id:0
65#: field:sale.order.line.quantity.formula,formula_text:0
66msgid "Formula"
67msgstr ""
68
69#. module: sale_line_quantity_properties_based
70#: code:addons/sale_line_quantity_properties_based/sale.py:83
71#, python-format
72msgid "%s is not a valid formula. Reason: %s"
73msgstr ""
74
75#. module: sale_line_quantity_properties_based
76#: code:addons/sale_line_quantity_properties_based/sale.py:67
77#, python-format
78msgid "%s is not a valid value for the property %s, it must be a number"
79msgstr ""
80
81#. module: sale_line_quantity_properties_based
82#: model:ir.model,name:sale_line_quantity_properties_based.model_sale_order_line
83msgid "Sales Order Line"
84msgstr ""
85
086
=== added file 'sale_line_quantity_properties_based/mrp_view.xml'
--- sale_line_quantity_properties_based/mrp_view.xml 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/mrp_view.xml 2014-07-04 07:24:04 +0000
@@ -0,0 +1,29 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="mrp_formula_action" model="ir.actions.act_window">
6 <field name="name">Formulas</field>
7 <field name="type">ir.actions.act_window</field>
8 <field name="res_model">sale.order.line.quantity.formula</field>
9 <field name="view_type">form</field>
10 <field name="view_mode">tree,form</field>
11 <field name="help" type="html">
12 <p class="oe_view_nocontent_create">
13 Click to create a new formula.
14 </p><p>
15 The formulas are used to automatically compute the product quantity on the basis of the properties specified by the user
16 on the sale order line and on the quantity (UoS)
17 </p>
18 </field>
19 </record>
20
21 <menuitem
22 action="mrp_formula_action"
23 parent="mrp.menu_mrp_configuration"
24 groups="base.group_no_one,product.group_mrp_properties"
25 id="menu_mrp_formula_group_action"
26 sequence="40"/>
27
28 </data>
29</openerp>
030
=== added file 'sale_line_quantity_properties_based/sale.py'
--- sale_line_quantity_properties_based/sale.py 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/sale.py 2014-07-04 07:24:04 +0000
@@ -0,0 +1,150 @@
1# -*- coding: utf-8 -*-
2##############################################################################
3#
4# Author: Alex Comba <alex.comba@agilebg.com>
5# Copyright (C) 2014 Agile Business Group sagl
6# (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21##############################################################################
22
23from openerp.osv import orm, fields
24from openerp.tools.translate import _
25import traceback
26
27
28class sale_order_line(orm.Model):
29 _inherit = 'sale.order.line'
30
31 def onchange_formula(
32 self, cr, uid, ids,
33 formula_id, property_ids, product_uos_qty, context=None
34 ):
35 res = {}
36 properties = {}
37 warning_msg = ''
38 warning = {'title': _('Formula Error!')}
39 if formula_id and property_ids:
40 formula = self.pool.get('sale.order.line.quantity.formula').browse(
41 cr, uid, formula_id, context=context)
42 formula_text = formula.formula_text
43 mrp_property_obj = self.pool.get('mrp.property')
44 for mrp_property_id in property_ids[0][2]:
45 mrp_property = mrp_property_obj.browse(
46 cr, uid, mrp_property_id, context=context)
47 if not mrp_property.description:
48 warning_msg = _(
49 u"The property %s has the field description "
50 u"not filled" % mrp_property.name
51 )
52 break
53 if mrp_property.group_id.name in properties:
54 warning_msg = _(
55 u"The formula %s cannot work since "
56 u"there are more than one property belong "
57 u"to the same group" % formula_text
58 )
59 break
60 try:
61 properties[mrp_property.group_id.name] = float(
62 mrp_property.description)
63 except ValueError:
64 warning_msg = _(
65 u"%s is not a valid value for the "
66 u"property %s, it must be a number"
67 % (
68 mrp_property.description,
69 mrp_property.group_id.name
70 )
71 )
72 break
73 if warning_msg:
74 warning.update({'message': warning_msg})
75 return {'warning': warning}
76 try:
77 res['product_uom_qty'] = eval(formula_text.replace(
78 'P', 'properties')) * product_uos_qty
79 except Exception:
80 formatted_lines = traceback.format_exc().splitlines()
81 warning_msg = _(
82 u"%s is not a valid formula. Reason: %s"
83 % (
84 formula_text,
85 formatted_lines[-1]
86 )
87 )
88 warning.update({'message': warning_msg})
89 return {'warning': warning}
90 return {'value': res}
91
92 _columns = {
93 'formula_id': fields.many2one(
94 'sale.order.line.quantity.formula', 'Formula',),
95 }
96
97 def product_id_change(
98 self, cr, uid, ids, pricelist, product, qty=0,
99 uom=False, qty_uos=0, uos=False, name='', partner_id=False,
100 lang=False, update_tax=True, date_order=False, packaging=False,
101 fiscal_position=False, flag=False, context=None
102 ):
103 """
104 Removing product_uos_qty is needed because it is now used to compute
105 the real quantity.
106 Otherwise it would be recomputed after the quantity changed.
107 See the automated test for the use case.
108 """
109 res = super(sale_order_line, self).product_id_change(
110 cr, uid, ids, pricelist, product, qty=qty,
111 uom=uom, qty_uos=qty_uos, uos=uos, name=name,
112 partner_id=partner_id, lang=lang, update_tax=update_tax,
113 date_order=date_order, packaging=packaging,
114 fiscal_position=fiscal_position, flag=flag, context=context
115 )
116 if 'value' in res and 'product_uos_qty' in res['value']:
117 del res['value']['product_uos_qty']
118 return res
119
120
121class sale_order_line_quantity_formula(orm.Model):
122 _name = "sale.order.line.quantity.formula"
123
124 _columns = {
125 'name': fields.char('Name', size=32),
126 'formula_text': fields.text('Formula'),
127 }
128
129
130class mrp_property(orm.Model):
131 _inherit = 'mrp.property'
132
133 def name_create(self, cr, uid, name, context=None):
134 """
135 This allows the user to digit 'width 0.5' and the system will
136 automatically create a property of group 'width' with value '0.5'
137 """
138 splitted_name = name.split(' ')
139 if len(splitted_name) == 2:
140 group_ids = self.pool['mrp.property.group'].search(
141 cr, uid, [('name', '=', splitted_name[0])], context=context)
142 if group_ids and len(group_ids) == 1:
143 rec_id = self.create(cr, uid, {
144 'name': name,
145 'group_id': group_ids[0],
146 'description': splitted_name[1]
147 }, context=context)
148 return self.name_get(cr, uid, [rec_id], context)[0]
149 return super(mrp_property, self).name_create(
150 cr, uid, name, context=context)
0151
=== added file 'sale_line_quantity_properties_based/sale_view.xml'
--- sale_line_quantity_properties_based/sale_view.xml 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/sale_view.xml 2014-07-04 07:24:04 +0000
@@ -0,0 +1,43 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <record id="view_order_form_inherit" model="ir.ui.view">
6 <field name="name">sale.order.form.sale.stock</field>
7 <field name="model">sale.order</field>
8 <field name="inherit_id" ref="sale_stock.view_order_form_inherit"/>
9 <field name="arch" type="xml">
10 <xpath expr="//field[@name='property_ids']" position="replace"/>
11 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="after">
12 <field name="property_ids" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)" widget="many2many_tags"/>
13 </xpath>
14 </field>
15 </record>
16
17 <record id="view_order_form" model="ir.ui.view">
18 <field name="name">sale.order.form</field>
19 <field name="model">sale.order</field>
20 <field name="inherit_id" ref="sale.view_order_form"/>
21 <field name="arch" type="xml">
22 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/label[@for='product_uos_qty']" position="replace">
23 </xpath>
24 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/div[@groups='product.group_uos']" position="replace">
25 </xpath>
26 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='price_unit']" position="replace">
27 </xpath>
28 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='product_id']" position="after">
29 <field name="formula_id" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)"/>
30 <label for="product_uos_qty"/>
31 <div>
32 <field name="product_uos_qty" on_change="onchange_formula(formula_id, property_ids, product_uos_qty)" class="oe_inline"/>
33 <field name="product_uos" class="oe_inline"/>
34 </div>
35 </xpath>
36 <xpath expr="//page[@string='Order Lines']/field[@name='order_line']/form[@string='Sales Order Lines']/group/group/field[@name='address_allotment_id']" position="after">
37 <field name="price_unit"/>
38 </xpath>
39 </field>
40 </record>
41
42 </data>
43</openerp>
044
=== added directory 'sale_line_quantity_properties_based/security'
=== added file 'sale_line_quantity_properties_based/security/ir.model.access.csv'
--- sale_line_quantity_properties_based/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/security/ir.model.access.csv 2014-07-04 07:24:04 +0000
@@ -0,0 +1,3 @@
1id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
2access_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
3access_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
04
=== added directory 'sale_line_quantity_properties_based/test'
=== added file 'sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml'
--- sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml 1970-01-01 00:00:00 +0000
+++ sale_line_quantity_properties_based/test/sale_line_quantity_properties_based.yml 2014-07-04 07:24:04 +0000
@@ -0,0 +1,68 @@
1-
2 In order to test the sale_line_quantity_properties_based,
3 I start by creating a new unit of measure category 'Surface'
4-
5 !record {model: product.uom.categ, id: product_uom_categ_area}:
6 name: Surface
7-
8 I create the unit of measure square meter
9-
10 !record {model: product.uom, id: product_uom_m2}:
11 name: m²
12 category_id: product_uom_categ_area
13-
14 I create a product 'shelf'
15-
16 !record {model: product.product, id: product_product_shelf}:
17 categ_id: product.product_category_all
18 name: shelf
19 type: product
20 uom_id: product_uom_m2
21 list_price: 1.0
22-
23 I create a property group 'length'
24-
25 !record {model: mrp.property.group, id: mrp_property_group_length}:
26 name: length
27-
28 I create a property group 'width'
29-
30 !record {model: mrp.property.group, id: mrp_property_group_width}:
31 name: width
32-
33 I create a property 'length 4'
34-
35 !record {model: mrp.property, id: mrp_property_length_4}:
36 name: length 4
37 group_id: mrp_property_group_length
38 description: 4
39-
40 I create a property 'width 0.5'
41-
42 !record {model: mrp.property, id: mrp_property_length_width_05}:
43 name: width 0.5
44 group_id: mrp_property_group_width
45 description: 0.5
46-
47 I create the formula surface
48-
49 !record {model: sale.order.line.quantity.formula, id: sale_order_line_quantity_formula_surface}:
50 name: surface
51 formula_text: P['width'] * P['length']
52-
53 Now i create a sale order with an order line that uses properties and formula previously created
54-
55 !record {model: sale.order, id: sale_order_formula}:
56 partner_id: base.res_partner_1
57 order_line:
58 - product_id: product_product_shelf
59 property_ids:
60 - mrp_property_length_4
61 - mrp_property_length_width_05
62 formula_id: sale_order_line_quantity_formula_surface
63 product_uos_qty: 6
64-
65 I verify that the quantity product has been correctly calculated using the formula
66-
67 !assert {model: sale.order, id: sale_order_formula, string: The formula was not correctly calculated}:
68 - order_line[0].product_uom_qty == 4 * 0.5 * 6

Subscribers

People subscribed via source and target branches