diff --git a/product_net_weight/README.rst b/product_net_weight/README.rst new file mode 100644 index 00000000000..36bbde8f648 --- /dev/null +++ b/product_net_weight/README.rst @@ -0,0 +1,114 @@ +===================== +Products - Net Weight +===================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:4aeae07043d7e7568ada0d6cdc7da1909337eb023b9bb610b800dcd35a1c830f + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fproduct--attribute-lightgray.png?logo=github + :target: https://github.com/OCA/product-attribute/tree/17.0/product_net_weight + :alt: OCA/product-attribute +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/product-attribute-17-0/product-attribute-17-0-product_net_weight + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/product-attribute&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends the functionality of stock module to support net +weight. (container excluded) + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +- Go to 'Inventory > Master Data > Product' and edit items. +- Go to 'Inventory' tab, and fill the "Net Weight" value. + +|image1| + +**Note**: The original weight field is renamed to "Gross Weight", to be +more explicit. + +.. |image1| image:: https://raw.githubusercontent.com/OCA/product-attribute/17.0/product_net_weight/static/description/product_form.png + +Known issues / Roadmap +====================== + +In futur version (> 12.0), allow to compute Weight Price (Net weight / +Price). For that purpose, refactor with ``product_logistics_uom``. + +Ref : +https://github.com/OCA/product-attribute/pull/894#issuecomment-895930887 + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* GRAP + +Contributors +------------ + +- Sylvain LE GAL (https://www.twitter.com/legalsylvain) +- `Greenice `__: + + - Fernando La Chica + +- `Tecnativa `__: + + - Sergio Teruel + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px + :target: https://github.com/legalsylvain + :alt: legalsylvain + +Current `maintainer `__: + +|maintainer-legalsylvain| + +This module is part of the `OCA/product-attribute `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/product_net_weight/__init__.py b/product_net_weight/__init__.py new file mode 100644 index 00000000000..0650744f6bc --- /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 00000000000..61e132b26b1 --- /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' on product models", + "version": "17.0.1.0.0", + "category": "Product", + "author": "GRAP,Odoo Community Association (OCA)", + "maintainers": ["legalsylvain"], + "website": "https://github.com/OCA/product-attribute", + "license": "AGPL-3", + "depends": ["stock"], + "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 00000000000..b8d72cf57d5 --- /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/es.po b/product_net_weight/i18n/es.po new file mode 100644 index 00000000000..f8e444cde2b --- /dev/null +++ b/product_net_weight/i18n/es.po @@ -0,0 +1,58 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_net_weight +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0+e\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2023-03-02 08:36+0000\n" +"PO-Revision-Date: 2023-08-29 08:30+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Peso bruto" + +#. 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 "Peso neto" + +#. 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 "Peso neto del producto, contenedor excluido." + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_template +msgid "Product" +msgstr "Producto" + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_product +msgid "Product Variant" +msgstr "Variantes de producto" + +#. module: product_net_weight +#: model:product.template,name:product_net_weight.product_strawberry_jam_product_template +msgid "Strawberry Jam (Jar of 250 grams)" +msgstr "Mermelada de fresa (tarro de 250 gramos)" + +#. module: product_net_weight +#. odoo-python +#: code:addons/product_net_weight/models/product_product.py:0 +#, python-format +msgid "The net weight of product must be lower than gross weight." +msgstr "El peso neto tiene que ser menor que el peso bruto." diff --git a/product_net_weight/i18n/fr.po b/product_net_weight/i18n/fr.po new file mode 100644 index 00000000000..4f2d5913f77 --- /dev/null +++ b/product_net_weight/i18n/fr.po @@ -0,0 +1,75 @@ +# 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-13 18:38+0000\n" +"PO-Revision-Date: 2021-08-13 18:38+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \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_template +msgid "Product" +msgstr "Article" + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: product_net_weight +#: 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 +#. odoo-python +#: code:addons/product_net_weight/models/product_product.py:0 +#, python-format +msgid "The net weight of product must be lower than gross weight." +msgstr "" + +#~ msgid "Product Template" +#~ msgstr "Modèle d'article" + +#, fuzzy +#~ msgid "The weight of the contents, not including any packaging, etc." +#~ msgstr "" +#~ "Le poids du contenu en kilogrammes, sans compter tout emballage, etc." + +#~ msgid "Unit(s)" +#~ msgstr "Unité(s)" + +#~ 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." diff --git a/product_net_weight/i18n/it.po b/product_net_weight/i18n/it.po new file mode 100644 index 00000000000..2dd591c532f --- /dev/null +++ b/product_net_weight/i18n/it.po @@ -0,0 +1,57 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_net_weight +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2023-10-29 15:40+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\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 "Peso lordo" + +#. 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 "Peso netto" + +#. 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 "Peso netto del prodotto, escluso contenitore." + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_template +msgid "Product" +msgstr "Prodotto" + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_product +msgid "Product Variant" +msgstr "Variante prodotto" + +#. module: product_net_weight +#: model:product.template,name:product_net_weight.product_strawberry_jam_product_template +msgid "Strawberry Jam (Jar of 250 grams)" +msgstr "Marmellata di fragole (vasetto da 250 grammi)" + +#. module: product_net_weight +#. odoo-python +#: code:addons/product_net_weight/models/product_product.py:0 +#, python-format +msgid "The net weight of product must be lower than gross weight." +msgstr "Il peso netto del prodotto deve essere inferiore al peso lordo." diff --git a/product_net_weight/i18n/product_net_weight.pot b/product_net_weight/i18n/product_net_weight.pot new file mode 100644 index 00000000000..0e3c174ec73 --- /dev/null +++ b/product_net_weight/i18n/product_net_weight.pot @@ -0,0 +1,54 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * product_net_weight +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \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 "" + +#. 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 "" + +#. 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 "" + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_template +msgid "Product" +msgstr "" + +#. module: product_net_weight +#: model:ir.model,name:product_net_weight.model_product_product +msgid "Product Variant" +msgstr "" + +#. module: product_net_weight +#: model:product.template,name:product_net_weight.product_strawberry_jam_product_template +msgid "Strawberry Jam (Jar of 250 grams)" +msgstr "" + +#. module: product_net_weight +#. odoo-python +#: code:addons/product_net_weight/models/product_product.py:0 +#, python-format +msgid "The net weight of product must be lower than gross weight." +msgstr "" diff --git a/product_net_weight/models/__init__.py b/product_net_weight/models/__init__.py new file mode 100644 index 00000000000..18b37e85320 --- /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 00000000000..8ca02cf3955 --- /dev/null +++ b/product_net_weight/models/product_product.py @@ -0,0 +1,26 @@ +# 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.exceptions import ValidationError + + +class ProductProduct(models.Model): + _inherit = "product.product" + + net_weight = fields.Float( + digits="Stock Weight", + help="Net Weight of the product, container excluded.", + ) + + # Explicit field, renaming it + weight = fields.Float(string="Gross Weight") + + @api.constrains("net_weight", "weight") + def _check_net_weight(self): + for product in self: + if product.weight and product.net_weight > product.weight: + raise ValidationError( + _("The net weight of product must be lower than gross weight.") + ) diff --git a/product_net_weight/models/product_template.py b/product_net_weight/models/product_template.py new file mode 100644 index 00000000000..fe97e83a29d --- /dev/null +++ b/product_net_weight/models/product_template.py @@ -0,0 +1,43 @@ +# Copyright (C) 2021 - Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). + +from odoo import api, fields, models + + +class ProductTemplate(models.Model): + _inherit = "product.template" + + net_weight = fields.Float( + compute="_compute_net_weight", + inverse="_inverse_net_weight", + digits="Stock Weight", + help="Net Weight of the product, container excluded.", + store=True, + ) + + # Explicit field, renaming it + weight = fields.Float(string="Gross Weight") + + @api.depends("product_variant_ids", "product_variant_ids.net_weight") + def _compute_net_weight(self): + for template in self: + if template.product_variant_count == 1: + template.net_weight = template.product_variant_ids.net_weight + else: + template.net_weight = 0.0 + + def _inverse_net_weight(self): + for template in self: + if len(template.product_variant_ids) == 1: + template.product_variant_ids.net_weight = template.net_weight + + @api.model_create_multi + def create(self, vals_list): + templates = super().create(vals_list) + # This is needed to set given values to first variant after creation + for template, vals in zip(templates, vals_list, strict=True): + if vals.get("net_weight"): + template.write({"net_weight": vals["net_weight"]}) + return templates diff --git a/product_net_weight/pyproject.toml b/product_net_weight/pyproject.toml new file mode 100644 index 00000000000..4231d0cccb3 --- /dev/null +++ b/product_net_weight/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/product_net_weight/readme/CONTRIBUTORS.md b/product_net_weight/readme/CONTRIBUTORS.md new file mode 100644 index 00000000000..857c72b4a9e --- /dev/null +++ b/product_net_weight/readme/CONTRIBUTORS.md @@ -0,0 +1,5 @@ +- Sylvain LE GAL () +- [Greenice](https://www.greenice.com): + - Fernando La Chica \<\> +- [Tecnativa](https://www.tecnativa.com): + - Sergio Teruel diff --git a/product_net_weight/readme/DESCRIPTION.md b/product_net_weight/readme/DESCRIPTION.md new file mode 100644 index 00000000000..d9e1fde5cc4 --- /dev/null +++ b/product_net_weight/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends the functionality of stock module to support net +weight. (container excluded) diff --git a/product_net_weight/readme/ROADMAP.md b/product_net_weight/readme/ROADMAP.md new file mode 100644 index 00000000000..71662ba1a9e --- /dev/null +++ b/product_net_weight/readme/ROADMAP.md @@ -0,0 +1,5 @@ +In futur version (\> 12.0), allow to compute Weight Price (Net weight / +Price). For that purpose, refactor with `product_logistics_uom`. + +Ref : + diff --git a/product_net_weight/readme/USAGE.md b/product_net_weight/readme/USAGE.md new file mode 100644 index 00000000000..a81cea018de --- /dev/null +++ b/product_net_weight/readme/USAGE.md @@ -0,0 +1,7 @@ +- Go to 'Inventory \> Master Data \> Product' and edit items. +- Go to 'Inventory' tab, and fill the "Net Weight" value. + +![](../static/description/product_form.png) + +**Note**: The original weight field is renamed to "Gross Weight", to be +more explicit. diff --git a/product_net_weight/static/description/icon.png b/product_net_weight/static/description/icon.png new file mode 100644 index 00000000000..3a0328b516c Binary files /dev/null and b/product_net_weight/static/description/icon.png differ diff --git a/product_net_weight/static/description/index.html b/product_net_weight/static/description/index.html new file mode 100644 index 00000000000..ccad0247e57 --- /dev/null +++ b/product_net_weight/static/description/index.html @@ -0,0 +1,450 @@ + + + + + +Products - Net Weight + + + +
+

