diff --git a/product_net_weight/README.rst b/product_net_weight/README.rst new file mode 100644 index 000000000000..ab9484e9b9d0 --- /dev/null +++ b/product_net_weight/README.rst @@ -0,0 +1,8 @@ +===================== +Products - Net Weight +===================== + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/product_net_weight/__init__.py b/product_net_weight/__init__.py new file mode 100644 index 000000000000..0650744f6bc6 --- /dev/null +++ b/product_net_weight/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/product_net_weight/__manifest__.py b/product_net_weight/__manifest__.py new file mode 100644 index 000000000000..a945854dcc1b --- /dev/null +++ b/product_net_weight/__manifest__.py @@ -0,0 +1,25 @@ +# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). +{ + "name": "Products - Net Weight", + "summary": "Add 'Net Weight' and 'Weight Price' on product models", + "version": "12.0.1.0.1", + "category": "Product", + "author": "GRAP,Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "website": "https://github.com/OCA/product-attribute", + "license": "AGPL-3", + "depends": ["product"], + "data": [ + "views/view_product_product.xml", + "views/view_product_template.xml", + ], + "demo": [ + "demo/product_product.xml", + ], + "images": [ + "static/description/product_product_form.png", + ], + "installable": True, +} diff --git a/product_net_weight/demo/product_product.xml b/product_net_weight/demo/product_product.xml new file mode 100644 index 000000000000..03f5afc7897d --- /dev/null +++ b/product_net_weight/demo/product_product.xml @@ -0,0 +1,19 @@ + + + + + + Strawberry Jam (Jar of 250 grams) + + + 0.250 + 0.410 + 1.97 + 2.70 + + + diff --git a/product_net_weight/i18n/fr.po b/product_net_weight/i18n/fr.po new file mode 100644 index 000000000000..005bfbec1b9c --- /dev/null +++ b/product_net_weight/i18n/fr.po @@ -0,0 +1,79 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_net_weight +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-08-06 09:11+0000\n" +"PO-Revision-Date: 2021-08-06 09:11+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: product_net_weight +#: model:ir.model.fields,field_description:product_net_weight.field_product_product__weight +#: model:ir.model.fields,field_description:product_net_weight.field_product_template__weight +msgid "Gross Weight" +msgstr "Poids brut" + +#. module: product_net_weight +#: model:ir.model.fields,field_description:product_net_weight.field_product_product__net_weight +#: model:ir.model.fields,field_description:product_net_weight.field_product_template__net_weight +msgid "Net Weight" +msgstr "Poids net" + +#. module: product_net_weight +#: model:ir.model.fields,help:product_net_weight.field_product_product__net_weight +#: model:ir.model.fields,help:product_net_weight.field_product_template__net_weight +msgid "Net Weight of the product, container excluded." +msgstr "Poids net du produit, contenant exclus." + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_product +msgid "Product" +msgstr "Article" + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_template +msgid "Product Template" +msgstr "Modèle d'article" + +#. module: product_net_weight +#: model:product.product,name:product_net_weight.product_strawberry_jam +#: model:product.template,name:product_net_weight.product_strawberry_jam_product_template +msgid "Strawberry Jam (Jar of 250 grams)" +msgstr "Confiture de fraise (Pot de 250 grammes)" + +#. module: product_net_weight +#: model:ir.model.fields,help:product_net_weight.field_product_template__weight +msgid "The weight of the contents in Kg, not including any packaging, etc." +msgstr "Le poids du contenu en kilogrammes, sans compter tout emballage, etc." + +#. module: product_net_weight +#: model:product.product,uom_name:product_net_weight.product_strawberry_jam +#: model:product.template,uom_name:product_net_weight.product_strawberry_jam_product_template +msgid "Unit(s)" +msgstr "Unité(s)" + +#. module: product_net_weight +#: model:ir.model.fields,field_description:product_net_weight.field_product_product__weight_price +#: model:ir.model.fields,field_description:product_net_weight.field_product_template__weight_price +msgid "Weight Price" +msgstr "" + +#. module: product_net_weight +#: model:ir.model.fields,help:product_net_weight.field_product_product__weight +msgid "Weight of the product, packaging not included. The unit of measure can be changed in the general settings" +msgstr "Poids du produit, sans le conditionnement. L'unité de mesure peut être changée dans les paramètres généraux." + +#. module: product_net_weight +#: model:product.product,weight_uom_name:product_net_weight.product_strawberry_jam +#: model:product.template,weight_uom_name:product_net_weight.product_strawberry_jam_product_template +msgid "kg" +msgstr "" + diff --git a/product_net_weight/models/__init__.py b/product_net_weight/models/__init__.py new file mode 100644 index 000000000000..18b37e853203 --- /dev/null +++ b/product_net_weight/models/__init__.py @@ -0,0 +1,2 @@ +from . import product_product +from . import product_template diff --git a/product_net_weight/models/product_product.py b/product_net_weight/models/product_product.py new file mode 100644 index 000000000000..632f72b6d07b --- /dev/null +++ b/product_net_weight/models/product_product.py @@ -0,0 +1,30 @@ +# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models +from odoo.addons import decimal_precision as dp + + +class ProductProduct(models.Model): + _inherit = "product.product" + + net_weight = fields.Float( + string="Net Weight", + digits=dp.get_precision("Stock Weight"), + help="Net Weight of the product, container excluded.", + ) + + weight_price = fields.Float( + string="Weight Price", + digits=dp.get_precision("Product Price"), + compute="_compute_weight_price" + ) + + # Explicit field, renaming it + weight = fields.Float(string="Gross Weight") + + @api.depends("weight", "list_price") + def _compute_weight_price(self): + for product in self.filtered(lambda x: x.net_weight): + product.weight_price = product.list_price / product.net_weight diff --git a/product_net_weight/models/product_template.py b/product_net_weight/models/product_template.py new file mode 100644 index 000000000000..c8f91da4108e --- /dev/null +++ b/product_net_weight/models/product_template.py @@ -0,0 +1,27 @@ +# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +from odoo import fields, models +from odoo.addons import decimal_precision as dp + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + net_weight = fields.Float( + string="Net Weight", + related="product_variant_ids.net_weight", + digits=dp.get_precision("Stock Weight"), + help="Net Weight of the product, container excluded.", + readonly=False, + ) + + weight_price = fields.Float( + string="Weight Price", + digits=dp.get_precision("Product Price"), + related="product_variant_ids.weight_price", + ) + + # Explicit field, renaming it + weight = fields.Float(string="Gross Weight") diff --git a/product_net_weight/readme/CONTRIBUTORS.rst b/product_net_weight/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000000..e1525ce042bd --- /dev/null +++ b/product_net_weight/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Sylvain LE GAL (https://www.twitter.com/legalsylvain) diff --git a/product_net_weight/readme/DESCRIPTION.rst b/product_net_weight/readme/DESCRIPTION.rst new file mode 100644 index 000000000000..11d3199c4e8f --- /dev/null +++ b/product_net_weight/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module extends the functionality of stock module to support net weight. (container excluded) + +It also compute the Weight Price (Sale Price / Net Weight) that is a mandatory information +in certain businesses. diff --git a/product_net_weight/readme/USAGE.rst b/product_net_weight/readme/USAGE.rst new file mode 100644 index 000000000000..2f6e9d051b9e --- /dev/null +++ b/product_net_weight/readme/USAGE.rst @@ -0,0 +1,11 @@ +* Go to 'Inventory > Master Data > Product' and edit items. + +* Go to 'Inventory' tab, and fill the "Net Weight" value. + +.. figure:: ../static/description/product_form.png + +* If the net weight defined, the weight price is computed and displayed on the main tab + +.. figure:: ../static/description/product_form_price.png + +**Note**: The original weight field is renamed to "Gross Weight", to be more explicit. diff --git a/product_net_weight/static/description/product_form.png b/product_net_weight/static/description/product_form.png new file mode 100644 index 000000000000..f50a84dac093 Binary files /dev/null and b/product_net_weight/static/description/product_form.png differ diff --git a/product_net_weight/static/description/product_form_price.png b/product_net_weight/static/description/product_form_price.png new file mode 100644 index 000000000000..d59a5875ab95 Binary files /dev/null and b/product_net_weight/static/description/product_form_price.png differ diff --git a/product_net_weight/views/view_product_product.xml b/product_net_weight/views/view_product_product.xml new file mode 100644 index 000000000000..404f1dc45562 --- /dev/null +++ b/product_net_weight/views/view_product_product.xml @@ -0,0 +1,32 @@ + + + + + + product.product + + + + + + + + + + diff --git a/product_net_weight/views/view_product_template.xml b/product_net_weight/views/view_product_template.xml new file mode 100644 index 000000000000..3e1e6fd3cef8 --- /dev/null +++ b/product_net_weight/views/view_product_template.xml @@ -0,0 +1,32 @@ + + + + + + product.template + + + + + + + + + +