Skip to content
Open
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
164 changes: 164 additions & 0 deletions product_uom_reference/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
=====================
Product uom reference
=====================

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

.. |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/18.0/product_uom_reference
: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_uom_reference
: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 allows you to display a reference price for the initial unit
of measure on product labels.

Example: Product: Meat Price: $100 per kg Reference price: $50 per pound

**Table of contents**

.. contents::
:local:

Configuration
=============

Enable unit of measure role
---------------------------

1. Go to Settings > Users & Companies > Users
2. Create or edit a user
3. Find the Manage Multiple Units of Measure role and select it
4. Save

|ROLE_UOM_IN_USER|

Other option:

1. Go to Settings
2. Option Inventory
3. Find the option Units of Measure and select it
4. Save

|OPTION_UOM_IN_SETTINGS|

.. |ROLE_UOM_IN_USER| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/rol_uom_in_user.png
.. |OPTION_UOM_IN_SETTINGS| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/option_uom_in_settings.png

Usage
=====

Add Uom Reference
-----------------

1. Go to Inventory > Configuration > Product UOM Reference
2. Add a new item
3. Save

|CREATE_REFERENCE|

Configure Uom Reference in Product
----------------------------------

1. Go to Inventory > Products > Products
2. Create a new product
3. Select a reference unit. Note that only units whose initial unit of
measurement matches the product's unit of measurement will be
displayed
4. Save

|CONFIGURE_REFERENCE_PRODUCT|

Print labels with Uom Reference
-------------------------------

1. Follow the steps `Configure Uom Reference in
Product <#configure-uom-reference-in-product>`__

2. Press the Print labels button and select the type of label you want
to print

3. Press the button Confirm

4. Upon confirmation, the product label is generated, in which the price
of the reference unit is shown below the product price, taking into
account the ratio configured in `Add Uom
Reference <#add-uom-reference>`__.

Example:

- Price based on initial unit of measure (kg): $100 per kg
- Reference unit of measure ratio: 2.0
- Price based on reference unit of measure (lb): $50 per lb

|PRODUCT_PRINT_LABELS|

|REPORT_PRINT_LABELS|

|REPORT_PRINT_LABELS_ZPL|

.. |CREATE_REFERENCE| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/create_reference.png
.. |CONFIGURE_REFERENCE_PRODUCT| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/configure_reference_product.png
.. |PRODUCT_PRINT_LABELS| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/product_print_labels.png
.. |REPORT_PRINT_LABELS| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/report_print_labels.png
.. |REPORT_PRINT_LABELS_ZPL| image:: https://raw.githubusercontent.com/OCA/product-attribute/18.0/product_uom_reference/static/img/readme/report_print_labels_zpl.png

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_uom_reference%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
-------

* Binhex

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

- [Binhex Cloud] (https://www.binhex.cloud):

- Edilio Escalona Almira e.escalona@binhex.cloud

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_uom_reference>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 4 additions & 0 deletions product_uom_reference/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import models
20 changes: 20 additions & 0 deletions product_uom_reference/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

{
"name": "Product uom reference",
"version": "18.0.1.0.0",
"category": "Product",
"summary": "Configure reference unit of measurement",
"author": "Binhex, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/product-attribute",
"license": "AGPL-3",
"depends": ["stock"],
"data": [
"security/ir.model.access.csv",
"views/product_uom_reference_views.xml",
"views/product_template_views.xml",
"views/product_uom_reference_ratio_menu_views.xml",
"report/product_product_templates.xml",
],
}
6 changes: 6 additions & 0 deletions product_uom_reference/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from . import product_uom_reference
from . import product_product
from . import product_template
16 changes: 16 additions & 0 deletions product_uom_reference/models/product_product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import models


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

def _get_price_uom_reference(self, product, pricelist):
product_price = pricelist._get_product_price(
product, 1, currency=pricelist.currency_id or product.currency_id
)
if product.uom_reference_id:
return product_price / product.uom_reference_id.ratio
return False
12 changes: 12 additions & 0 deletions product_uom_reference/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

from odoo import fields, models


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

uom_reference_id = fields.Many2one(
"product.uom.reference", domain="[('uom_id', '=', uom_id)]"
)
34 changes: 34 additions & 0 deletions product_uom_reference/models/product_uom_reference.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2025 Binhex <https://www.binhex.cloud>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).

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


class ProductUomReference(models.Model):
_name = "product.uom.reference"
_description = "Product UOM Reference"

name = fields.Char(required=True, translate=True)
uom_id = fields.Many2one("uom.uom", required=True)
uom_reference_id = fields.Many2one("uom.uom", required=True)
ratio = fields.Float(required=True)

def _compute_display_name(self):
for uom_reference in self:
uom_reference.display_name = (
f"{uom_reference.name} "
f"[{uom_reference.uom_id.name}-"
f"{uom_reference.uom_reference_id.name}]"
)

@api.constrains("uom_id", "uom_reference_id")
def _check_uom_reference(self):
for uom_reference in self:
if uom_reference.uom_id == uom_reference.uom_reference_id:
raise ValidationError(
self.env._(
"The unit of measurement and the reference "
"unit of measurement must be different."
)
)
3 changes: 3 additions & 0 deletions product_uom_reference/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
18 changes: 18 additions & 0 deletions product_uom_reference/readme/CONFIGURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Enable unit of measure role
----------------------------

1. Go to Settings > Users & Companies > Users
2. Create or edit a user
3. Find the Manage Multiple Units of Measure role and select it
4. Save

![ROLE_UOM_IN_USER](../static/img/readme/rol_uom_in_user.png)

Other option:

1. Go to Settings
2. Option Inventory
3. Find the option Units of Measure and select it
4. Save

![OPTION_UOM_IN_SETTINGS](../static/img/readme/option_uom_in_settings.png)
2 changes: 2 additions & 0 deletions product_uom_reference/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- [Binhex Cloud] (https://www.binhex.cloud):
- Edilio Escalona Almira <e.escalona@binhex.cloud>
6 changes: 6 additions & 0 deletions product_uom_reference/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This module allows you to display a reference price for the initial unit of measure on product labels.

Example:
Product: Meat
Price: $100 per kg
Reference price: $50 per pound
36 changes: 36 additions & 0 deletions product_uom_reference/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Add Uom Reference
----------------------------------------
1. Go to Inventory > Configuration > Product UOM Reference
2. Add a new item
3. Save

![CREATE_REFERENCE](../static/img/readme/create_reference.png)

Configure Uom Reference in Product
-------------------------------------------
1. Go to Inventory > Products > Products
2. Create a new product
3. Select a reference unit. Note that only units whose initial unit of measurement
matches the product's unit of measurement will be displayed
4. Save

![CONFIGURE_REFERENCE_PRODUCT](../static/img/readme/configure_reference_product.png)

Print labels with Uom Reference
-------------------------------------
1. Follow the steps [Configure Uom Reference in Product](#configure-uom-reference-in-product)
2. Press the Print labels button and select the type of label you want to print
3. Press the button Confirm
4. Upon confirmation, the product label is generated, in which the price of the reference unit
is shown below the product price, taking into account the ratio configured in [Add Uom Reference](#add-uom-reference).

Example:
* Price based on initial unit of measure (kg): $100 per kg
* Reference unit of measure ratio: 2.0
* Price based on reference unit of measure (lb): $50 per lb

![PRODUCT_PRINT_LABELS](../static/img/readme/product_print_labels.png)

![REPORT_PRINT_LABELS](../static/img/readme/report_print_labels.png)

![REPORT_PRINT_LABELS_ZPL](../static/img/readme/report_print_labels_zpl.png)
Loading