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
=== added directory 'product_pack'
=== added file 'product_pack/__init__.py'
--- product_pack/__init__.py 1970-01-01 00:00:00 +0000
+++ product_pack/__init__.py 2014-07-07 16:03:26 +0000
@@ -0,0 +1,22 @@
1# -*- coding: utf-8 -*-
2###############################################################################
3#
4# Copyright (c) 2009 Angel Alvarez - NaN (http://www.nan-tic.com)
5# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
6# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21###############################################################################
22import pack
023
=== added file 'product_pack/__openerp__.py'
--- product_pack/__openerp__.py 1970-01-01 00:00:00 +0000
+++ product_pack/__openerp__.py 2014-07-07 16:03:26 +0000
@@ -0,0 +1,48 @@
1# -*- coding: utf-8 -*-
2###############################################################################
3#
4# Copyright (c) 2009 Angel Alvarez - NaN (http://www.nan-tic.com)
5# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
6# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
7# @author Albert Cervera i Areny <albert@nan-tic.com>
8# @author Franco Tampieri <franco.tampieri@agilebg.com>
9# Ported to OpenERP 7.0 by Alex Comba <alex.comba@agilebg.com>
10#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU Affero General Public License as published
13# by the Free Software Foundation, either version 3 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU Affero General Public License for more details.
20#
21# You should have received a copy of the GNU Affero General Public License
22# along with this program. If not, see <http://www.gnu.org/licenses/>.
23#
24###############################################################################
25{
26 "name": "Product Pack",
27 "version": "0.2",
28 "category": "Warehouse Management",
29 "description": """
30Based on the NAN_product_pack this module allows configuring products
31as a collection of other products.
32If such a product is added in a sale order or a purchase order, all the
33products of the pack will be added automatically (when storing the order)
34as children of the pack product.
35 """,
36 "author": "Agile Business Group & NaN·tic",
37 "website": "http://www.agilebg.com",
38 "depends": [
39 'sale',
40 'purchase',
41 ],
42 "data": [
43 'security/ir.model.access.csv',
44 'pack_view.xml'
45 ],
46 "active": False,
47 "installable": True
48}
049
=== added directory 'product_pack/i18n'
=== added file 'product_pack/i18n/ca.po'
--- product_pack/i18n/ca.po 1970-01-01 00:00:00 +0000
+++ product_pack/i18n/ca.po 2014-07-07 16:03:26 +0000
@@ -0,0 +1,163 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * nan_product_pack
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 5.0.6\n"
8"Report-Msgid-Bugs-To: support@openerp.com\n"
9"POT-Creation-Date: 2011-01-15 11:45+0000\n"
10"PO-Revision-Date: 2011-02-15 15:15+0000\n"
11"Last-Translator: Jordi Esteve (Zikzakmedia) <jesteve@zikzakmedia.com>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: 8bit\n"
16"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
17"X-Generator: Launchpad (build 15060)\n"
18
19#. module: nan_product_pack
20#: constraint:ir.model:0
21msgid ""
22"The Object name must start with x_ and not contain any special character !"
23msgstr ""
24"El nom de l'objecte ha de començar amb x_ i no contenir cap caràcter "
25"especial!"
26
27#. module: nan_product_pack
28#: help:product.product,stock_depends:0
29msgid "Mark if pack stock is calcualted from component stock"
30msgstr ""
31"Marqueu aquest camp si l'estoc del paquet es calcula a partir de l'estoc "
32"dels components."
33
34#. module: nan_product_pack
35#: field:sale.order.line,pack_child_line_ids:0
36msgid "Lines in pack"
37msgstr "Línies en el paquet"
38
39#. module: nan_product_pack
40#: help:sale.order.line,pack_depth:0
41msgid "Depth of the product if it is part of a pack."
42msgstr "Profunditat del producte si forma part d'un paquet."
43
44#. module: nan_product_pack
45#: field:product.pack.line,product_id:0
46msgid "Product"
47msgstr "Producte"
48
49#. module: nan_product_pack
50#: view:product.pack.line:0
51msgid "Pack Product Lines"
52msgstr "Línies del paquet de productes"
53
54#. module: nan_product_pack
55#: view:product.product:0
56msgid ""
57"If you add products in the 'Pack Products' field, all those products will be "
58"added automatically when a new quotation or order is created."
59msgstr ""
60"Si afegiu productes en el camp \"Paquet de productes\", tots els productes "
61"s'afegiran automàticament quan creeu un nou pressupost o comanda."
62
63#. module: nan_product_pack
64#: model:ir.module.module,description:nan_product_pack.module_meta_information
65msgid ""
66"\n"
67"Allows configuring products as a collection of other products. If such a "
68"product is added in a sale order, all the products of the pack will be added "
69"automatically (when storing the order) as children of the pack product.\n"
70"\n"
71"The module has been made compatible with nan_external_prices and containts "
72"code to specifically handle when the module is available but they're still "
73"independent and there are no dependencies between them.\n"
74" "
75msgstr ""
76"\n"
77"Permet configurar els productes com col·leccions d'altres productes. Si "
78"s'afegeix un producte d'aquest tipus en una comanda de venda, tots els "
79"productes del paquet s'afegiran automàticament (quan es guardi la comanda) "
80"com a fills del producte principal.\n"
81"\n"
82"Aquest mòdul és compatible amb nan_external_prices i conté codi per "
83"funcionar quan està instal·lat encara que ambdós són encara independents i "
84"no hi ha dependències entre ells.\n"
85" "
86
87#. module: nan_product_pack
88#: view:product.product:0
89#: field:sale.order.line,pack_parent_line_id:0
90msgid "Pack"
91msgstr "Paquet"
92
93#. module: nan_product_pack
94#: model:ir.model,name:nan_product_pack.model_product_pack_line
95msgid "product.pack.line"
96msgstr "producte.paquet.línea"
97
98#. module: nan_product_pack
99#: constraint:ir.ui.view:0
100msgid "Invalid XML for View Architecture!"
101msgstr "XML no vàlid per a la definició de la vista!"
102
103#. module: nan_product_pack
104#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
105msgid "Product Pack"
106msgstr "Paquet de productes"
107
108#. module: nan_product_pack
109#: field:product.product,stock_depends:0
110msgid "Stock depends of components"
111msgstr "Estoc depen dels components"
112
113#. module: nan_product_pack
114#: help:sale.order.line,pack_parent_line_id:0
115msgid "The pack that contains this product."
116msgstr "El paquet que conté aquest producte."
117
118#. module: nan_product_pack
119#: field:sale.order.line,pack_depth:0
120msgid "Depth"
121msgstr "Profunditat"
122
123#. module: nan_product_pack
124#: help:product.product,pack_fixed_price:0
125msgid ""
126"Mark this field if the public price of the pack should be fixed. Do not mark "
127"it if the price should be calculated from the sum of the prices of the "
128"products in the pack."
129msgstr ""
130"Marqueu aquest camp si el preu de venda del paquet ha de ser fix. No ho "
131"marqueu si el preu s'ha de calcular a partir de la suma dels preus dels "
132"productes del paquet."
133
134#. module: nan_product_pack
135#: field:product.pack.line,quantity:0
136msgid "Quantity"
137msgstr "Quantitat"
138
139#. module: nan_product_pack
140#: view:product.product:0
141#: field:product.product,pack_line_ids:0
142msgid "Pack Products"
143msgstr "Productes del paquet"
144
145#. module: nan_product_pack
146#: field:product.pack.line,parent_product_id:0
147msgid "Parent Product"
148msgstr "Producte pare"
149
150#. module: nan_product_pack
151#: field:product.product,pack_fixed_price:0
152msgid "Pack has fixed price"
153msgstr "El paquet té un preu fix"
154
155#. module: nan_product_pack
156#: view:product.pack.line:0
157msgid "Pack Product Line"
158msgstr "Línia de paquet de productes"
159
160#. module: nan_product_pack
161#: help:product.product,pack_line_ids:0
162msgid "List of products that are part of this pack."
163msgstr "Llista de productes que formen part del paquet."
0164
=== added file 'product_pack/i18n/de.po'
--- product_pack/i18n/de.po 1970-01-01 00:00:00 +0000
+++ product_pack/i18n/de.po 2014-07-07 16:03:26 +0000
@@ -0,0 +1,145 @@
1# German translation for openobject-addons
2# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
3# This file is distributed under the same license as the openobject-addons package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: openobject-addons\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2011-01-15 11:45+0000\n"
11"PO-Revision-Date: 2011-02-15 15:15+0000\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: German <de@li.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
18"X-Generator: Launchpad (build 15060)\n"
19
20#. module: nan_product_pack
21#: constraint:ir.model:0
22msgid ""
23"The Object name must start with x_ and not contain any special character !"
24msgstr ""
25
26#. module: nan_product_pack
27#: help:product.product,stock_depends:0
28msgid "Mark if pack stock is calcualted from component stock"
29msgstr ""
30
31#. module: nan_product_pack
32#: field:sale.order.line,pack_child_line_ids:0
33msgid "Lines in pack"
34msgstr ""
35
36#. module: nan_product_pack
37#: help:sale.order.line,pack_depth:0
38msgid "Depth of the product if it is part of a pack."
39msgstr ""
40
41#. module: nan_product_pack
42#: field:product.pack.line,product_id:0
43msgid "Product"
44msgstr ""
45
46#. module: nan_product_pack
47#: view:product.pack.line:0
48msgid "Pack Product Lines"
49msgstr ""
50
51#. module: nan_product_pack
52#: view:product.product:0
53msgid ""
54"If you add products in the 'Pack Products' field, all those products will be "
55"added automatically when a new quotation or order is created."
56msgstr ""
57
58#. module: nan_product_pack
59#: model:ir.module.module,description:nan_product_pack.module_meta_information
60msgid ""
61"\n"
62"Allows configuring products as a collection of other products. If such a "
63"product is added in a sale order, all the products of the pack will be added "
64"automatically (when storing the order) as children of the pack product.\n"
65"\n"
66"The module has been made compatible with nan_external_prices and containts "
67"code to specifically handle when the module is available but they're still "
68"independent and there are no dependencies between them.\n"
69" "
70msgstr ""
71
72#. module: nan_product_pack
73#: view:product.product:0
74#: field:sale.order.line,pack_parent_line_id:0
75msgid "Pack"
76msgstr ""
77
78#. module: nan_product_pack
79#: model:ir.model,name:nan_product_pack.model_product_pack_line
80msgid "product.pack.line"
81msgstr ""
82
83#. module: nan_product_pack
84#: constraint:ir.ui.view:0
85msgid "Invalid XML for View Architecture!"
86msgstr ""
87
88#. module: nan_product_pack
89#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
90msgid "Product Pack"
91msgstr ""
92
93#. module: nan_product_pack
94#: field:product.product,stock_depends:0
95msgid "Stock depends of components"
96msgstr ""
97
98#. module: nan_product_pack
99#: help:sale.order.line,pack_parent_line_id:0
100msgid "The pack that contains this product."
101msgstr ""
102
103#. module: nan_product_pack
104#: field:sale.order.line,pack_depth:0
105msgid "Depth"
106msgstr ""
107
108#. module: nan_product_pack
109#: help:product.product,pack_fixed_price:0
110msgid ""
111"Mark this field if the public price of the pack should be fixed. Do not mark "
112"it if the price should be calculated from the sum of the prices of the "
113"products in the pack."
114msgstr ""
115
116#. module: nan_product_pack
117#: field:product.pack.line,quantity:0
118msgid "Quantity"
119msgstr ""
120
121#. module: nan_product_pack
122#: view:product.product:0
123#: field:product.product,pack_line_ids:0
124msgid "Pack Products"
125msgstr ""
126
127#. module: nan_product_pack
128#: field:product.pack.line,parent_product_id:0
129msgid "Parent Product"
130msgstr ""
131
132#. module: nan_product_pack
133#: field:product.product,pack_fixed_price:0
134msgid "Pack has fixed price"
135msgstr ""
136
137#. module: nan_product_pack
138#: view:product.pack.line:0
139msgid "Pack Product Line"
140msgstr ""
141
142#. module: nan_product_pack
143#: help:product.product,pack_line_ids:0
144msgid "List of products that are part of this pack."
145msgstr ""
0146
=== added file 'product_pack/i18n/es.po'
--- product_pack/i18n/es.po 1970-01-01 00:00:00 +0000
+++ product_pack/i18n/es.po 2014-07-07 16:03:26 +0000
@@ -0,0 +1,164 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * nan_product_pack
4#
5# Albert Cervera i Areny <albert@nan-tic.com>, 2009.
6msgid ""
7msgstr ""
8"Project-Id-Version: OpenERP Server 5.0.6\n"
9"Report-Msgid-Bugs-To: support@openerp.com\n"
10"POT-Creation-Date: 2011-01-15 11:45+0000\n"
11"PO-Revision-Date: 2011-02-15 15:15+0000\n"
12"Last-Translator: Jordi Esteve (Zikzakmedia) <jesteve@zikzakmedia.com>\n"
13"Language-Team: Catalan <kde-i18n-ca@kde.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
18"X-Generator: Launchpad (build 15060)\n"
19
20#. module: nan_product_pack
21#: constraint:ir.model:0
22msgid ""
23"The Object name must start with x_ and not contain any special character !"
24msgstr ""
25"¡El nombre del objeto debe empezar con x_ y no contener ningún carácter "
26"especial!"
27
28#. module: nan_product_pack
29#: help:product.product,stock_depends:0
30msgid "Mark if pack stock is calcualted from component stock"
31msgstr ""
32"Marque este campo si el stock del pack se calcula a partir del stock de los "
33"componentes."
34
35#. module: nan_product_pack
36#: field:sale.order.line,pack_child_line_ids:0
37msgid "Lines in pack"
38msgstr "Líneas en el pack"
39
40#. module: nan_product_pack
41#: help:sale.order.line,pack_depth:0
42msgid "Depth of the product if it is part of a pack."
43msgstr "Profundidad del producto si forma parte de un pack."
44
45#. module: nan_product_pack
46#: field:product.pack.line,product_id:0
47msgid "Product"
48msgstr "Producto"
49
50#. module: nan_product_pack
51#: view:product.pack.line:0
52msgid "Pack Product Lines"
53msgstr "Líneas del pack de productos"
54
55#. module: nan_product_pack
56#: view:product.product:0
57msgid ""
58"If you add products in the 'Pack Products' field, all those products will be "
59"added automatically when a new quotation or order is created."
60msgstr ""
61"Si añade productos en el campo \"Pack de productos\", todos los productos se "
62"añadirán automáticamente cuando cree un nuevo presupuesto o pedido."
63
64#. module: nan_product_pack
65#: model:ir.module.module,description:nan_product_pack.module_meta_information
66msgid ""
67"\n"
68"Allows configuring products as a collection of other products. If such a "
69"product is added in a sale order, all the products of the pack will be added "
70"automatically (when storing the order) as children of the pack product.\n"
71"\n"
72"The module has been made compatible with nan_external_prices and containts "
73"code to specifically handle when the module is available but they're still "
74"independent and there are no dependencies between them.\n"
75" "
76msgstr ""
77"\n"
78"Permite configurar los productos como colecciones de otros productos. Si se "
79"añade un producto de este tipo en un pedido de venta, todos los productos "
80"del pack se añadirán automáticamente (cuando se guarde el pedido) como hijos "
81"del producto principal.\n"
82"\n"
83"Este módulo es compatible con nan_external_prices y contiene código para "
84"funcionar cuando está instalado aunque ambos son todavía independientes y no "
85"hay dependencias entre ellos.\n"
86" "
87
88#. module: nan_product_pack
89#: view:product.product:0
90#: field:sale.order.line,pack_parent_line_id:0
91msgid "Pack"
92msgstr "Pack"
93
94#. module: nan_product_pack
95#: model:ir.model,name:nan_product_pack.model_product_pack_line
96msgid "product.pack.line"
97msgstr "producto.pack.línea"
98
99#. module: nan_product_pack
100#: constraint:ir.ui.view:0
101msgid "Invalid XML for View Architecture!"
102msgstr "¡XML no válido para la definición de la vista!"
103
104#. module: nan_product_pack
105#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
106msgid "Product Pack"
107msgstr "Pack de productos"
108
109#. module: nan_product_pack
110#: field:product.product,stock_depends:0
111msgid "Stock depends of components"
112msgstr "Stock depende de los componentes"
113
114#. module: nan_product_pack
115#: help:sale.order.line,pack_parent_line_id:0
116msgid "The pack that contains this product."
117msgstr "El pack que contiene este producto."
118
119#. module: nan_product_pack
120#: field:sale.order.line,pack_depth:0
121msgid "Depth"
122msgstr "Profundidad"
123
124#. module: nan_product_pack
125#: help:product.product,pack_fixed_price:0
126msgid ""
127"Mark this field if the public price of the pack should be fixed. Do not mark "
128"it if the price should be calculated from the sum of the prices of the "
129"products in the pack."
130msgstr ""
131"Marque este campo si el precio de venta del pack tiene que ser fijo. No lo "
132"marque si el precio se tiene que calcular a partir de la suma de los precios "
133"de los productos del pack."
134
135#. module: nan_product_pack
136#: field:product.pack.line,quantity:0
137msgid "Quantity"
138msgstr "Cantidad"
139
140#. module: nan_product_pack
141#: view:product.product:0
142#: field:product.product,pack_line_ids:0
143msgid "Pack Products"
144msgstr "Productos del pack"
145
146#. module: nan_product_pack
147#: field:product.pack.line,parent_product_id:0
148msgid "Parent Product"
149msgstr "Producto padre"
150
151#. module: nan_product_pack
152#: field:product.product,pack_fixed_price:0
153msgid "Pack has fixed price"
154msgstr "El pack tiene un precio fijo"
155
156#. module: nan_product_pack
157#: view:product.pack.line:0
158msgid "Pack Product Line"
159msgstr "Línea de pack de productos"
160
161#. module: nan_product_pack
162#: help:product.product,pack_line_ids:0
163msgid "List of products that are part of this pack."
164msgstr "Lista de productos que forman parte del pack."
0165
=== added file 'product_pack/i18n/it.po'
--- product_pack/i18n/it.po 1970-01-01 00:00:00 +0000
+++ product_pack/i18n/it.po 2014-07-07 16:03:26 +0000
@@ -0,0 +1,164 @@
1# Italian translation for openobject-addons
2# Copyright (c) 2011 Rosetta Contributors and Canonical Ltd 2011
3# This file is distributed under the same license as the openobject-addons package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2011.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: openobject-addons\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2011-01-15 11:45+0000\n"
11"PO-Revision-Date: 2011-05-04 08:52+0000\n"
12"Last-Translator: Lorenzo Battistini - Agile BG - Domsense "
13"<lorenzo.battistini@agilebg.com>\n"
14"Language-Team: Italian <it@li.org>\n"
15"MIME-Version: 1.0\n"
16"Content-Type: text/plain; charset=UTF-8\n"
17"Content-Transfer-Encoding: 8bit\n"
18"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
19"X-Generator: Launchpad (build 15060)\n"
20
21#. module: nan_product_pack
22#: constraint:ir.model:0
23msgid ""
24"The Object name must start with x_ and not contain any special character !"
25msgstr ""
26"Il nome dell'oggetto deve iniziare con x_ e non deve contenere alcun "
27"carattere speciale !"
28
29#. module: nan_product_pack
30#: help:product.product,stock_depends:0
31msgid "Mark if pack stock is calcualted from component stock"
32msgstr ""
33"Selezionare se la giacenza del kit è calcolata sulla base della giacenza dei "
34"componenti"
35
36#. module: nan_product_pack
37#: field:sale.order.line,pack_child_line_ids:0
38msgid "Lines in pack"
39msgstr "Righe nel kit"
40
41#. module: nan_product_pack
42#: help:sale.order.line,pack_depth:0
43msgid "Depth of the product if it is part of a pack."
44msgstr "Profondità del prodotto se è parte di un kit"
45
46#. module: nan_product_pack
47#: field:product.pack.line,product_id:0
48msgid "Product"
49msgstr "Prodotto"
50
51#. module: nan_product_pack
52#: view:product.pack.line:0
53msgid "Pack Product Lines"
54msgstr "Righe Kit"
55
56#. module: nan_product_pack
57#: view:product.product:0
58msgid ""
59"If you add products in the 'Pack Products' field, all those products will be "
60"added automatically when a new quotation or order is created."
61msgstr ""
62"Se si aggiungono prodotti nel campo 'Prodotti Kit', tutti quei prodotti "
63"saranno automaticamente aggiunti alla creazione di un preventivo o ordine."
64
65#. module: nan_product_pack
66#: model:ir.module.module,description:nan_product_pack.module_meta_information
67msgid ""
68"\n"
69"Allows configuring products as a collection of other products. If such a "
70"product is added in a sale order, all the products of the pack will be added "
71"automatically (when storing the order) as children of the pack product.\n"
72"\n"
73"The module has been made compatible with nan_external_prices and containts "
74"code to specifically handle when the module is available but they're still "
75"independent and there are no dependencies between them.\n"
76" "
77msgstr ""
78"\n"
79"Permette di configurare prosotti come collezioni di altri prodotti. Se uno "
80"di questi prodotti viene aggiunto ad un ordine di vendita, tutti i prodotti "
81"nel kit saranno aggiunti automaticamente (al salvataggio dell'ordine) come "
82"figli del prodotto kit.\n"
83"\n"
84"Il modulo è stato reso compatibile con nan_external_prices e contiene il "
85"codice per gestire entrambi i moduli pur mantenendoli indipendenti.\n"
86" "
87
88#. module: nan_product_pack
89#: view:product.product:0
90#: field:sale.order.line,pack_parent_line_id:0
91msgid "Pack"
92msgstr "Kit"
93
94#. module: nan_product_pack
95#: model:ir.model,name:nan_product_pack.model_product_pack_line
96msgid "product.pack.line"
97msgstr "product.pack.line"
98
99#. module: nan_product_pack
100#: constraint:ir.ui.view:0
101msgid "Invalid XML for View Architecture!"
102msgstr "XML non valido per l'architettura della vista"
103
104#. module: nan_product_pack
105#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
106msgid "Product Pack"
107msgstr "Kit prodotto"
108
109#. module: nan_product_pack
110#: field:product.product,stock_depends:0
111msgid "Stock depends of components"
112msgstr "La giacenza si basa sui componenti"
113
114#. module: nan_product_pack
115#: help:sale.order.line,pack_parent_line_id:0
116msgid "The pack that contains this product."
117msgstr "Il kit che contiene questo prodotto."
118
119#. module: nan_product_pack
120#: field:sale.order.line,pack_depth:0
121msgid "Depth"
122msgstr "Profondità"
123
124#. module: nan_product_pack
125#: help:product.product,pack_fixed_price:0
126msgid ""
127"Mark this field if the public price of the pack should be fixed. Do not mark "
128"it if the price should be calculated from the sum of the prices of the "
129"products in the pack."
130msgstr ""
131"Selezionare questo campo se il prezzo pubblico del kit debba essere fisso. "
132"Non selezionarlo se il prezzo debba essere calcolato sulla base dei prezzi "
133"dei prodotti nel kit."
134
135#. module: nan_product_pack
136#: field:product.pack.line,quantity:0
137msgid "Quantity"
138msgstr "Quantità"
139
140#. module: nan_product_pack
141#: view:product.product:0
142#: field:product.product,pack_line_ids:0
143msgid "Pack Products"
144msgstr "Prodotti kit"
145
146#. module: nan_product_pack
147#: field:product.pack.line,parent_product_id:0
148msgid "Parent Product"
149msgstr "Prodotto genitore"
150
151#. module: nan_product_pack
152#: field:product.product,pack_fixed_price:0
153msgid "Pack has fixed price"
154msgstr "Il kit ha prezzo fisso"
155
156#. module: nan_product_pack
157#: view:product.pack.line:0
158msgid "Pack Product Line"
159msgstr "Riga prodotto kit"
160
161#. module: nan_product_pack
162#: help:product.product,pack_line_ids:0
163msgid "List of products that are part of this pack."
164msgstr "Lista dei prodotti che sono parte di questo kit."
0165
=== added file 'product_pack/i18n/product_pack.pot'
--- product_pack/i18n/product_pack.pot 1970-01-01 00:00:00 +0000
+++ product_pack/i18n/product_pack.pot 2014-07-07 16:03:26 +0000
@@ -0,0 +1,155 @@
1# Translation of OpenERP Server.
2# This file contains the translation of the following modules:
3# * product_pack
4#
5msgid ""
6msgstr ""
7"Project-Id-Version: OpenERP Server 7.0\n"
8"Report-Msgid-Bugs-To: \n"
9"POT-Creation-Date: 2013-11-19 14:48+0000\n"
10"PO-Revision-Date: 2013-11-19 14:48+0000\n"
11"Last-Translator: <>\n"
12"Language-Team: \n"
13"MIME-Version: 1.0\n"
14"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Transfer-Encoding: \n"
16"Plural-Forms: \n"
17
18#. module: product_pack
19#: model:ir.model,name:product_pack.model_purchase_order_line
20msgid "Purchase Order Line"
21msgstr "Purchase Order Line"
22
23#. module: product_pack
24#: help:product.product,stock_depends:0
25msgid "Mark if pack stock is calcualted from component stock"
26msgstr "Mark if pack stock is calcualted from component stock"
27
28#. module: product_pack
29#: field:purchase.order.line,pack_child_line_ids:0
30#: field:sale.order.line,pack_child_line_ids:0
31msgid "Lines in pack"
32msgstr "Lines in pack"
33
34#. module: product_pack
35#: help:purchase.order.line,pack_depth:0
36#: help:sale.order.line,pack_depth:0
37msgid "Depth of the product if it is part of a pack."
38msgstr "Depth of the product if it is part of a pack."
39
40#. module: product_pack
41#: model:ir.model,name:product_pack.model_product_product
42#: field:product.pack.line,product_id:0
43msgid "Product"
44msgstr "Product"
45
46#. module: product_pack
47#: view:product.pack.line:0
48msgid "Pack Product Lines"
49msgstr "Pack Product Lines"
50
51#. module: product_pack
52#: view:product.product:0
53msgid "If you add products in the 'Pack Products' field, all those products will be added automatically when a new quotation or order is created."
54msgstr "If you add products in the 'Pack Products' field, all those products will be added automatically when a new quotation or order is created."
55
56#. module: product_pack
57#: help:purchase.order.line,sequence:0
58msgid "Gives the sequence order when displaying a list of\n"
59" purchase order lines. "
60msgstr "Gives the sequence order when displaying a list of\n"
61" purchase order lines. "
62
63#. module: product_pack
64#: view:product.product:0
65#: field:purchase.order.line,pack_parent_line_id:0
66#: field:sale.order.line,pack_parent_line_id:0
67msgid "Pack"
68msgstr "Pack"
69
70#. module: product_pack
71#: model:ir.model,name:product_pack.model_product_pack_line
72msgid "product.pack.line"
73msgstr "product.pack.line"
74
75#. module: product_pack
76#: help:product.product,pack_fixed_price:0
77msgid "\n"
78" Mark this field if the public price of the pack should be fixed.\n"
79" Do not mark it if the price should be calculated from the sum of\n"
80" the prices of the products in the pack.\n"
81" "
82msgstr "\n"
83" Mark this field if the public price of the pack should be fixed.\n"
84" Do not mark it if the price should be calculated from the sum of\n"
85" the prices of the products in the pack.\n"
86" "
87
88#. module: product_pack
89#: field:product.product,stock_depends:0
90msgid "Stock depends of components"
91msgstr "Stock depends of components"
92
93#. module: product_pack
94#: model:ir.model,name:product_pack.model_purchase_order
95msgid "Purchase Order"
96msgstr "Purchase Order"
97
98#. module: product_pack
99#: field:purchase.order.line,pack_depth:0
100#: field:sale.order.line,pack_depth:0
101msgid "Depth"
102msgstr "Depth"
103
104#. module: product_pack
105#: help:purchase.order.line,pack_parent_line_id:0
106#: help:sale.order.line,pack_parent_line_id:0
107msgid "The pack that contains this product."
108msgstr "The pack that contains this product."
109
110#. module: product_pack
111#: field:product.pack.line,quantity:0
112msgid "Quantity"
113msgstr "Quantity"
114
115#. module: product_pack
116#: view:product.product:0
117#: field:product.product,pack_line_ids:0
118msgid "Pack Products"
119msgstr "Pack Products"
120
121#. module: product_pack
122#: field:purchase.order.line,sequence:0
123msgid "Sequence"
124msgstr "Sequence"
125
126#. module: product_pack
127#: field:product.pack.line,parent_product_id:0
128msgid "Parent Product"
129msgstr "Parent Product"
130
131#. module: product_pack
132#: field:product.product,pack_fixed_price:0
133msgid "Pack has fixed price"
134msgstr "Pack has fixed price"
135
136#. module: product_pack
137#: model:ir.model,name:product_pack.model_sale_order
138msgid "Sales Order"
139msgstr "Sales Order"
140
141#. module: product_pack
142#: view:product.pack.line:0
143msgid "Pack Product Line"
144msgstr "Pack Product Line"
145
146#. module: product_pack
147#: model:ir.model,name:product_pack.model_sale_order_line
148msgid "Sales Order Line"
149msgstr "Sales Order Line"
150
151#. module: product_pack
152#: help:product.product,pack_line_ids:0
153msgid "List of products that are part of this pack."
154msgstr "List of products that are part of this pack."
155
0156
=== added file 'product_pack/i18n/pt.po'
--- product_pack/i18n/pt.po 1970-01-01 00:00:00 +0000
+++ product_pack/i18n/pt.po 2014-07-07 16:03:26 +0000
@@ -0,0 +1,149 @@
1# Portuguese translation for openobject-addons
2# Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010
3# This file is distributed under the same license as the openobject-addons package.
4# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
5#
6msgid ""
7msgstr ""
8"Project-Id-Version: openobject-addons\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2011-01-15 11:45+0000\n"
11"PO-Revision-Date: 2011-02-15 15:15+0000\n"
12"Last-Translator: Luniz <luniz52@hotmail.com>\n"
13"Language-Team: Portuguese <pt@li.org>\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
17"X-Launchpad-Export-Date: 2012-04-05 04:56+0000\n"
18"X-Generator: Launchpad (build 15060)\n"
19
20#. module: nan_product_pack
21#: constraint:ir.model:0
22msgid ""
23"The Object name must start with x_ and not contain any special character !"
24msgstr ""
25"O nome do Objecto deve começar com x_ e não pode conter nenhum caracter "
26"especial !"
27
28#. module: nan_product_pack
29#: help:product.product,stock_depends:0
30msgid "Mark if pack stock is calcualted from component stock"
31msgstr ""
32
33#. module: nan_product_pack
34#: field:sale.order.line,pack_child_line_ids:0
35msgid "Lines in pack"
36msgstr "Linhas em embalagens"
37
38#. module: nan_product_pack
39#: help:sale.order.line,pack_depth:0
40msgid "Depth of the product if it is part of a pack."
41msgstr "Profundidade do produto se ele faz parte da embalagem."
42
43#. module: nan_product_pack
44#: field:product.pack.line,product_id:0
45msgid "Product"
46msgstr "Produto"
47
48#. module: nan_product_pack
49#: view:product.pack.line:0
50msgid "Pack Product Lines"
51msgstr "Linhas de Embalagem de Produto"
52
53#. module: nan_product_pack
54#: view:product.product:0
55msgid ""
56"If you add products in the 'Pack Products' field, all those products will be "
57"added automatically when a new quotation or order is created."
58msgstr ""
59"Se adicionar o produto no campo \"Embalagem de Produtos ', todos os produtos "
60"serão adicionados automaticamente quando uma nova ordem de cotação é criado."
61
62#. module: nan_product_pack
63#: model:ir.module.module,description:nan_product_pack.module_meta_information
64msgid ""
65"\n"
66"Allows configuring products as a collection of other products. If such a "
67"product is added in a sale order, all the products of the pack will be added "
68"automatically (when storing the order) as children of the pack product.\n"
69"\n"
70"The module has been made compatible with nan_external_prices and containts "
71"code to specifically handle when the module is available but they're still "
72"independent and there are no dependencies between them.\n"
73" "
74msgstr ""
75
76#. module: nan_product_pack
77#: view:product.product:0
78#: field:sale.order.line,pack_parent_line_id:0
79msgid "Pack"
80msgstr "Embalagem"
81
82#. module: nan_product_pack
83#: model:ir.model,name:nan_product_pack.model_product_pack_line
84msgid "product.pack.line"
85msgstr "product.pack.line"
86
87#. module: nan_product_pack
88#: constraint:ir.ui.view:0
89msgid "Invalid XML for View Architecture!"
90msgstr "XML Inválido para a Aquitectura de Vista!"
91
92#. module: nan_product_pack
93#: model:ir.module.module,shortdesc:nan_product_pack.module_meta_information
94msgid "Product Pack"
95msgstr "Embalagem de Produto"
96
97#. module: nan_product_pack
98#: field:product.product,stock_depends:0
99msgid "Stock depends of components"
100msgstr ""
101
102#. module: nan_product_pack
103#: help:sale.order.line,pack_parent_line_id:0
104msgid "The pack that contains this product."
105msgstr "A embalagem que contém esse produto."
106
107#. module: nan_product_pack
108#: field:sale.order.line,pack_depth:0
109msgid "Depth"
110msgstr "Profundidade"
111
112#. module: nan_product_pack
113#: help:product.product,pack_fixed_price:0
114msgid ""
115"Mark this field if the public price of the pack should be fixed. Do not mark "
116"it if the price should be calculated from the sum of the prices of the "
117"products in the pack."
118msgstr ""
119
120#. module: nan_product_pack
121#: field:product.pack.line,quantity:0
122msgid "Quantity"
123msgstr "Quantidade"
124
125#. module: nan_product_pack
126#: view:product.product:0
127#: field:product.product,pack_line_ids:0
128msgid "Pack Products"
129msgstr "Embalagem de Produtos"
130
131#. module: nan_product_pack
132#: field:product.pack.line,parent_product_id:0
133msgid "Parent Product"
134msgstr "Produto Ascendente"
135
136#. module: nan_product_pack
137#: field:product.product,pack_fixed_price:0
138msgid "Pack has fixed price"
139msgstr "A Embalagem tem preço fixado"
140
141#. module: nan_product_pack
142#: view:product.pack.line:0
143msgid "Pack Product Line"
144msgstr "Linha de Embalagem de Produto"
145
146#. module: nan_product_pack
147#: help:product.product,pack_line_ids:0
148msgid "List of products that are part of this pack."
149msgstr "Lista dos produtos que fazem parte desta embalagem."
0150
=== added file 'product_pack/pack.py'
--- product_pack/pack.py 1970-01-01 00:00:00 +0000
+++ product_pack/pack.py 2014-07-07 16:03:26 +0000
@@ -0,0 +1,484 @@
1# -*- coding: utf-8 -*-
2###############################################################################
3#
4# Copyright (c) 2009 Angel Alvarez - NaN (http://www.nan-tic.com)
5# Copyright (C) 2012 Domsense srl (<http://www.domsense.com>)
6# Copyright (C) 2013 Agile Business Group sagl (<http://www.agilebg.com>)
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU Affero General Public License as published
10# by the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU Affero General Public License for more details.
17#
18# You should have received a copy of the GNU Affero General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.
20#
21###############################################################################
22
23import math
24from openerp.osv import fields, orm
25
26
27class product_pack(orm.Model):
28 _name = 'product.pack.line'
29 _rec_name = 'product_id'
30 _columns = {
31 'parent_product_id': fields.many2one(
32 'product.product', 'Parent Product',
33 ondelete='cascade', required=True
34 ),
35 'quantity': fields.float('Quantity', required=True),
36 'product_id': fields.many2one(
37 'product.product', 'Product', required=True
38 ),
39 }
40
41
42class product_product(orm.Model):
43 _inherit = 'product.product'
44 _columns = {
45 'stock_depends': fields.boolean(
46 'Stock depends of components',
47 help='Mark if pack stock is calcualted from component stock'
48 ),
49 'pack_fixed_price': fields.boolean(
50 'Pack has fixed price',
51 help="""
52 Mark this field if the public price of the pack should be fixed.
53 Do not mark it if the price should be calculated from the sum of
54 the prices of the products in the pack.
55 """
56 ),
57 'pack_line_ids': fields.one2many(
58 'product.pack.line', 'parent_product_id', 'Pack Products',
59 help='List of products that are part of this pack.'
60 ),
61 }
62
63 def get_product_available(self, cr, uid, ids, context=None):
64 """
65 Calulate stock for packs
66 :return: maximum stock that lets complete pack
67 """
68 result = {}
69 for product in self.browse(cr, uid, ids, context=context):
70 stock = super(product_product, self).get_product_available(
71 cr, uid, [product.id], context=context)
72
73 # Check if product stock depends on it's subproducts stock.
74 if not product.stock_depends:
75 result[product.id] = stock[product.id]
76 continue
77
78 first_subproduct = True
79 pack_stock = 0
80
81 # Check if the pack has subproducts
82 if product.pack_line_ids:
83
84 # Take the stock/virtual stock of all subproducts
85 subproducts_stock = self.get_product_available(
86 cr,
87 uid,
88 [line.product_id.id for line in product.pack_line_ids],
89 context=context
90 )
91
92 """ Go over all subproducts, take quantity needed for the pack
93 and its available stock """
94 for subproduct in product.pack_line_ids:
95
96 # if subproduct is a service don't calculate the stock
97 if subproduct.product_id.type == 'service':
98 continue
99 if first_subproduct:
100 subproduct_quantity = subproduct.quantity
101 subproduct_stock = (
102 subproducts_stock[subproduct.product_id.id])
103 if subproduct_quantity == 0:
104 continue
105
106 """ Calculate real stock for current pack from the
107 subproduct stock and needed quantity """
108 pack_stock = math.floor(
109 subproduct_stock / subproduct_quantity)
110 first_subproduct = False
111 continue
112
113 # Take the info of the next subproduct
114 subproduct_quantity_next = subproduct.quantity
115 subproduct_stock_next = (
116 subproducts_stock[subproduct.product_id.id])
117
118 if (
119 subproduct_quantity_next == 0
120 or subproduct_quantity_next == 0.0
121 ):
122 continue
123
124 pack_stock_next = math.floor(
125 subproduct_stock_next / subproduct_quantity_next)
126
127 # compare the stock of a subproduct and the next subproduct
128 if pack_stock_next < pack_stock:
129 pack_stock = pack_stock_next
130
131 # result is the minimum stock of all subproducts
132 result[product.id] = pack_stock
133 else:
134 result[product.id] = stock[product.id]
135 return result
136
137
138class sale_order_line(orm.Model):
139 _inherit = 'sale.order.line'
140 _columns = {
141 'pack_depth': fields.integer(
142 'Depth', required=True,
143 help='Depth of the product if it is part of a pack.'
144 ),
145 'pack_parent_line_id': fields.many2one(
146 'sale.order.line', 'Pack',
147 help='The pack that contains this product.'
148 ),
149 'pack_child_line_ids': fields.one2many(
150 'sale.order.line', 'pack_parent_line_id', 'Lines in pack'),
151 }
152 _defaults = {
153 'pack_depth': 0,
154 }
155
156
157class sale_order(orm.Model):
158 _inherit = 'sale.order'
159
160 def create(self, cr, uid, vals, context=None):
161 result = super(sale_order, self).create(cr, uid, vals, context)
162 self.expand_packs(cr, uid, [result], context)
163 return result
164
165 def write(self, cr, uid, ids, vals, context=None):
166 result = super(sale_order, self).write(cr, uid, ids, vals, context)
167 self.expand_packs(cr, uid, ids, context)
168 return result
169
170 def expand_packs(self, cr, uid, ids, context={}, depth=1):
171 if type(ids) in [int, long]:
172 ids = [ids]
173 if depth == 10:
174 return
175 updated_orders = []
176 for order in self.browse(cr, uid, ids, context):
177
178 fiscal_position = (
179 order.fiscal_position
180 and self.pool.get('account.fiscal.position').browse(
181 cr, uid, order.fiscal_position.id, context
182 )
183 or False
184 )
185 """
186 The reorder variable is used to ensure lines of the same pack go
187 right after their parent. What the algorithm does is check if the
188 previous item had children. As children items must go right after
189 the parent if the line we're evaluating doesn't have a parent it
190 means it's a new item (and probably has the default 10 sequence
191 number - unless the appropiate c2c_sale_sequence module is
192 installed). In this case we mark the item for reordering and
193 evaluate the next one. Note that as the item is not evaluated and
194 it might have to be expanded it's put on the queue for another
195 iteration (it's simple and works well). Once the next item has been
196 evaluated the sequence of the item marked for reordering is updated
197 with the next value.
198 """
199 sequence = -1
200 reorder = []
201 last_had_children = False
202 for line in order.order_line:
203 if last_had_children and not line.pack_parent_line_id:
204 reorder.append(line.id)
205 if (
206 line.product_id.pack_line_ids
207 and not order.id in updated_orders
208 ):
209 updated_orders.append(order.id)
210 continue
211
212 sequence += 1
213
214 if sequence > line.sequence:
215 self.pool.get('sale.order.line').write(
216 cr, uid, [line.id], {'sequence': sequence, }, context)
217 else:
218 sequence = line.sequence
219
220 if line.state != 'draft':
221 continue
222 if not line.product_id:
223 continue
224
225 """ If pack was already expanded (in another create/write
226 operation or in a previous iteration) don't do it again. """
227 if line.pack_child_line_ids:
228 last_had_children = True
229 continue
230 last_had_children = False
231
232 for subline in line.product_id.pack_line_ids:
233 sequence += 1
234
235 subproduct = subline.product_id
236 quantity = subline.quantity * line.product_uom_qty
237
238 if line.product_id.pack_fixed_price:
239 price = 0.0
240 discount = 0.0
241 else:
242 pricelist = order.pricelist_id.id
243 price = self.pool.get('product.pricelist').price_get(
244 cr, uid, [pricelist], subproduct.id, quantity,
245 order.partner_id.id, {
246 'uom': subproduct.uom_id.id,
247 'date': order.date_order,
248 }
249 )[pricelist]
250 discount = line.discount
251
252 # Obtain product name in partner's language
253 ctx = {'lang': order.partner_id.lang}
254 subproduct_name = self.pool.get('product.product').browse(
255 cr, uid, subproduct.id, ctx).name
256
257 tax_ids = self.pool.get('account.fiscal.position').map_tax(
258 cr, uid, fiscal_position, subproduct.taxes_id)
259
260 if subproduct.uos_id:
261 uos_id = subproduct.uos_id.id
262 uos_qty = quantity * subproduct.uos_coeff
263 else:
264 uos_id = False
265 uos_qty = quantity
266
267 vals = {
268 'order_id': order.id,
269 'name': '%s%s' % (
270 '> ' * (line.pack_depth+1), subproduct_name
271 ),
272 'sequence': sequence,
273 'delay': subproduct.sale_delay or 0.0,
274 'product_id': subproduct.id,
275 'procurement_id': (
276 line.procurement_id
277 and line.procurement_id.id
278 or False
279 ),
280 'price_unit': price,
281 'tax_id': [(6, 0, tax_ids)],
282 'type': subproduct.procure_method,
283 'property_ids': [(6, 0, [])],
284 'address_allotment_id': False,
285 'product_uom_qty': quantity,
286 'product_uom': subproduct.uom_id.id,
287 'product_uos_qty': uos_qty,
288 'product_uos': uos_id,
289 'product_packaging': False,
290 'move_ids': [(6, 0, [])],
291 'discount': discount,
292 'number_packages': False,
293 'notes': False,
294 'th_weight': False,
295 'state': 'draft',
296 'pack_parent_line_id': line.id,
297 'pack_depth': line.pack_depth + 1,
298 }
299
300 """ It's a control for the case that the
301 nan_external_prices was installed with the product pack """
302 if 'prices_used' in line:
303 vals['prices_used'] = line.prices_used
304
305 self.pool.get('sale.order.line').create(
306 cr, uid, vals, context)
307 if not order.id in updated_orders:
308 updated_orders.append(order.id)
309
310 for id in reorder:
311 sequence += 1
312 self.pool.get('sale.order.line').write(
313 cr, uid, [id], {'sequence': sequence, }, context)
314
315 if updated_orders:
316 """ Try to expand again all those orders that had a pack in this
317 iteration. This way we support packs inside other packs. """
318 self.expand_packs(cr, uid, ids, context, depth + 1)
319 return
320
321
322class purchase_order_line(orm.Model):
323 _inherit = 'purchase.order.line'
324 _columns = {
325 'sequence': fields.integer(
326 'Sequence',
327 help="""Gives the sequence order when displaying a list of
328 purchase order lines. """
329 ),
330 'pack_depth': fields.integer(
331 'Depth', required=True,
332 help='Depth of the product if it is part of a pack.'
333 ),
334 'pack_parent_line_id': fields.many2one(
335 'purchase.order.line', 'Pack',
336 help='The pack that contains this product.'
337 ),
338 'pack_child_line_ids': fields.one2many(
339 'purchase.order.line', 'pack_parent_line_id', 'Lines in pack'
340 ),
341 }
342 _defaults = {
343 'pack_depth': 0,
344 }
345
346
347class purchase_order(orm.Model):
348 _inherit = 'purchase.order'
349
350 def create(self, cr, uid, vals, context=None):
351 result = super(purchase_order, self).create(cr, uid, vals, context)
352 self.expand_packs(cr, uid, [result], context)
353 return result
354
355 def write(self, cr, uid, ids, vals, context=None):
356 result = super(purchase_order, self).write(cr, uid, ids, vals, context)
357 self.expand_packs(cr, uid, ids, context)
358 return result
359
360 def expand_packs(self, cr, uid, ids, context={}, depth=1):
361 if type(ids) in [int, long]:
362 ids = [ids]
363 if depth == 10:
364 return
365 updated_orders = []
366 for order in self.browse(cr, uid, ids, context):
367 fiscal_position = (
368 order.fiscal_position
369 and self.pool.get('account.fiscal.position').browse(
370 cr, uid, order.fiscal_position.id, context
371 )
372 or False
373 )
374 """
375 The reorder variable is used to ensure lines of the same pack go
376 right after their parent. What the algorithm does is check if the
377 previous item had children. As children items must go right after
378 the parent if the line we're evaluating doesn't have a parent it
379 means it's a new item (and probably has the default 10 sequence
380 number - unless the appropiate c2c_sale_sequence module is
381 installed). In this case we mark the item for reordering and
382 evaluate the next one. Note that as the item is not evaluated and
383 it might have to be expanded it's put on the queue for another
384 iteration (it's simple and works well). Once the next item has been
385 evaluated the sequence of the item marked for reordering is updated
386 with the next value.
387 """
388 sequence = -1
389 reorder = []
390 last_had_children = False
391 for line in order.order_line:
392 if last_had_children and not line.pack_parent_line_id:
393 reorder.append(line.id)
394 if (
395 line.product_id.pack_line_ids
396 and not order.id in updated_orders
397 ):
398 updated_orders.append(order.id)
399 continue
400
401 sequence += 1
402
403 if sequence > line.sequence:
404 self.pool.get('purchase.order.line').write(
405 cr, uid, [line.id], {'sequence': sequence, }, context)
406 else:
407 sequence = line.sequence
408
409 if line.state != 'draft':
410 continue
411 if not line.product_id:
412 continue
413
414 # If pack was already expanded (in another create/write
415 # operation or in a previous iteration) don't do it again.
416 if line.pack_child_line_ids:
417 last_had_children = True
418 continue
419 last_had_children = False
420
421 for subline in line.product_id.pack_line_ids:
422 sequence += 1
423
424 subproduct = subline.product_id
425 quantity = subline.quantity * line.product_qty
426
427 if line.product_id.pack_fixed_price:
428 price = 0.0
429 else:
430 pricelist = order.pricelist_id.id
431 price = self.pool.get('product.pricelist').price_get(
432 cr, uid, [pricelist], subproduct.id, quantity,
433 order.partner_id.id, {
434 'uom': subproduct.uom_id.id,
435 'date': order.date_order,
436 }
437 )[pricelist]
438
439 # Obtain product name in partner's language
440 ctx = {'lang': order.partner_id.lang}
441 subproduct_name = self.pool.get('product.product').browse(
442 cr, uid, subproduct.id, ctx).name
443
444 tax_ids = self.pool.get('account.fiscal.position').map_tax(
445 cr, uid, fiscal_position, subproduct.taxes_id)
446
447 vals = {
448 'order_id': order.id,
449 'name': '%s%s' % (
450 '> ' * (line.pack_depth + 1), subproduct_name),
451 'date_planned': line.date_planned or 0.0,
452 'sequence': sequence,
453 'product_id': subproduct.id,
454 'price_unit': price,
455 'taxes_id': [(6, 0, tax_ids)],
456 'product_qty': quantity,
457 'product_uom': subproduct.uom_id.id,
458 'move_ids': [(6, 0, [])],
459 'notes': False,
460 'state': 'draft',
461 'pack_parent_line_id': line.id,
462 'pack_depth': line.pack_depth + 1,
463 }
464
465 # It's a control for the case that the nan_external_prices
466 # was installed with the product pack
467 if 'prices_used' in line:
468 vals['prices_used'] = line.prices_used
469
470 self.pool.get('purchase.order.line').create(
471 cr, uid, vals, context)
472 if not order.id in updated_orders:
473 updated_orders.append(order.id)
474
475 for id in reorder:
476 sequence += 1
477 self.pool.get('purchase.order.line').write(
478 cr, uid, [id], {'sequence': sequence, }, context)
479
480 if updated_orders:
481 """ Try to expand again all those orders that had a pack in this
482 iteration. This way we support packs inside other packs. """
483 self.expand_packs(cr, uid, ids, context, depth + 1)
484 return
0485
=== added file 'product_pack/pack_view.xml'
--- product_pack/pack_view.xml 1970-01-01 00:00:00 +0000
+++ product_pack/pack_view.xml 2014-07-07 16:03:26 +0000
@@ -0,0 +1,48 @@
1<?xml version="1.0" encoding="utf-8"?>
2<openerp>
3 <data>
4
5 <!-- Product view modification -->
6 <record model="ir.ui.view" id="nan_product_pack_form">
7 <field name="name">product.product.pack.form</field>
8 <field name="model">product.product</field>
9 <field name="inherit_id" ref="product.product_normal_form_view" />
10 <field name="arch" type="xml">
11 <notebook position="inside">
12 <page string="Pack">
13 <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"/>
14 <group>
15 <field name="stock_depends" />
16 <field name="pack_fixed_price" />
17 </group>
18 <separator string="Pack Products" colspan="4"/>
19 <field name="pack_line_ids" colspan="4" nolabel="1"/>
20 </page>
21 </notebook>
22 </field>
23 </record>
24
25 <!-- product.pack.line -->
26 <record model="ir.ui.view" id="product_pack_line_form">
27 <field name="name">product.pack.line.form</field>
28 <field name="model">product.pack.line</field>
29 <field name="arch" type="xml">
30 <form string="Pack Product Line">
31 <field name="quantity"/>
32 <field name="product_id"/>
33 </form>
34 </field>
35 </record>
36 <record model="ir.ui.view" id="product_pack_line_tree">
37 <field name="name">product.pack.line.tree</field>
38 <field name="model">product.pack.line</field>
39 <field name="arch" type="xml">
40 <tree string="Pack Product Lines">
41 <field name="quantity"/>
42 <field name="product_id"/>
43 </tree>
44 </field>
45 </record>
46 </data>
47</openerp>
48
049
=== added directory 'product_pack/security'
=== added file 'product_pack/security/ir.model.access.csv'
--- product_pack/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ product_pack/security/ir.model.access.csv 2014-07-07 16:03:26 +0000
@@ -0,0 +1,3 @@
1"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
2"access_product_pack_line_manager","product.pack.line manager","model_product_pack_line","base.group_sale_manager",1,1,1,1
3"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