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