-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ADD] product_dimension_net
- Loading branch information
Showing
10 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
===================== | ||
Product Dimension Net | ||
===================== | ||
|
||
Net product dimensions | ||
|
||
Refers to product dimension when it is outside of its retail package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 Akretion | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Product Dimension Net", | ||
"summary": """ | ||
Net product dimensions""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Akretion", | ||
"website": "https://github.com/akretion/ak-odoo-incubator", | ||
"depends": ["product_dimension"], | ||
"data": [ | ||
"views/product_product.xml", | ||
], | ||
"demo": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import product_product |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2023 Akretion | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class ProductProduct(models.Model): | ||
_inherit = "product.product" | ||
|
||
product_length_net = fields.Float( | ||
"Longueur (net)", help="Longueur de l'article en dehors de son emballage" | ||
) | ||
product_height_net = fields.Float( | ||
"Hauteur (net)", help="Hauteur de l'article en dehors de son emballage" | ||
) | ||
product_width_net = fields.Float( | ||
"Largeur (net)", help="Largeur de l'article en dehors de son emballage" | ||
) | ||
volume_net = fields.Float( | ||
string="Volume (net)", | ||
help="Volume de l'article en dehors de son emballage", | ||
compute="_compute_volume_net", | ||
readonly=False, | ||
store=True, | ||
) | ||
|
||
@api.depends( | ||
"product_length_net", | ||
"product_height_net", | ||
"product_width_net", | ||
"dimensional_uom_id", | ||
) | ||
def _compute_volume_net(self): | ||
template_obj = self.env["product.template"] | ||
for product in self: | ||
product.volume = template_obj._calc_volume( | ||
product.product_length_net, | ||
product.product_height_net, | ||
product.product_width_net, | ||
product.dimensional_uom_id, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2023 Akretion | ||
# 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" | ||
|
||
product_length_net = fields.Float( | ||
related="product_variant_ids.product_length_net", readonly=False | ||
) | ||
product_height_net = fields.Float( | ||
related="product_variant_ids.product_height_net", readonly=False | ||
) | ||
product_width_net = fields.Float( | ||
related="product_variant_ids.product_width_net", readonly=False | ||
) | ||
volume_net = fields.Float( | ||
string="Volume (net)", | ||
compute="_compute_volume_net", | ||
readonly=False, | ||
store=True, | ||
) | ||
|
||
@api.depends( | ||
"product_length", "product_height", "product_width", "dimensional_uom_id" | ||
) | ||
def _compute_volume_net(self): | ||
for template in self: | ||
template.volume = template._calc_volume( | ||
template.product_length_net, | ||
template.product_height_net, | ||
template.product_width_net, | ||
template.dimensional_uom_id, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Akretion | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="product_normal_form_view"> | ||
<field name="model">product.product</field> | ||
<field name="inherit_id" ref="product.product_normal_form_view" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[@name='dimensions']" position="after"> | ||
<group string="Dimensions (net)" name="dimensions_net" colspan="2"> | ||
<field name="product_length_net" /> | ||
<field name="product_height_net" /> | ||
<field name="product_width_net" /> | ||
<field name="volume_net" /> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2023 Akretion | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="product_template_form_view_dimensions"> | ||
<field name="model">product.template</field> | ||
<field | ||
name="inherit_id" | ||
ref="product_dimension.product_template_only_form_view" | ||
/> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//page[@name='description']" position="inside"> | ||
<group | ||
string="Dimensions (net = sans packaging)" | ||
name="dimensions_net" | ||
colspan="2" | ||
attrs="{'invisible': [('product_variant_count', '>', 1)]}" | ||
> | ||
<field name="product_length_net" /> | ||
<field name="product_height_net" /> | ||
<field name="product_width_net" /> | ||
<field name="volume_net" /> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
|
||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../product_dimension_net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |