Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ addon | version | maintainers | summary
[product_cost_security](product_cost_security/) | 18.0.1.0.0 | <a href='https://github.com/sergio-teruel'><img src='https://github.com/sergio-teruel.png' width='32' height='32' style='border-radius:50%;' alt='sergio-teruel'/></a> <a href='https://github.com/rafaelbn'><img src='https://github.com/rafaelbn.png' width='32' height='32' style='border-radius:50%;' alt='rafaelbn'/></a> <a href='https://github.com/yajo'><img src='https://github.com/yajo.png' width='32' height='32' style='border-radius:50%;' alt='yajo'/></a> | Product cost security restriction view
[product_customerinfo](product_customerinfo/) | 18.0.1.1.0 | <a href='https://github.com/luisg123v'><img src='https://github.com/luisg123v.png' width='32' height='32' style='border-radius:50%;' alt='luisg123v'/></a> | Allows to define prices for customers in the products
[product_dimension](product_dimension/) | 18.0.1.0.0 | | Product Dimension
[product_drained_weight](product_drained_weight/) | 18.0.1.0.0 | | Add 'Drained Weight' on product models
[product_get_price_helper](product_get_price_helper/) | 18.0.1.1.0 | | This module provides a helper function to compute product prices.
[product_list_price_from_pricelist](product_list_price_from_pricelist/) | 18.0.1.0.0 | <a href='https://github.com/carlos-lopez-tecnativa'><img src='https://github.com/carlos-lopez-tecnativa.png' width='32' height='32' style='border-radius:50%;' alt='carlos-lopez-tecnativa'/></a> | Compute product sales price from a pricelist
[product_logistics_uom](product_logistics_uom/) | 18.0.1.1.0 | <a href='https://github.com/hparfr'><img src='https://github.com/hparfr.png' width='32' height='32' style='border-radius:50%;' alt='hparfr'/></a> | Configure product weights and volume UoM
Expand Down
93 changes: 93 additions & 0 deletions product_drained_weight/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

=========================
Products - Drained Weight
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:348294d263b965a6ff4ce505cf6272c9624b4b701d0f009cf101d39d3c74e548
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/license-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/18.0/product_drained_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-18-0/product-attribute-18-0-product_drained_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=18.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the functionality of stock module to support Drained
Weight. (fluid excluded)

You could be interested by another modules like as:

- product_net_weight

**Table of contents**

.. contents::
:local:

Usage
=====

- Go to 'Inventory > Master Data > Product' and edit items.
- Go to 'Inventory' tab, and fill the "Drained Weight" value.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/product-attribute/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 <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_drained_weight%0Aversion:%2018.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Tecnativa

Contributors
------------

- `Tecnativa <https://www.tecnativa.com>`__:

- 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.

This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/18.0/product_drained_weight>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions product_drained_weight/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
17 changes: 17 additions & 0 deletions product_drained_weight/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright 2022 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Products - Drained Weight",
"summary": "Add 'Drained Weight' on product models",
"version": "18.0.1.0.0",
"category": "Product",
"author": "Tecnativa,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"license": "AGPL-3",
"depends": ["product_net_weight"],
"data": [
"views/view_product_product.xml",
"views/view_product_template.xml",
],
"installable": True,
}
46 changes: 46 additions & 0 deletions product_drained_weight/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_drained_weight
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-01-11 12:25+0000\n"
"PO-Revision-Date: 2023-01-11 13:26+0100\n"
"Last-Translator: Sergio Teruel <sergio.teruel@tecnativa.com>\n"
"Language-Team: \n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.0.1\n"

#. module: product_drained_weight
#: model:ir.model.fields,field_description:product_drained_weight.field_product_product__drained_weight
#: model:ir.model.fields,field_description:product_drained_weight.field_product_template__drained_weight
msgid "Drained Weight"
msgstr "Peso escurrido"

#. module: product_drained_weight
#: model:ir.model.fields,help:product_drained_weight.field_product_product__drained_weight
#: model:ir.model.fields,help:product_drained_weight.field_product_template__drained_weight
msgid "Drained Weight of the product, fluid excluded."
msgstr "Peso escurrido del producto, excluido el líquido."

#. module: product_drained_weight
#: model:ir.model,name:product_drained_weight.model_product_product
msgid "Product"
msgstr "Producto"

#. module: product_drained_weight
#: model:ir.model,name:product_drained_weight.model_product_template
msgid "Product Template"
msgstr "Plantilla de producto"