Products - Net Weight

+ + +

Beta License: AGPL-3 OCA/product-attribute Translate me on Weblate Try me on Runboat

+

This module extends the functionality of stock module to support net +weight. (container excluded)

+

Table of contents

+ +
+

Usage

+
    +
  • Go to ‘Inventory > Master Data > Product’ and edit items.
  • +
  • Go to ‘Inventory’ tab, and fill the “Net Weight” value.
  • +
+

image1

+

Note: The original weight field is renamed to “Gross Weight”, to be +more explicit.

+
+
+

Known issues / Roadmap

+

In futur version (> 12.0), allow to compute Weight Price (Net weight / +Price). For that purpose, refactor with product_logistics_uom.

+

Ref : +https://github.com/OCA/product-attribute/pull/894#issuecomment-895930887

+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • GRAP
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

legalsylvain

+

This module is part of the OCA/product-attribute project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + 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 00000000000..f50a84dac09 Binary files /dev/null and b/product_net_weight/static/description/product_form.png differ diff --git a/product_net_weight/tests/__init__.py b/product_net_weight/tests/__init__.py new file mode 100644 index 00000000000..0804ce88209 --- /dev/null +++ b/product_net_weight/tests/__init__.py @@ -0,0 +1,2 @@ +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from . import test_product_net_weight diff --git a/product_net_weight/tests/test_product_net_weight.py b/product_net_weight/tests/test_product_net_weight.py new file mode 100644 index 00000000000..f9b196e792b --- /dev/null +++ b/product_net_weight/tests/test_product_net_weight.py @@ -0,0 +1,70 @@ +# Copyright 2023 Tecnativa - Sergio Teruel +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). +from odoo.exceptions import ValidationError +from odoo.tests.common import Form, TransactionCase + + +class TestProductNetWeight(TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.attribute = cls.env["product.attribute"].create( + { + "name": "test attribute", + "display_type": "select", + } + ) + + def test_create_product_template(self): + product_form = Form(self.env["product.template"]) + product_form.name = "Test net weight" + product_form.net_weight = 25.0 + product = product_form.save() + self.assertEqual(product.net_weight, 25.0) + self.assertEqual(product.product_variant_id.net_weight, 25.0) + product.write( + { + "attribute_line_ids": [ + ( + 0, + 0, + { + "attribute_id": self.attribute.id, + "value_ids": [ + ( + 0, + 0, + { + "attribute_id": self.attribute.id, + "name": "test value 1", + }, + ), + ( + 0, + 0, + { + "attribute_id": self.attribute.id, + "name": "test value 2", + }, + ), + ], + }, + ) + ] + } + ) + self.assertEqual(product.net_weight, 0.0) + + def test_create_product_product(self): + product_form = Form(self.env["product.product"]) + product_form.name = "Test net weight" + product_form.net_weight = 25.0 + product = product_form.save() + self.assertEqual(product.net_weight, 25.0) + self.assertEqual(product.product_variant_id.net_weight, 25.0) + + def test_product_constraint(self): + with self.assertRaises(ValidationError): + self.env["product.product"].create( + {"name": "Test net weight", "net_weight": 25.0, "weight": 22.0} + ) 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 00000000000..84f93fd6b50 --- /dev/null +++ b/product_net_weight/views/view_product_product.xml @@ -0,0 +1,36 @@ + + + + + + product.product + + + + + + + + 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 00000000000..3c9ce07be21 --- /dev/null +++ b/product_net_weight/views/view_product_template.xml @@ -0,0 +1,33 @@ + + + + + + product.template + + + + + + + +