Skip to content

Commit

Permalink
[IMP] product_dimension: Works with many variants and split Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
clementmbr authored and FrancoMaxime committed Oct 11, 2022
1 parent e2f97c1 commit adb14b0
Show file tree
Hide file tree
Showing 8 changed files with 530 additions and 44 deletions.
77 changes: 51 additions & 26 deletions product_dimension/README.rst
Original file line number Diff line number Diff line change
@@ -1,67 +1,92 @@
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3

=================
Product Dimension
=================

This module extends the functionality of product to support
dimensions (length, width and height). Find the volume
automatically when you change one of these dimensions.
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |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/12.0/product_dimension
: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-12-0/product-attribute-12-0-product_dimension
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/135/12.0
:alt: Try me on Runbot

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

This module extends the functionality of product to support dimensions (length, width and height).
Also computes the volume automatically when you change one of these dimensions.

This module was previously hosted on https://github.com/ingadhoc/odoo-addons
and before that on https://launchpad.net/~ingenieria-adhoc.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:
To use this module :

#. Go to product view and enter dimensions.
#. Go to Product View > Inventory
#. Edit Dimensional UoM and the three dimensions

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/135/11.0
If the product has got more than one variant, the dimensions (and the volume) are visible only in the variants.

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 smash it by providing detailed and welcomed feedback.
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 smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/product-attribute/issues/new?body=module:%20product_dimension%0Aversion:%2012.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
=======

Images
------
Authors
~~~~~~~

* Odoo Community Association: `Icon <https://odoo-community.org/logo.png>`_.
* brain-tec AG
* ADHOC SA
* Camptocamp SA

Contributors
------------
~~~~~~~~~~~~

* Juan Jose Scarafia <[email protected]>
* Leonardo Pistone <[email protected]>
* Denis Leemann <[email protected]>
* Kumar Aberer <[email protected]>

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

Maintainer
----------
This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

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.

To contribute to this module, please visit https://odoo-community.org.
This module is part of the `OCA/product-attribute <https://github.com/OCA/product-attribute/tree/12.0/product_dimension>`_ 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_dimension/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'author': 'brain-tec AG, ADHOC SA, Camptocamp SA, '
'Odoo Community Association (OCA)',
'license': 'AGPL-3',
'website': 'https://github.com/OCA/product-attribute',
'depends': ['product'],
'data': ['views/product_view.xml'],
'installable': True,
Expand Down
19 changes: 13 additions & 6 deletions product_dimension/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright 2015-2016 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).


from odoo import models, fields, api


Expand All @@ -27,7 +26,9 @@ def _get_dimension_uom_domain(self):
'uom.uom',
'Dimensional UoM',
domain=lambda self: self._get_dimension_uom_domain(),
help='UoM for length, height, width')
help='UoM for length, height, width',
default=lambda self: self.env.ref('uom.product_uom_meter'),
)


class ProductTemplate(models.Model):
Expand Down Expand Up @@ -58,10 +59,16 @@ def convert_to_meters(self, measure, dimensional_uom):
round=False,
)

# Define all the related fields in product.template with 'readonly=False'
# to be able to modify the values from product.template.
dimensional_uom_id = fields.Many2one(
'uom.uom',
'Dimensional UoM',
related='product_variant_ids.dimensional_uom_id',
help='UoM for length, height, width',
readonly=False,
)

length = fields.Float(related='product_variant_ids.length', readonly=False)
height = fields.Float(related='product_variant_ids.height', readonly=False)
width = fields.Float(related='product_variant_ids.width', readonly=False)
dimensional_uom_id = fields.Many2one(
'uom.uom',
'Dimensional UoM', related='product_variant_ids.dimensional_uom_id',
help='UoM for length, height, width')
4 changes: 4 additions & 0 deletions product_dimension/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* Juan Jose Scarafia <[email protected]>
* Leonardo Pistone <[email protected]>
* Denis Leemann <[email protected]>
* Kumar Aberer <[email protected]>
5 changes: 5 additions & 0 deletions product_dimension/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module extends the functionality of product to support dimensions (length, width and height).
Also computes the volume automatically when you change one of these dimensions.

This module was previously hosted on https://github.com/ingadhoc/odoo-addons
and before that on https://launchpad.net/~ingenieria-adhoc.
6 changes: 6 additions & 0 deletions product_dimension/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To use this module :

#. Go to Product View > Inventory
#. Edit Dimensional UoM and the three dimensions

If the product has got more than one variant, the dimensions (and the volume) are visible only in the variants.
Loading

0 comments on commit adb14b0

Please sign in to comment.