#. module: product_drained_weight
#: code:addons/product_drained_weight/models/product_product.py:0
#, python-format
msgid "The drained weight of product must be lower than net_weight."
msgstr "El peso escurrido del producto debe ser menor al peso neto."
45 changes: 45 additions & 0 deletions product_drained_weight/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_drained_weight
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 15.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2023-11-01 14:37+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\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_drained_weight
#: model:ir.model.fields,field_description:product_drained_weight.field_product_product__drained_weight
#: model:ir.model.fields,field_description:product_drained_weight.field_product_template__drained_weight
msgid "Drained Weight"
msgstr "Peso sgocciolato"

#. module: product_drained_weight
#: model:ir.model.fields,help:product_drained_weight.field_product_product__drained_weight
#: model:ir.model.fields,help:product_drained_weight.field_product_template__drained_weight
msgid "Drained Weight of the product, fluid excluded."
msgstr "Peso sgocciolato del prodotto, liquido escluso."

#. module: product_drained_weight
#: model:ir.model,name:product_drained_weight.model_product_product
msgid "Product"
msgstr "Prodotto"

#. module: product_drained_weight
#: model:ir.model,name:product_drained_weight.model_product_template
msgid "Product Template"
msgstr "Modello prodotto"

#. module: product_drained_weight
#: code:addons/product_drained_weight/models/product_product.py:0
#, python-format
msgid "The drained weight of product must be lower than net_weight."
msgstr "Il peso sgocciolato del prodotto deve essere inferiore al peso netto."
42 changes: 42 additions & 0 deletions product_drained_weight/i18n/product_drained_weight.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_drained_weight
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.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_drained_weight
#: model:ir.model.fields,field_description:product_drained_weight.field_product_product__drained_weight
#: model:ir.model.fields,field_description:product_drained_weight.field_product_template__drained_weight
msgid "Drained Weight"
msgstr ""

#. module: product_drained_weight
#: model:ir.model.fields,help:product_drained_weight.field_product_product__drained_weight
#: model:ir.model.fields,help:product_drained_weight.field_product_template__drained_weight
msgid "Drained Weight of the product, fluid excluded."
msgstr ""

#. module: product_drained_weight
#: model:ir.model,name:product_drained_weight.model_product_template
msgid "Product"
msgstr ""

#. module: product_drained_weight
#: model:ir.model,name:product_drained_weight.model_product_product
msgid "Product Variant"
msgstr ""

#. module: product_drained_weight
#. odoo-python
#: code:addons/product_drained_weight/models/product_product.py:0
msgid "The drained weight of product must be lower than net_weight."
msgstr ""
2 changes: 2 additions & 0 deletions product_drained_weight/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import product_product
from . import product_template
24 changes: 24 additions & 0 deletions product_drained_weight/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2022 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
from odoo.exceptions import ValidationError


class ProductProduct(models.Model):
_inherit = "product.product"

drained_weight = fields.Float(
digits="Stock Weight",
help="Drained Weight of the product, fluid excluded.",
)

@api.constrains("drained_weight", "net_weight")
def _check_drained_weight(self):
for product in self:
if product.net_weight and product.drained_weight > product.net_weight:
raise ValidationError(
self.env._(
"The drained weight of product must be lower than net_weight."
)
)
41 changes: 41 additions & 0 deletions product_drained_weight/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2022 Tecnativa - Sergio Teruel
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

drained_weight = fields.Float(
compute="_compute_drained_weight",
inverse="_inverse_drained_weight",
digits="Stock Weight",
help="Drained Weight of the product, fluid excluded.",
store=True,
)

@api.depends("product_variant_ids", "product_variant_ids.drained_weight")
def _compute_drained_weight(self):
unique_variants = self.filtered(lambda tmpl: tmpl.product_variant_count == 1)
for template in unique_variants:
template.drained_weight = template.product_variant_ids.drained_weight
for template in self - unique_variants:
template.drained_weight = 0.0

def _inverse_drained_weight(self):
for template in self:
if len(template.product_variant_ids) == 1:
template.product_variant_ids.drained_weight = template.drained_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=False):
related_vals = {}
if vals.get("drained_weight"):
related_vals["drained_weight"] = vals["drained_weight"]
if related_vals:
template.write(related_vals)
return templates
3 changes: 3 additions & 0 deletions product_drained_weight/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
2 changes: 2 additions & 0 deletions product_drained_weight/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Tecnativa](https://www.tecnativa.com):
- Sergio Teruel
6 changes: 6 additions & 0 deletions product_drained_weight/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module extends the functionality of stock module to support Drained
Weight. (fluid excluded)

You could be interested by another modules like as:

- product_net_weight
2 changes: 2 additions & 0 deletions product_drained_weight/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Go to 'Inventory \> Master Data \> Product' and edit items.
- Go to 'Inventory' tab, and fill the "Drained Weight" value.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading