Merge lp:~agilebg/openerp-product-attributes/adding_product_pack_7 into lp:~product-core-editors/openerp-product-attributes/7.0

Proposed by Lorenzo Battistini
Status: Needs review
Proposed branch: lp:~agilebg/openerp-product-attributes/adding_product_pack_7
Merge into: lp:~product-core-editors/openerp-product-attributes/7.0
Diff against target: 1602 lines (+1545/-0)
11 files modified
product_pack/__init__.py (+22/-0)
product_pack/__openerp__.py (+48/-0)
product_pack/i18n/ca.po (+163/-0)
product_pack/i18n/de.po (+145/-0)
product_pack/i18n/es.po (+164/-0)
product_pack/i18n/it.po (+164/-0)
product_pack/i18n/product_pack.pot (+155/-0)
product_pack/i18n/pt.po (+149/-0)
product_pack/pack.py (+484/-0)
product_pack/pack_view.xml (+48/-0)
product_pack/security/ir.model.access.csv (+3/-0)
To merge this branch: bzr merge lp:~agilebg/openerp-product-attributes/adding_product_pack_7
Reviewer Review Type Date Requested Status
Laetitia Gangloff (Acsone) (community) Needs Resubmitting
Paulius Sladkevičius @ hbee (community) test Needs Fixing
Leonardo Pistone code review, no test Needs Fixing
Pedro Manuel Baeza code review, no test Needs Fixing
Review via email: mp+195786@code.launchpad.net

Description of the change

Based on the NAN_product_pack this module allows configuring products
as a collection of other products.
If such a product is added in a sale order or a purchase order, all the
products of the pack will be added automatically (when storing the order)
as children of the pack product

To post a comment you must log in.
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

Hi, Lorenzo.

Good addition!

You need to fix translation files, because they still point to nan_product_pack module.

Regards.

review: Needs Fixing (code review, no test)
215. By Alex Comba - Agile BG

[FIX] Replaced nan_product_pack.pot by product_pack.pot

Revision history for this message
Alex Comba - Agile BG (tafaru) wrote :

Hi, Pedro.

I've just pushed the right pot file, please check if now it is ok.

Cheers.

Revision history for this message
Alex Comba - Agile BG (tafaru) wrote :

I forgot to fix the other translation files, I'll do it asap.

Regards.

Revision history for this message
Leonardo Pistone (lepistone) wrote :

Thank you Lorenzo, Alex.

- Translations, if they are old and/or incorrect, IMO we can remove them for now. You could leave whatever works for you (i.e. Italian) and remove everything else

- Defaults: lambda is not needed anymore

- I see some long, multi-line comments in the code. Maybe some could be moved in some more prominent place, like docstrings?

L

review: Needs Fixing (code review, no test)
Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

There is need to prevent possibility to add product pack to itself, otherwise it's easy to get infinite recursion when 'stock_depends' is marked.

review: Needs Fixing (test)
216. By Alex Comba - Agile BG

[REM] lambda not needed anymore

Revision history for this message
Ana Juaristi Olalde (ajuaristio) wrote :

Just to point it:

There was an error on nan_product_pack V6.X where after using it in a sale order, you duplicate that sale order, all the lines from pack used to stay on origin sale order.

nan_product_pack has been included in several repositories from different integrators, so depending the repository you used to migrate, bug could still be there. On the other side, it's very easy to fix. New sale_order_id not asigned on copied sale order lines but origin sale_order_id.

My 2 cents

217. By Lorenzo Battistini

[MERGE] from main

Revision history for this message
Laetitia Gangloff (Acsone) (laetitia-gangloff) wrote :

This project is now hosted on https://github.com/OCA/product-attribute. Please move your proposal there. This guide may help you https://github.com/OCA/maintainers-tools/wiki/How-to-move-a-Merge-Proposal-to-GitHub

review: Needs Resubmitting
Revision history for this message
Alex Comba - Agile BG (tafaru) wrote :

Unmerged revisions

217. By Lorenzo Battistini

[MERGE] from main

216. By Alex Comba - Agile BG

[REM] lambda not needed anymore

215. By Alex Comba - Agile BG

[FIX] Replaced nan_product_pack.pot by product_pack.pot

214. By Alex Comba - Agile BG

[FIX] Get labels for boolean fields inside 'Pack' page

213. By Alex Comba - Agile BG

[IMP] Add PEP8 style check using flake8

212. By Alex Comba - Agile BG

[REM] empty spaces close to arguments

211. By Alex Comba - Agile BG

[REF] product_stock module porting to 7.0

210. By Alex Comba - Agile BG

[ADD] product_pack module 6.1 version

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'product_pack'
2=== added file 'product_pack/__init__.py'
3--- product_pack/__init__.py 1970-01-01 00:00:00 +0000
4+++ product_pack/__init__.py 2014-07-07 16:03:26 +0000
5@@ -0,0 +1,22 @@
6+# -*- coding: utf-8 -*-
7+###############################################################################
8+#
9+# Copyright (c) 2009 Angel Alvarez - NaN (http://www.nan-tic.com)
10+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
11+# Copyright (C) 2013 Agile Business Group sagl (<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+import pack
28
29=== added file 'product_pack/__openerp__.py'
30--- product_pack/__openerp__.py 1970-01-01 00:00:00 +0000
31+++ product_pack/__openerp__.py 2014-07-07 16:03:26 +0000
32@@ -0,0 +1,48 @@
33+# -*- coding: utf-8 -*-
34+###############################################################################
35+#
36+# Copyright (c) 2009 Angel Alvarez - NaN (http://www.nan-tic.com)
37+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
38+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
39+# @author Albert Cervera i Areny <albert@nan-tic.com>
40+# @author Franco Tampieri <franco.tampieri@agilebg.com>
41+# Ported to OpenERP 7.0 by Alex Comba <alex.comba@agilebg.com>
42+#
43+# This program is free software: you can redistribute it and/or modify
44+# it under the terms of the GNU Affero General Public License as published
45+# by the Free Software Foundation, either version 3 of the License, or
46+# (at your option) any later version.
47+#
48+# This program is distributed in the hope that it will be useful,
49+# but WITHOUT ANY WARRANTY; without even the implied warranty of
50+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
51+# GNU Affero General Public License for more details.
52+#
53+# You should have received a copy of the GNU Affero General Public License
54+# along with this program. If not, see <http://www.gnu.org/licenses/>.
55+#
56+###############################################################################
57+{
58+ "name": "Product Pack",
59+ "version": "0.2",
60+ "category": "Warehouse Management",
61+ "description": """
62+Based on the NAN_product_pack this module allows configuring products
63+as a collection of other products.
64+If such a product is added in a sale order or a purchase order, all the
65+products of the pack will be added automatically (when storing the order)
66+as children of the pack product.
67+ """,
68+ "author": "Agile Business Group & NaN·tic",
69+ "website": "http://www.agilebg.com",
70+ "depends": [
71+ 'sale',
72+ 'purchase',
73+ ],
74+ "data": [
75+ 'security/ir.model.access.csv',
76+ 'pack_view.xml'
77+ ],
78+ "active": False,
79+ "installable": True
80+}
81
82=== added directory 'product_pack/i18n'
83=== added file 'product_pack/i18n/ca.po'
84--- product_pack/i18n/ca.po 1970-01-01 00:00:00 +0000
85+++ product_pack/i18n/ca.po 2014-07-07 16:03:26 +0000
86@@ -0,0 +1,163 @@
87+# Translation of OpenERP Server.
88+# This file contains the translation of the following modules:
89+# * nan_product_pack
90+#
91+msgid ""
92+msgstr ""
93+"Project-Id-Version: OpenERP Server 5.0.6\n"
94+"Report-Msgid-Bugs-To: support@openerp.com\n"
95+"POT-Creation-Date: 2011-01-15 11:45+0000\n"
96+"PO-Revision-Date: 2011-02-15 15:15+0000\n"
97+"Last-Translator: Jordi Esteve (Zikzakmedia) <jesteve@zikzakmedia.com>\n"
98+"Language-Team: \n"
99+"MIME-Version: 1.0\n"
100+"Content-Type: text/plain; charset=UTF-8\n"
101+"Content-Transfer-Encoding: 8bit\n"
102+"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
103+"X-Generator: Launchpad (build 15060)\n"
104+
105+#. module: nan_product_pack
106+#: constraint:ir.model:0
107+msgid ""
108+"The Object name must start with x_ and not contain any special character !"
109+msgstr ""
110+"El nom de l'objecte ha de començar amb x_ i no contenir cap caràcter "
111+"especial!"
112+
113+#. module: nan_product_pack
114+#: help:product.product,stock_depends:0
115+msgid "Mark if pack stock is calcualted from component stock"
116+msgstr ""
117+"Marqueu aquest camp si l'estoc del paquet es calcula a partir de l'estoc "
118+"dels components."
119+
120+#. module: nan_product_pack
121+#: field:sale.order.line,pack_child_line_ids:0
122+msgid "Lines in pack"
123+msgstr "Línies en el paquet"
124+
125+#. module: nan_product_pack
126+#: help:sale.order.line,pack_depth:0
127+msgid "Depth of the product if it is part of a pack."
128+msgstr "Profunditat del producte si forma part d'un paquet."
129+
130+#. module: nan_product_pack
131+#: field:product.pack.line,product_id:0
132+msgid "Product"
133+msgstr "Producte"
134+
135+#. module: nan_product_pack
136+#: view:product.pack.line:0
137+msgid "Pack Product Lines"
138+msgstr "Línies del paquet de productes"
139+
140+#. module: nan_product_pack
141+#: view:product.product:0
142+msgid ""
143+"If you add products in the 'Pack Products' field, all those products will be "
144+"added automatically when a new quotation or order is created."
145+msgstr ""
146+"Si afegiu productes en el camp \"Paquet de productes\", tots els productes "
147+"s'afegiran automàticament quan creeu un nou pressupost o comanda."
148+
149+#. module: nan_product_pack
150+#: model:ir.module.module,description:nan_product_pack.module_meta_information
151+msgid ""
152+"\n"
153+"Allows configuring products as a collection of other products. If such a "
154+"product is added in a sale order, all the products of the pack will be added "
155+"automatically (when storing the order) as children of the pack product.\n"
156+"\n"
157+"The module has been made compatible with nan_external_prices and containts "
158+"code to specifically handle when the module is available but they're still "
159+"independent and there are no dependencies between them.\n"
160+" "
161+msgstr ""
162+"\n"
163+"Permet configurar els productes com col·leccions d'altres productes. Si "
164+"s'afegeix un producte d'aquest tipus en una comanda de venda, tots els "
165+"productes del paquet s'afegiran automàticament (quan es guardi la comanda) "
166+"com a fills del producte principal.\n"
167+"\n"
168+"Aquest mòdul és compatible amb nan_external_prices i conté codi per "
169+"funcionar quan està instal·lat encara que ambdós són encara independents i "
170+"no hi ha dependències entre ells.\n"
171+" "
172+
173+#. module: nan_product_pack
174+#: view:product.product:0
175+#: field:sale.order.line,pack_parent_line_id:0
176+msgid "Pack"
177+msgstr "Paquet"
178+
179+#. module: nan_product_pack
180+#: model:ir.model,name:nan_product_pack.model_product_pack_line
181+msgid "product.pack.line"
182+msgstr "producte.paquet.línea"
183+
184+#. module: nan_product_pack
185+#: constraint:ir.ui.view:0
186+msgid "Invalid XML for View Architecture!"
187+msgstr "XML no vàlid per a la definició de la vista!"
188+
189+#. module: nan_product_pack
190+#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
191+msgid "Product Pack"
192+msgstr "Paquet de productes"
193+
194+#. module: nan_product_pack
195+#: field:product.product,stock_depends:0
196+msgid "Stock depends of components"
197+msgstr "Estoc depen dels components"
198+
199+#. module: nan_product_pack
200+#: help:sale.order.line,pack_parent_line_id:0
201+msgid "The pack that contains this product."
202+msgstr "El paquet que conté aquest producte."
203+
204+#. module: nan_product_pack
205+#: field:sale.order.line,pack_depth:0
206+msgid "Depth"
207+msgstr "Profunditat"
208+
209+#. module: nan_product_pack
210+#: help:product.product,pack_fixed_price:0
211+msgid ""
212+"Mark this field if the public price of the pack should be fixed. Do not mark "
213+"it if the price should be calculated from the sum of the prices of the "
214+"products in the pack."
215+msgstr ""
216+"Marqueu aquest camp si el preu de venda del paquet ha de ser fix. No ho "
217+"marqueu si el preu s'ha de calcular a partir de la suma dels preus dels "
218+"productes del paquet."
219+
220+#. module: nan_product_pack
221+#: field:product.pack.line,quantity:0
222+msgid "Quantity"
223+msgstr "Quantitat"
224+
225+#. module: nan_product_pack
226+#: view:product.product:0
227+#: field:product.product,pack_line_ids:0
228+msgid "Pack Products"
229+msgstr "Productes del paquet"
230+
231+#. module: nan_product_pack
232+#: field:product.pack.line,parent_product_id:0
233+msgid "Parent Product"
234+msgstr "Producte pare"
235+
236+#. module: nan_product_pack
237+#: field:product.product,pack_fixed_price:0
238+msgid "Pack has fixed price"
239+msgstr "El paquet té un preu fix"
240+
241+#. module: nan_product_pack
242+#: view:product.pack.line:0
243+msgid "Pack Product Line"
244+msgstr "Línia de paquet de productes"
245+
246+#. module: nan_product_pack
247+#: help:product.product,pack_line_ids:0
248+msgid "List of products that are part of this pack."
249+msgstr "Llista de productes que formen part del paquet."
250
251=== added file 'product_pack/i18n/de.po'
252--- product_pack/i18n/de.po 1970-01-01 00:00:00 +0000
253+++ product_pack/i18n/de.po 2014-07-07 16:03:26 +0000
254@@ -0,0 +1,145 @@
255+# German translation for openobject-addons
256+# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
257+# This file is distributed under the same license as the openobject-addons package.
258+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
259+#
260+msgid ""
261+msgstr ""
262+"Project-Id-Version: openobject-addons\n"
263+"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
264+"POT-Creation-Date: 2011-01-15 11:45+0000\n"
265+"PO-Revision-Date: 2011-02-15 15:15+0000\n"
266+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
267+"Language-Team: German <de@li.org>\n"
268+"MIME-Version: 1.0\n"
269+"Content-Type: text/plain; charset=UTF-8\n"
270+"Content-Transfer-Encoding: 8bit\n"
271+"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
272+"X-Generator: Launchpad (build 15060)\n"
273+
274+#. module: nan_product_pack
275+#: constraint:ir.model:0
276+msgid ""
277+"The Object name must start with x_ and not contain any special character !"
278+msgstr ""
279+
280+#. module: nan_product_pack
281+#: help:product.product,stock_depends:0
282+msgid "Mark if pack stock is calcualted from component stock"
283+msgstr ""
284+
285+#. module: nan_product_pack
286+#: field:sale.order.line,pack_child_line_ids:0
287+msgid "Lines in pack"
288+msgstr ""
289+
290+#. module: nan_product_pack
291+#: help:sale.order.line,pack_depth:0
292+msgid "Depth of the product if it is part of a pack."
293+msgstr ""
294+
295+#. module: nan_product_pack
296+#: field:product.pack.line,product_id:0
297+msgid "Product"
298+msgstr ""
299+
300+#. module: nan_product_pack
301+#: view:product.pack.line:0
302+msgid "Pack Product Lines"
303+msgstr ""
304+
305+#. module: nan_product_pack
306+#: view:product.product:0
307+msgid ""
308+"If you add products in the 'Pack Products' field, all those products will be "
309+"added automatically when a new quotation or order is created."
310+msgstr ""
311+
312+#. module: nan_product_pack
313+#: model:ir.module.module,description:nan_product_pack.module_meta_information
314+msgid ""
315+"\n"
316+"Allows configuring products as a collection of other products. If such a "
317+"product is added in a sale order, all the products of the pack will be added "
318+"automatically (when storing the order) as children of the pack product.\n"
319+"\n"
320+"The module has been made compatible with nan_external_prices and containts "
321+"code to specifically handle when the module is available but they're still "
322+"independent and there are no dependencies between them.\n"
323+" "
324+msgstr ""
325+
326+#. module: nan_product_pack
327+#: view:product.product:0
328+#: field:sale.order.line,pack_parent_line_id:0
329+msgid "Pack"
330+msgstr ""
331+
332+#. module: nan_product_pack
333+#: model:ir.model,name:nan_product_pack.model_product_pack_line
334+msgid "product.pack.line"
335+msgstr ""
336+
337+#. module: nan_product_pack
338+#: constraint:ir.ui.view:0
339+msgid "Invalid XML for View Architecture!"
340+msgstr ""
341+
342+#. module: nan_product_pack
343+#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
344+msgid "Product Pack"
345+msgstr ""
346+
347+#. module: nan_product_pack
348+#: field:product.product,stock_depends:0
349+msgid "Stock depends of components"
350+msgstr ""
351+
352+#. module: nan_product_pack
353+#: help:sale.order.line,pack_parent_line_id:0
354+msgid "The pack that contains this product."
355+msgstr ""
356+
357+#. module: nan_product_pack
358+#: field:sale.order.line,pack_depth:0
359+msgid "Depth"
360+msgstr ""
361+
362+#. module: nan_product_pack
363+#: help:product.product,pack_fixed_price:0
364+msgid ""
365+"Mark this field if the public price of the pack should be fixed. Do not mark "
366+"it if the price should be calculated from the sum of the prices of the "
367+"products in the pack."
368+msgstr ""
369+
370+#. module: nan_product_pack
371+#: field:product.pack.line,quantity:0
372+msgid "Quantity"
373+msgstr ""
374+
375+#. module: nan_product_pack
376+#: view:product.product:0
377+#: field:product.product,pack_line_ids:0
378+msgid "Pack Products"
379+msgstr ""
380+
381+#. module: nan_product_pack
382+#: field:product.pack.line,parent_product_id:0
383+msgid "Parent Product"
384+msgstr ""
385+
386+#. module: nan_product_pack
387+#: field:product.product,pack_fixed_price:0
388+msgid "Pack has fixed price"
389+msgstr ""
390+
391+#. module: nan_product_pack
392+#: view:product.pack.line:0
393+msgid "Pack Product Line"
394+msgstr ""
395+
396+#. module: nan_product_pack
397+#: help:product.product,pack_line_ids:0
398+msgid "List of products that are part of this pack."
399+msgstr ""
400
401=== added file 'product_pack/i18n/es.po'
402--- product_pack/i18n/es.po 1970-01-01 00:00:00 +0000
403+++ product_pack/i18n/es.po 2014-07-07 16:03:26 +0000
404@@ -0,0 +1,164 @@
405+# Translation of OpenERP Server.
406+# This file contains the translation of the following modules:
407+# * nan_product_pack
408+#
409+# Albert Cervera i Areny <albert@nan-tic.com>, 2009.
410+msgid ""
411+msgstr ""
412+"Project-Id-Version: OpenERP Server 5.0.6\n"
413+"Report-Msgid-Bugs-To: support@openerp.com\n"
414+"POT-Creation-Date: 2011-01-15 11:45+0000\n"
415+"PO-Revision-Date: 2011-02-15 15:15+0000\n"
416+"Last-Translator: Jordi Esteve (Zikzakmedia) <jesteve@zikzakmedia.com>\n"
417+"Language-Team: Catalan <kde-i18n-ca@kde.org>\n"
418+"MIME-Version: 1.0\n"
419+"Content-Type: text/plain; charset=UTF-8\n"
420+"Content-Transfer-Encoding: 8bit\n"
421+"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
422+"X-Generator: Launchpad (build 15060)\n"
423+
424+#. module: nan_product_pack
425+#: constraint:ir.model:0
426+msgid ""
427+"The Object name must start with x_ and not contain any special character !"
428+msgstr ""
429+"¡El nombre del objeto debe empezar con x_ y no contener ningún carácter "
430+"especial!"
431+
432+#. module: nan_product_pack
433+#: help:product.product,stock_depends:0
434+msgid "Mark if pack stock is calcualted from component stock"
435+msgstr ""
436+"Marque este campo si el stock del pack se calcula a partir del stock de los "
437+"componentes."
438+
439+#. module: nan_product_pack
440+#: field:sale.order.line,pack_child_line_ids:0
441+msgid "Lines in pack"
442+msgstr "Líneas en el pack"
443+
444+#. module: nan_product_pack
445+#: help:sale.order.line,pack_depth:0
446+msgid "Depth of the product if it is part of a pack."
447+msgstr "Profundidad del producto si forma parte de un pack."
448+
449+#. module: nan_product_pack
450+#: field:product.pack.line,product_id:0
451+msgid "Product"
452+msgstr "Producto"
453+
454+#. module: nan_product_pack
455+#: view:product.pack.line:0
456+msgid "Pack Product Lines"
457+msgstr "Líneas del pack de productos"
458+
459+#. module: nan_product_pack
460+#: view:product.product:0
461+msgid ""
462+"If you add products in the 'Pack Products' field, all those products will be "
463+"added automatically when a new quotation or order is created."
464+msgstr ""
465+"Si añade productos en el campo \"Pack de productos\", todos los productos se "
466+"añadirán automáticamente cuando cree un nuevo presupuesto o pedido."
467+
468+#. module: nan_product_pack
469+#: model:ir.module.module,description:nan_product_pack.module_meta_information
470+msgid ""
471+"\n"
472+"Allows configuring products as a collection of other products. If such a "
473+"product is added in a sale order, all the products of the pack will be added "
474+"automatically (when storing the order) as children of the pack product.\n"
475+"\n"
476+"The module has been made compatible with nan_external_prices and containts "
477+"code to specifically handle when the module is available but they're still "
478+"independent and there are no dependencies between them.\n"
479+" "
480+msgstr ""
481+"\n"
482+"Permite configurar los productos como colecciones de otros productos. Si se "
483+"añade un producto de este tipo en un pedido de venta, todos los productos "
484+"del pack se añadirán automáticamente (cuando se guarde el pedido) como hijos "
485+"del producto principal.\n"
486+"\n"
487+"Este módulo es compatible con nan_external_prices y contiene código para "
488+"funcionar cuando está instalado aunque ambos son todavía independientes y no "
489+"hay dependencias entre ellos.\n"
490+" "
491+
492+#. module: nan_product_pack
493+#: view:product.product:0
494+#: field:sale.order.line,pack_parent_line_id:0
495+msgid "Pack"
496+msgstr "Pack"
497+
498+#. module: nan_product_pack
499+#: model:ir.model,name:nan_product_pack.model_product_pack_line
500+msgid "product.pack.line"
501+msgstr "producto.pack.línea"
502+
503+#. module: nan_product_pack
504+#: constraint:ir.ui.view:0
505+msgid "Invalid XML for View Architecture!"
506+msgstr "¡XML no válido para la definición de la vista!"
507+
508+#. module: nan_product_pack
509+#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
510+msgid "Product Pack"
511+msgstr "Pack de productos"
512+
513+#. module: nan_product_pack
514+#: field:product.product,stock_depends:0
515+msgid "Stock depends of components"
516+msgstr "Stock depende de los componentes"
517+
518+#. module: nan_product_pack
519+#: help:sale.order.line,pack_parent_line_id:0
520+msgid "The pack that contains this product."
521+msgstr "El pack que contiene este producto."
522+
523+#. module: nan_product_pack
524+#: field:sale.order.line,pack_depth:0
525+msgid "Depth"
526+msgstr "Profundidad"
527+
528+#. module: nan_product_pack
529+#: help:product.product,pack_fixed_price:0
530+msgid ""
531+"Mark this field if the public price of the pack should be fixed. Do not mark "
532+"it if the price should be calculated from the sum of the prices of the "
533+"products in the pack."
534+msgstr ""
535+"Marque este campo si el precio de venta del pack tiene que ser fijo. No lo "
536+"marque si el precio se tiene que calcular a partir de la suma de los precios "
537+"de los productos del pack."
538+
539+#. module: nan_product_pack
540+#: field:product.pack.line,quantity:0
541+msgid "Quantity"
542+msgstr "Cantidad"
543+
544+#. module: nan_product_pack
545+#: view:product.product:0
546+#: field:product.product,pack_line_ids:0
547+msgid "Pack Products"
548+msgstr "Productos del pack"
549+
550+#. module: nan_product_pack
551+#: field:product.pack.line,parent_product_id:0
552+msgid "Parent Product"
553+msgstr "Producto padre"
554+
555+#. module: nan_product_pack
556+#: field:product.product,pack_fixed_price:0
557+msgid "Pack has fixed price"
558+msgstr "El pack tiene un precio fijo"
559+
560+#. module: nan_product_pack
561+#: view:product.pack.line:0
562+msgid "Pack Product Line"
563+msgstr "Línea de pack de productos"
564+
565+#. module: nan_product_pack
566+#: help:product.product,pack_line_ids:0
567+msgid "List of products that are part of this pack."
568+msgstr "Lista de productos que forman parte del pack."
569
570=== added file 'product_pack/i18n/it.po'
571--- product_pack/i18n/it.po 1970-01-01 00:00:00 +0000
572+++ product_pack/i18n/it.po 2014-07-07 16:03:26 +0000
573@@ -0,0 +1,164 @@
574+# Italian translation for openobject-addons
575+# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
576+# This file is distributed under the same license as the openobject-addons package.
577+# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
578+#
579+msgid ""
580+msgstr ""
581+"Project-Id-Version: openobject-addons\n"
582+"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
583+"POT-Creation-Date: 2011-01-15 11:45+0000\n"
584+"PO-Revision-Date: 2011-05-04 08:52+0000\n"
585+"Last-Translator: Lorenzo Battistini - Agile BG - Domsense "
586+"<lorenzo.battistini@agilebg.com>\n"
587+"Language-Team: Italian <it@li.org>\n"
588+"MIME-Version: 1.0\n"
589+"Content-Type: text/plain; charset=UTF-8\n"
590+"Content-Transfer-Encoding: 8bit\n"
591+"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
592+"X-Generator: Launchpad (build 15060)\n"
593+
594+#. module: nan_product_pack
595+#: constraint:ir.model:0
596+msgid ""
597+"The Object name must start with x_ and not contain any special character !"
598+msgstr ""
599+"Il nome dell'oggetto deve iniziare con x_ e non deve contenere alcun "
600+"carattere speciale !"
601+
602+#. module: nan_product_pack
603+#: help:product.product,stock_depends:0
604+msgid "Mark if pack stock is calcualted from component stock"
605+msgstr ""
606+"Selezionare se la giacenza del kit è calcolata sulla base della giacenza dei "
607+"componenti"
608+
609+#. module: nan_product_pack
610+#: field:sale.order.line,pack_child_line_ids:0
611+msgid "Lines in pack"
612+msgstr "Righe nel kit"
613+
614+#. module: nan_product_pack
615+#: help:sale.order.line,pack_depth:0
616+msgid "Depth of the product if it is part of a pack."
617+msgstr "Profondità del prodotto se è parte di un kit"
618+
619+#. module: nan_product_pack
620+#: field:product.pack.line,product_id:0
621+msgid "Product"
622+msgstr "Prodotto"
623+
624+#. module: nan_product_pack
625+#: view:product.pack.line:0
626+msgid "Pack Product Lines"
627+msgstr "Righe Kit"
628+
629+#. module: nan_product_pack
630+#: view:product.product:0
631+msgid ""
632+"If you add products in the 'Pack Products' field, all those products will be "
633+"added automatically when a new quotation or order is created."
634+msgstr ""
635+"Se si aggiungono prodotti nel campo 'Prodotti Kit', tutti quei prodotti "
636+"saranno automaticamente aggiunti alla creazione di un preventivo o ordine."
637+
638+#. module: nan_product_pack
639+#: model:ir.module.module,description:nan_product_pack.module_meta_information
640+msgid ""
641+"\n"
642+"Allows configuring products as a collection of other products. If such a "
643+"product is added in a sale order, all the products of the pack will be added "
644+"automatically (when storing the order) as children of the pack product.\n"
645+"\n"
646+"The module has been made compatible with nan_external_prices and containts "
647+"code to specifically handle when the module is available but they're still "
648+"independent and there are no dependencies between them.\n"
649+" "
650+msgstr ""
651+"\n"
652+"Permette di configurare prosotti come collezioni di altri prodotti. Se uno "
653+"di questi prodotti viene aggiunto ad un ordine di vendita, tutti i prodotti "
654+"nel kit saranno aggiunti automaticamente (al salvataggio dell'ordine) come "
655+"figli del prodotto kit.\n"
656+"\n"
657+"Il modulo è stato reso compatibile con nan_external_prices e contiene il "
658+"codice per gestire entrambi i moduli pur mantenendoli indipendenti.\n"
659+" "
660+
661+#. module: nan_product_pack
662+#: view:product.product:0
663+#: field:sale.order.line,pack_parent_line_id:0
664+msgid "Pack"
665+msgstr "Kit"
666+
667+#. module: nan_product_pack
668+#: model:ir.model,name:nan_product_pack.model_product_pack_line
669+msgid "product.pack.line"
670+msgstr "product.pack.line"
671+
672+#. module: nan_product_pack
673+#: constraint:ir.ui.view:0
674+msgid "Invalid XML for View Architecture!"
675+msgstr "XML non valido per l'architettura della vista"
676+
677+#. module: nan_product_pack
678+#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
679+msgid "Product Pack"
680+msgstr "Kit prodotto"
681+
682+#. module: nan_product_pack
683+#: field:product.product,stock_depends:0
684+msgid "Stock depends of components"
685+msgstr "La giacenza si basa sui componenti"
686+
687+#. module: nan_product_pack
688+#: help:sale.order.line,pack_parent_line_id:0
689+msgid "The pack that contains this product."
690+msgstr "Il kit che contiene questo prodotto."
691+
692+#. module: nan_product_pack
693+#: field:sale.order.line,pack_depth:0
694+msgid "Depth"
695+msgstr "Profondità"
696+
697+#. module: nan_product_pack
698+#: help:product.product,pack_fixed_price:0
699+msgid ""
700+"Mark this field if the public price of the pack should be fixed. Do not mark "
701+"it if the price should be calculated from the sum of the prices of the "
702+"products in the pack."
703+msgstr ""
704+"Selezionare questo campo se il prezzo pubblico del kit debba essere fisso. "
705+"Non selezionarlo se il prezzo debba essere calcolato sulla base dei prezzi "
706+"dei prodotti nel kit."
707+
708+#. module: nan_product_pack
709+#: field:product.pack.line,quantity:0
710+msgid "Quantity"
711+msgstr "Quantità"
712+
713+#. module: nan_product_pack
714+#: view:product.product:0
715+#: field:product.product,pack_line_ids:0
716+msgid "Pack Products"
717+msgstr "Prodotti kit"
718+
719+#. module: nan_product_pack
720+#: field:product.pack.line,parent_product_id:0
721+msgid "Parent Product"
722+msgstr "Prodotto genitore"
723+
724+#. module: nan_product_pack
725+#: field:product.product,pack_fixed_price:0
726+msgid "Pack has fixed price"
727+msgstr "Il kit ha prezzo fisso"
728+
729+#. module: nan_product_pack
730+#: view:product.pack.line:0
731+msgid "Pack Product Line"
732+msgstr "Riga prodotto kit"
733+
734+#. module: nan_product_pack
735+#: help:product.product,pack_line_ids:0
736+msgid "List of products that are part of this pack."
737+msgstr "Lista dei prodotti che sono parte di questo kit."
738
739=== added file 'product_pack/i18n/product_pack.pot'
740--- product_pack/i18n/product_pack.pot 1970-01-01 00:00:00 +0000
741+++ product_pack/i18n/product_pack.pot 2014-07-07 16:03:26 +0000
742@@ -0,0 +1,155 @@
743+# Translation of OpenERP Server.
744+# This file contains the translation of the following modules:
745+# * product_pack
746+#
747+msgid ""
748+msgstr ""
749+"Project-Id-Version: OpenERP Server 7.0\n"
750+"Report-Msgid-Bugs-To: \n"
751+"POT-Creation-Date: 2013-11-19 14:48+0000\n"
752+"PO-Revision-Date: 2013-11-19 14:48+0000\n"
753+"Last-Translator: <>\n"
754+"Language-Team: \n"
755+"MIME-Version: 1.0\n"
756+"Content-Type: text/plain; charset=UTF-8\n"
757+"Content-Transfer-Encoding: \n"
758+"Plural-Forms: \n"
759+
760+#. module: product_pack
761+#: model:ir.model,name:product_pack.model_purchase_order_line
762+msgid "Purchase Order Line"
763+msgstr "Purchase Order Line"
764+
765+#. module: product_pack
766+#: help:product.product,stock_depends:0
767+msgid "Mark if pack stock is calcualted from component stock"
768+msgstr "Mark if pack stock is calcualted from component stock"
769+
770+#. module: product_pack
771+#: field:purchase.order.line,pack_child_line_ids:0
772+#: field:sale.order.line,pack_child_line_ids:0
773+msgid "Lines in pack"
774+msgstr "Lines in pack"
775+
776+#. module: product_pack
777+#: help:purchase.order.line,pack_depth:0
778+#: help:sale.order.line,pack_depth:0
779+msgid "Depth of the product if it is part of a pack."
780+msgstr "Depth of the product if it is part of a pack."
781+
782+#. module: product_pack
783+#: model:ir.model,name:product_pack.model_product_product
784+#: field:product.pack.line,product_id:0
785+msgid "Product"
786+msgstr "Product"
787+
788+#. module: product_pack
789+#: view:product.pack.line:0
790+msgid "Pack Product Lines"
791+msgstr "Pack Product Lines"
792+
793+#. module: product_pack
794+#: view:product.product:0
795+msgid "If you add products in the 'Pack Products' field, all those products will be added automatically when a new quotation or order is created."
796+msgstr "If you add products in the 'Pack Products' field, all those products will be added automatically when a new quotation or order is created."
797+
798+#. module: product_pack
799+#: help:purchase.order.line,sequence:0
800+msgid "Gives the sequence order when displaying a list of\n"
801+" purchase order lines. "
802+msgstr "Gives the sequence order when displaying a list of\n"
803+" purchase order lines. "
804+
805+#. module: product_pack
806+#: view:product.product:0
807+#: field:purchase.order.line,pack_parent_line_id:0
808+#: field:sale.order.line,pack_parent_line_id:0
809+msgid "Pack"
810+msgstr "Pack"
811+
812+#. module: product_pack
813+#: model:ir.model,name:product_pack.model_product_pack_line
814+msgid "product.pack.line"
815+msgstr "product.pack.line"
816+
817+#. module: product_pack
818+#: help:product.product,pack_fixed_price:0
819+msgid "\n"
820+" Mark this field if the public price of the pack should be fixed.\n"
821+" Do not mark it if the price should be calculated from the sum of\n"
822+" the prices of the products in the pack.\n"
823+" "
824+msgstr "\n"
825+" Mark this field if the public price of the pack should be fixed.\n"
826+" Do not mark it if the price should be calculated from the sum of\n"
827+" the prices of the products in the pack.\n"
828+" "
829+
830+#. module: product_pack
831+#: field:product.product,stock_depends:0
832+msgid "Stock depends of components"
833+msgstr "Stock depends of components"
834+
835+#. module: product_pack
836+#: model:ir.model,name:product_pack.model_purchase_order
837+msgid "Purchase Order"
838+msgstr "Purchase Order"
839+
840+#. module: product_pack
841+#: field:purchase.order.line,pack_depth:0
842+#: field:sale.order.line,pack_depth:0
843+msgid "Depth"
844+msgstr "Depth"
845+
846+#. module: product_pack
847+#: help:purchase.order.line,pack_parent_line_id:0
848+#: help:sale.order.line,pack_parent_line_id:0
849+msgid "The pack that contains this product."
850+msgstr "The pack that contains this product."
851+
852+#. module: product_pack
853+#: field:product.pack.line,quantity:0
854+msgid "Quantity"
855+msgstr "Quantity"
856+
857+#. module: product_pack
858+#: view:product.product:0
859+#: field:product.product,pack_line_ids:0
860+msgid "Pack Products"
861+msgstr "Pack Products"
862+
863+#. module: product_pack
864+#: field:purchase.order.line,sequence:0
865+msgid "Sequence"
866+msgstr "Sequence"
867+
868+#. module: product_pack
869+#: field:product.pack.line,parent_product_id:0
870+msgid "Parent Product"
871+msgstr "Parent Product"
872+
873+#. module: product_pack
874+#: field:product.product,pack_fixed_price:0
875+msgid "Pack has fixed price"
876+msgstr "Pack has fixed price"
877+
878+#. module: product_pack
879+#: model:ir.model,name:product_pack.model_sale_order
880+msgid "Sales Order"
881+msgstr "Sales Order"
882+
883+#. module: product_pack
884+#: view:product.pack.line:0
885+msgid "Pack Product Line"
886+msgstr "Pack Product Line"
887+
888+#. module: product_pack
889+#: model:ir.model,name:product_pack.model_sale_order_line
890+msgid "Sales Order Line"
891+msgstr "Sales Order Line"
892+
893+#. module: product_pack
894+#: help:product.product,pack_line_ids:0
895+msgid "List of products that are part of this pack."
896+msgstr "List of products that are part of this pack."
897+
898
899=== added file 'product_pack/i18n/pt.po'
900--- product_pack/i18n/pt.po 1970-01-01 00:00:00 +0000
901+++ product_pack/i18n/pt.po 2014-07-07 16:03:26 +0000
902@@ -0,0 +1,149 @@
903+# Portuguese translation for openobject-addons
904+# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
905+# This file is distributed under the same license as the openobject-addons package.
906+# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
907+#
908+msgid ""
909+msgstr ""
910+"Project-Id-Version: openobject-addons\n"
911+"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
912+"POT-Creation-Date: 2011-01-15 11:45+0000\n"
913+"PO-Revision-Date: 2011-02-15 15:15+0000\n"
914+"Last-Translator: Luniz <luniz52@hotmail.com>\n"
915+"Language-Team: Portuguese <pt@li.org>\n"
916+"MIME-Version: 1.0\n"
917+"Content-Type: text/plain; charset=UTF-8\n"
918+"Content-Transfer-Encoding: 8bit\n"
919+"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
920+"X-Generator: Launchpad (build 15060)\n"
921+
922+#. module: nan_product_pack
923+#: constraint:ir.model:0
924+msgid ""
925+"The Object name must start with x_ and not contain any special character !"
926+msgstr ""
927+"O nome do Objecto deve começar com x_ e não pode conter nenhum caracter "
928+"especial !"
929+
930+#. module: nan_product_pack
931+#: help:product.product,stock_depends:0
932+msgid "Mark if pack stock is calcualted from component stock"
933+msgstr ""
934+
935+#. module: nan_product_pack
936+#: field:sale.order.line,pack_child_line_ids:0
937+msgid "Lines in pack"
938+msgstr "Linhas em embalagens"
939+
940+#. module: nan_product_pack
941+#: help:sale.order.line,pack_depth:0
942+msgid "Depth of the product if it is part of a pack."
943+msgstr "Profundidade do produto se ele faz parte da embalagem."
944+
945+#. module: nan_product_pack
946+#: field:product.pack.line,product_id:0
947+msgid "Product"
948+msgstr "Produto"
949+
950+#. module: nan_product_pack
951+#: view:product.pack.line:0
952+msgid "Pack Product Lines"
953+msgstr "Linhas de Embalagem de Produto"
954+
955+#. module: nan_product_pack
956+#: view:product.product:0
957+msgid ""
958+"If you add products in the 'Pack Products' field, all those products will be "
959+"added automatically when a new quotation or order is created."
960+msgstr ""
961+"Se adicionar o produto no campo \"Embalagem de Produtos ', todos os produtos "
962+"serão adicionados automaticamente quando uma nova ordem de cotação é criado."
963+
964+#. module: nan_product_pack
965+#: model:ir.module.module,description:nan_product_pack.module_meta_information
966+msgid ""
967+"\n"
968+"Allows configuring products as a collection of other products. If such a "
969+"product is added in a sale order, all the products of the pack will be added "
970+"automatically (when storing the order) as children of the pack product.\n"
971+"\n"
972+"The module has been made compatible with nan_external_prices and containts "
973+"code to specifically handle when the module is available but they're still "
974+"independent and there are no dependencies between them.\n"
975+" "
976+msgstr ""
977+
978+#. module: nan_product_pack
979+#: view:product.product:0
980+#: field:sale.order.line,pack_parent_line_id:0
981+msgid "Pack"
982+msgstr "Embalagem"
983+
984+#. module: nan_product_pack
985+#: model:ir.model,name:nan_product_pack.model_product_pack_line
986+msgid "product.pack.line"
987+msgstr "product.pack.line"
988+
989+#. module: nan_product_pack
990+#: constraint:ir.ui.view:0
991+msgid "Invalid XML for View Architecture!"
992+msgstr "XML Inválido para a Aquitectura de Vista!"
993+
994+#. module: nan_product_pack
995+#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
996+msgid "Product Pack"
997+msgstr "Embalagem de Produto"
998+
999+#. module: nan_product_pack
1000+#: field:product.product,stock_depends:0
1001+msgid "Stock depends of components"
1002+msgstr ""
1003+
1004+#. module: nan_product_pack
1005+#: help:sale.order.line,pack_parent_line_id:0
1006+msgid "The pack that contains this product."
1007+msgstr "A embalagem que contém esse produto."
1008+
1009+#. module: nan_product_pack
1010+#: field:sale.order.line,pack_depth:0
1011+msgid "Depth"
1012+msgstr "Profundidade"
1013+
1014+#. module: nan_product_pack
1015+#: help:product.product,pack_fixed_price:0
1016+msgid ""
1017+"Mark this field if the public price of the pack should be fixed. Do not mark "
1018+"it if the price should be calculated from the sum of the prices of the "
1019+"products in the pack."
1020+msgstr ""
1021+
1022+#. module: nan_product_pack
1023+#: field:product.pack.line,quantity:0
1024+msgid "Quantity"
1025+msgstr "Quantidade"
1026+
1027+#. module: nan_product_pack
1028+#: view:product.product:0
1029+#: field:product.product,pack_line_ids:0
1030+msgid "Pack Products"
1031+msgstr "Embalagem de Produtos"
1032+
1033+#. module: nan_product_pack
1034+#: field:product.pack.line,parent_product_id:0
1035+msgid "Parent Product"
1036+msgstr "Produto Ascendente"
1037+
1038+#. module: nan_product_pack
1039+#: field:product.product,pack_fixed_price:0
1040+msgid "Pack has fixed price"
1041+msgstr "A Embalagem tem preço fixado"
1042+
1043+#. module: nan_product_pack
1044+#: view:product.pack.line:0
1045+msgid "Pack Product Line"
1046+msgstr "Linha de Embalagem de Produto"
1047+
1048+#. module: nan_product_pack
1049+#: help:product.product,pack_line_ids:0
1050+msgid "List of products that are part of this pack."
1051+msgstr "Lista dos produtos que fazem parte desta embalagem."
1052
1053=== added file 'product_pack/pack.py'
1054--- product_pack/pack.py 1970-01-01 00:00:00 +0000
1055+++ product_pack/pack.py 2014-07-07 16:03:26 +0000
1056@@ -0,0 +1,484 @@
1057+# -*- coding: utf-8 -*-
1058+###############################################################################
1059+#
1060+# Copyright (c) 2009 Angel Alvarez - NaN (http://www.nan-tic.com)
1061+# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
1062+# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
1063+#
1064+# This program is free software: you can redistribute it and/or modify
1065+# it under the terms of the GNU Affero General Public License as published
1066+# by the Free Software Foundation, either version 3 of the License, or
1067+# (at your option) any later version.
1068+#
1069+# This program is distributed in the hope that it will be useful,
1070+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1071+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1072+# GNU Affero General Public License for more details.
1073+#
1074+# You should have received a copy of the GNU Affero General Public License
1075+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1076+#
1077+###############################################################################
1078+
1079+import math
1080+from openerp.osv import fields, orm
1081+
1082+
1083+class product_pack(orm.Model):
1084+ _name = 'product.pack.line'
1085+ _rec_name = 'product_id'
1086+ _columns = {
1087+ 'parent_product_id': fields.many2one(
1088+ 'product.product', 'Parent Product',
1089+ ondelete='cascade', required=True
1090+ ),
1091+ 'quantity': fields.float('Quantity', required=True),
1092+ 'product_id': fields.many2one(
1093+ 'product.product', 'Product', required=True
1094+ ),
1095+ }
1096+
1097+
1098+class product_product(orm.Model):
1099+ _inherit = 'product.product'
1100+ _columns = {
1101+ 'stock_depends': fields.boolean(
1102+ 'Stock depends of components',
1103+ help='Mark if pack stock is calcualted from component stock'
1104+ ),
1105+ 'pack_fixed_price': fields.boolean(
1106+ 'Pack has fixed price',
1107+ help="""
1108+ Mark this field if the public price of the pack should be fixed.
1109+ Do not mark it if the price should be calculated from the sum of
1110+ the prices of the products in the pack.
1111+ """
1112+ ),
1113+ 'pack_line_ids': fields.one2many(
1114+ 'product.pack.line', 'parent_product_id', 'Pack Products',
1115+ help='List of products that are part of this pack.'
1116+ ),
1117+ }
1118+
1119+ def get_product_available(self, cr, uid, ids, context=None):
1120+ """
1121+ Calulate stock for packs
1122+ :return: maximum stock that lets complete pack
1123+ """
1124+ result = {}
1125+ for product in self.browse(cr, uid, ids, context=context):
1126+ stock = super(product_product, self).get_product_available(
1127+ cr, uid, [product.id], context=context)
1128+
1129+ # Check if product stock depends on it's subproducts stock.
1130+ if not product.stock_depends:
1131+ result[product.id] = stock[product.id]
1132+ continue
1133+
1134+ first_subproduct = True
1135+ pack_stock = 0
1136+
1137+ # Check if the pack has subproducts
1138+ if product.pack_line_ids:
1139+
1140+ # Take the stock/virtual stock of all subproducts
1141+ subproducts_stock = self.get_product_available(
1142+ cr,
1143+ uid,
1144+ [line.product_id.id for line in product.pack_line_ids],
1145+ context=context
1146+ )
1147+
1148+ """ Go over all subproducts, take quantity needed for the pack
1149+ and its available stock """
1150+ for subproduct in product.pack_line_ids:
1151+
1152+ # if subproduct is a service don't calculate the stock
1153+ if subproduct.product_id.type == 'service':
1154+ continue
1155+ if first_subproduct:
1156+ subproduct_quantity = subproduct.quantity
1157+ subproduct_stock = (
1158+ subproducts_stock[subproduct.product_id.id])
1159+ if subproduct_quantity == 0:
1160+ continue
1161+
1162+ """ Calculate real stock for current pack from the
1163+ subproduct stock and needed quantity """
1164+ pack_stock = math.floor(
1165+ subproduct_stock / subproduct_quantity)
1166+ first_subproduct = False
1167+ continue
1168+
1169+ # Take the info of the next subproduct
1170+ subproduct_quantity_next = subproduct.quantity
1171+ subproduct_stock_next = (
1172+ subproducts_stock[subproduct.product_id.id])
1173+
1174+ if (
1175+ subproduct_quantity_next == 0
1176+ or subproduct_quantity_next == 0.0
1177+ ):
1178+ continue
1179+
1180+ pack_stock_next = math.floor(
1181+ subproduct_stock_next / subproduct_quantity_next)
1182+
1183+ # compare the stock of a subproduct and the next subproduct
1184+ if pack_stock_next < pack_stock:
1185+ pack_stock = pack_stock_next
1186+
1187+ # result is the minimum stock of all subproducts
1188+ result[product.id] = pack_stock
1189+ else:
1190+ result[product.id] = stock[product.id]
1191+ return result
1192+
1193+
1194+class sale_order_line(orm.Model):
1195+ _inherit = 'sale.order.line'
1196+ _columns = {
1197+ 'pack_depth': fields.integer(
1198+ 'Depth', required=True,
1199+ help='Depth of the product if it is part of a pack.'
1200+ ),
1201+ 'pack_parent_line_id': fields.many2one(
1202+ 'sale.order.line', 'Pack',
1203+ help='The pack that contains this product.'
1204+ ),
1205+ 'pack_child_line_ids': fields.one2many(
1206+ 'sale.order.line', 'pack_parent_line_id', 'Lines in pack'),
1207+ }
1208+ _defaults = {
1209+ 'pack_depth': 0,
1210+ }
1211+
1212+
1213+class sale_order(orm.Model):
1214+ _inherit = 'sale.order'
1215+
1216+ def create(self, cr, uid, vals, context=None):
1217+ result = super(sale_order, self).create(cr, uid, vals, context)
1218+ self.expand_packs(cr, uid, [result], context)
1219+ return result
1220+
1221+ def write(self, cr, uid, ids, vals, context=None):
1222+ result = super(sale_order, self).write(cr, uid, ids, vals, context)
1223+ self.expand_packs(cr, uid, ids, context)
1224+ return result
1225+
1226+ def expand_packs(self, cr, uid, ids, context={}, depth=1):
1227+ if type(ids) in [int, long]:
1228+ ids = [ids]
1229+ if depth == 10:
1230+ return
1231+ updated_orders = []
1232+ for order in self.browse(cr, uid, ids, context):
1233+
1234+ fiscal_position = (
1235+ order.fiscal_position
1236+ and self.pool.get('account.fiscal.position').browse(
1237+ cr, uid, order.fiscal_position.id, context
1238+ )
1239+ or False
1240+ )
1241+ """
1242+ The reorder variable is used to ensure lines of the same pack go
1243+ right after their parent. What the algorithm does is check if the
1244+ previous item had children. As children items must go right after
1245+ the parent if the line we're evaluating doesn't have a parent it
1246+ means it's a new item (and probably has the default 10 sequence
1247+ number - unless the appropiate c2c_sale_sequence module is
1248+ installed). In this case we mark the item for reordering and
1249+ evaluate the next one. Note that as the item is not evaluated and
1250+ it might have to be expanded it's put on the queue for another
1251+ iteration (it's simple and works well). Once the next item has been
1252+ evaluated the sequence of the item marked for reordering is updated
1253+ with the next value.
1254+ """
1255+ sequence = -1
1256+ reorder = []
1257+ last_had_children = False
1258+ for line in order.order_line:
1259+ if last_had_children and not line.pack_parent_line_id:
1260+ reorder.append(line.id)
1261+ if (
1262+ line.product_id.pack_line_ids
1263+ and not order.id in updated_orders
1264+ ):
1265+ updated_orders.append(order.id)
1266+ continue
1267+
1268+ sequence += 1
1269+
1270+ if sequence > line.sequence:
1271+ self.pool.get('sale.order.line').write(
1272+ cr, uid, [line.id], {'sequence': sequence, }, context)
1273+ else:
1274+ sequence = line.sequence
1275+
1276+ if line.state != 'draft':
1277+ continue
1278+ if not line.product_id:
1279+ continue
1280+
1281+ """ If pack was already expanded (in another create/write
1282+ operation or in a previous iteration) don't do it again. """
1283+ if line.pack_child_line_ids:
1284+ last_had_children = True
1285+ continue
1286+ last_had_children = False
1287+
1288+ for subline in line.product_id.pack_line_ids:
1289+ sequence += 1
1290+
1291+ subproduct = subline.product_id
1292+ quantity = subline.quantity * line.product_uom_qty
1293+
1294+ if line.product_id.pack_fixed_price:
1295+ price = 0.0
1296+ discount = 0.0
1297+ else:
1298+ pricelist = order.pricelist_id.id
1299+ price = self.pool.get('product.pricelist').price_get(
1300+ cr, uid, [pricelist], subproduct.id, quantity,
1301+ order.partner_id.id, {
1302+ 'uom': subproduct.uom_id.id,
1303+ 'date': order.date_order,
1304+ }
1305+ )[pricelist]
1306+ discount = line.discount
1307+
1308+ # Obtain product name in partner's language
1309+ ctx = {'lang': order.partner_id.lang}
1310+ subproduct_name = self.pool.get('product.product').browse(
1311+ cr, uid, subproduct.id, ctx).name
1312+
1313+ tax_ids = self.pool.get('account.fiscal.position').map_tax(
1314+ cr, uid, fiscal_position, subproduct.taxes_id)
1315+
1316+ if subproduct.uos_id:
1317+ uos_id = subproduct.uos_id.id
1318+ uos_qty = quantity * subproduct.uos_coeff
1319+ else:
1320+ uos_id = False
1321+ uos_qty = quantity
1322+
1323+ vals = {
1324+ 'order_id': order.id,
1325+ 'name': '%s%s' % (
1326+ '> ' * (line.pack_depth+1), subproduct_name
1327+ ),
1328+ 'sequence': sequence,
1329+ 'delay': subproduct.sale_delay or 0.0,
1330+ 'product_id': subproduct.id,
1331+ 'procurement_id': (
1332+ line.procurement_id
1333+ and line.procurement_id.id
1334+ or False
1335+ ),
1336+ 'price_unit': price,
1337+ 'tax_id': [(6, 0, tax_ids)],
1338+ 'type': subproduct.procure_method,
1339+ 'property_ids': [(6, 0, [])],
1340+ 'address_allotment_id': False,
1341+ 'product_uom_qty': quantity,
1342+ 'product_uom': subproduct.uom_id.id,
1343+ 'product_uos_qty': uos_qty,
1344+ 'product_uos': uos_id,
1345+ 'product_packaging': False,
1346+ 'move_ids': [(6, 0, [])],
1347+ 'discount': discount,
1348+ 'number_packages': False,
1349+ 'notes': False,
1350+ 'th_weight': False,
1351+ 'state': 'draft',
1352+ 'pack_parent_line_id': line.id,
1353+ 'pack_depth': line.pack_depth + 1,
1354+ }
1355+
1356+ """ It's a control for the case that the
1357+ nan_external_prices was installed with the product pack """
1358+ if 'prices_used' in line:
1359+ vals['prices_used'] = line.prices_used
1360+
1361+ self.pool.get('sale.order.line').create(
1362+ cr, uid, vals, context)
1363+ if not order.id in updated_orders:
1364+ updated_orders.append(order.id)
1365+
1366+ for id in reorder:
1367+ sequence += 1
1368+ self.pool.get('sale.order.line').write(
1369+ cr, uid, [id], {'sequence': sequence, }, context)
1370+
1371+ if updated_orders:
1372+ """ Try to expand again all those orders that had a pack in this
1373+ iteration. This way we support packs inside other packs. """
1374+ self.expand_packs(cr, uid, ids, context, depth + 1)
1375+ return
1376+
1377+
1378+class purchase_order_line(orm.Model):
1379+ _inherit = 'purchase.order.line'
1380+ _columns = {
1381+ 'sequence': fields.integer(
1382+ 'Sequence',
1383+ help="""Gives the sequence order when displaying a list of
1384+ purchase order lines. """
1385+ ),
1386+ 'pack_depth': fields.integer(
1387+ 'Depth', required=True,
1388+ help='Depth of the product if it is part of a pack.'
1389+ ),
1390+ 'pack_parent_line_id': fields.many2one(
1391+ 'purchase.order.line', 'Pack',
1392+ help='The pack that contains this product.'
1393+ ),
1394+ 'pack_child_line_ids': fields.one2many(
1395+ 'purchase.order.line', 'pack_parent_line_id', 'Lines in pack'
1396+ ),
1397+ }
1398+ _defaults = {
1399+ 'pack_depth': 0,
1400+ }
1401+
1402+
1403+class purchase_order(orm.Model):
1404+ _inherit = 'purchase.order'
1405+
1406+ def create(self, cr, uid, vals, context=None):
1407+ result = super(purchase_order, self).create(cr, uid, vals, context)
1408+ self.expand_packs(cr, uid, [result], context)
1409+ return result
1410+
1411+ def write(self, cr, uid, ids, vals, context=None):
1412+ result = super(purchase_order, self).write(cr, uid, ids, vals, context)
1413+ self.expand_packs(cr, uid, ids, context)
1414+ return result
1415+
1416+ def expand_packs(self, cr, uid, ids, context={}, depth=1):
1417+ if type(ids) in [int, long]:
1418+ ids = [ids]
1419+ if depth == 10:
1420+ return
1421+ updated_orders = []
1422+ for order in self.browse(cr, uid, ids, context):
1423+ fiscal_position = (
1424+ order.fiscal_position
1425+ and self.pool.get('account.fiscal.position').browse(
1426+ cr, uid, order.fiscal_position.id, context
1427+ )
1428+ or False
1429+ )
1430+ """
1431+ The reorder variable is used to ensure lines of the same pack go
1432+ right after their parent. What the algorithm does is check if the
1433+ previous item had children. As children items must go right after
1434+ the parent if the line we're evaluating doesn't have a parent it
1435+ means it's a new item (and probably has the default 10 sequence
1436+ number - unless the appropiate c2c_sale_sequence module is
1437+ installed). In this case we mark the item for reordering and
1438+ evaluate the next one. Note that as the item is not evaluated and
1439+ it might have to be expanded it's put on the queue for another
1440+ iteration (it's simple and works well). Once the next item has been
1441+ evaluated the sequence of the item marked for reordering is updated
1442+ with the next value.
1443+ """
1444+ sequence = -1
1445+ reorder = []
1446+ last_had_children = False
1447+ for line in order.order_line:
1448+ if last_had_children and not line.pack_parent_line_id:
1449+ reorder.append(line.id)
1450+ if (
1451+ line.product_id.pack_line_ids
1452+ and not order.id in updated_orders
1453+ ):
1454+ updated_orders.append(order.id)
1455+ continue
1456+
1457+ sequence += 1
1458+
1459+ if sequence > line.sequence:
1460+ self.pool.get('purchase.order.line').write(
1461+ cr, uid, [line.id], {'sequence': sequence, }, context)
1462+ else:
1463+ sequence = line.sequence
1464+
1465+ if line.state != 'draft':
1466+ continue
1467+ if not line.product_id:
1468+ continue
1469+
1470+ # If pack was already expanded (in another create/write
1471+ # operation or in a previous iteration) don't do it again.
1472+ if line.pack_child_line_ids:
1473+ last_had_children = True
1474+ continue
1475+ last_had_children = False
1476+
1477+ for subline in line.product_id.pack_line_ids:
1478+ sequence += 1
1479+
1480+ subproduct = subline.product_id
1481+ quantity = subline.quantity * line.product_qty
1482+
1483+ if line.product_id.pack_fixed_price:
1484+ price = 0.0
1485+ else:
1486+ pricelist = order.pricelist_id.id
1487+ price = self.pool.get('product.pricelist').price_get(
1488+ cr, uid, [pricelist], subproduct.id, quantity,
1489+ order.partner_id.id, {
1490+ 'uom': subproduct.uom_id.id,
1491+ 'date': order.date_order,
1492+ }
1493+ )[pricelist]
1494+
1495+ # Obtain product name in partner's language
1496+ ctx = {'lang': order.partner_id.lang}
1497+ subproduct_name = self.pool.get('product.product').browse(
1498+ cr, uid, subproduct.id, ctx).name
1499+
1500+ tax_ids = self.pool.get('account.fiscal.position').map_tax(
1501+ cr, uid, fiscal_position, subproduct.taxes_id)
1502+
1503+ vals = {
1504+ 'order_id': order.id,
1505+ 'name': '%s%s' % (
1506+ '> ' * (line.pack_depth + 1), subproduct_name),
1507+ 'date_planned': line.date_planned or 0.0,
1508+ 'sequence': sequence,
1509+ 'product_id': subproduct.id,
1510+ 'price_unit': price,
1511+ 'taxes_id': [(6, 0, tax_ids)],
1512+ 'product_qty': quantity,
1513+ 'product_uom': subproduct.uom_id.id,
1514+ 'move_ids': [(6, 0, [])],
1515+ 'notes': False,
1516+ 'state': 'draft',
1517+ 'pack_parent_line_id': line.id,
1518+ 'pack_depth': line.pack_depth + 1,
1519+ }
1520+
1521+ # It's a control for the case that the nan_external_prices
1522+ # was installed with the product pack
1523+ if 'prices_used' in line:
1524+ vals['prices_used'] = line.prices_used
1525+
1526+ self.pool.get('purchase.order.line').create(
1527+ cr, uid, vals, context)
1528+ if not order.id in updated_orders:
1529+ updated_orders.append(order.id)
1530+
1531+ for id in reorder:
1532+ sequence += 1
1533+ self.pool.get('purchase.order.line').write(
1534+ cr, uid, [id], {'sequence': sequence, }, context)
1535+
1536+ if updated_orders:
1537+ """ Try to expand again all those orders that had a pack in this
1538+ iteration. This way we support packs inside other packs. """
1539+ self.expand_packs(cr, uid, ids, context, depth + 1)
1540+ return
1541
1542=== added file 'product_pack/pack_view.xml'
1543--- product_pack/pack_view.xml 1970-01-01 00:00:00 +0000
1544+++ product_pack/pack_view.xml 2014-07-07 16:03:26 +0000
1545@@ -0,0 +1,48 @@
1546+<?xml version="1.0" encoding="utf-8"?>
1547+<openerp>
1548+ <data>
1549+
1550+ <!-- Product view modification -->
1551+ <record model="ir.ui.view" id="nan_product_pack_form">
1552+ <field name="name">product.product.pack.form</field>
1553+ <field name="model">product.product</field>
1554+ <field name="inherit_id" ref="product.product_normal_form_view" />
1555+ <field name="arch" type="xml">
1556+ <notebook position="inside">
1557+ <page string="Pack">
1558+ <label string="If you add products in the 'Pack Products' field, all those products will be added automatically when a new quotation or order is created." colspan="4"/>
1559+ <group>
1560+ <field name="stock_depends" />
1561+ <field name="pack_fixed_price" />
1562+ </group>
1563+ <separator string="Pack Products" colspan="4"/>
1564+ <field name="pack_line_ids" colspan="4" nolabel="1"/>
1565+ </page>
1566+ </notebook>
1567+ </field>
1568+ </record>
1569+
1570+ <!-- product.pack.line -->
1571+ <record model="ir.ui.view" id="product_pack_line_form">
1572+ <field name="name">product.pack.line.form</field>
1573+ <field name="model">product.pack.line</field>
1574+ <field name="arch" type="xml">
1575+ <form string="Pack Product Line">
1576+ <field name="quantity"/>
1577+ <field name="product_id"/>
1578+ </form>
1579+ </field>
1580+ </record>
1581+ <record model="ir.ui.view" id="product_pack_line_tree">
1582+ <field name="name">product.pack.line.tree</field>
1583+ <field name="model">product.pack.line</field>
1584+ <field name="arch" type="xml">
1585+ <tree string="Pack Product Lines">
1586+ <field name="quantity"/>
1587+ <field name="product_id"/>
1588+ </tree>
1589+ </field>
1590+ </record>
1591+ </data>
1592+</openerp>
1593+
1594
1595=== added directory 'product_pack/security'
1596=== added file 'product_pack/security/ir.model.access.csv'
1597--- product_pack/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
1598+++ product_pack/security/ir.model.access.csv 2014-07-07 16:03:26 +0000
1599@@ -0,0 +1,3 @@
1600+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
1601+"access_product_pack_line_manager","product.pack.line manager","model_product_pack_line","base.group_sale_manager",1,1,1,1
1602+"access_product_pack_line_mployee","product.pack.line employee","model_product_pack_line","base.group_user",1,0,0,0

Subscribers

People subscribed via source and target branches