forked from OCA/stock-logistics-warehouse
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by jgrandguillaume
- Loading branch information
Showing
10 changed files
with
103 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,2 @@ | ||
product-attribute https://github.com/grindtildeath/product-attribute 13.0-mig-product_packaging_dimension | ||
stock-logistics-workflow https://github.com/grindtildeath/stock-logistics-workflow 13.0-mig-stock_quant_package_product_packaging |
1 change: 1 addition & 0 deletions
1
setup/stock_quant_package_dimension/odoo/addons/stock_quant_package_dimension
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 @@ | ||
../../../../stock_quant_package_dimension |
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, | ||
) |
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,20 @@ | ||
# Copyright 2019 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
{ | ||
"name": "Stock Quant Package Dimension", | ||
"summary": "Use dimensions on packages", | ||
"version": "13.0.1.0.0", | ||
"development_status": "Alpha", | ||
"category": "Warehouse Management", | ||
"website": "https://github.com/OCA/stock-logistics-workflow", | ||
"author": "Camptocamp, Odoo Community Association (OCA)", | ||
"license": "AGPL-3", | ||
"application": False, | ||
"installable": True, | ||
"depends": [ | ||
"stock", | ||
"product_packaging_dimension", | ||
"stock_quant_package_product_packaging", | ||
], | ||
"data": ["views/stock_quant_package.xml"], | ||
} |
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 stock_quant_package |
51 changes: 51 additions & 0 deletions
51
stock_quant_package_dimension/models/stock_quant_package.py
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,51 @@ | ||
# Copyright 2019 Camptocamp SA | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl) | ||
from odoo import api, fields, models | ||
|
||
|
||
class StockQuantPackage(models.Model): | ||
_inherit = "stock.quant.package" | ||
|
||
pack_weight = fields.Float("Weight (kg)") | ||
# lngth IS NOT A TYPO: https://github.com/odoo/odoo/issues/41353 | ||
lngth = fields.Integer("Length (mm)", help="length in millimeters") | ||
width = fields.Integer("Width (mm)", help="width in millimeters") | ||
height = fields.Integer("Height (mm)", help="height in millimeters") | ||
volume = fields.Float( | ||
"Volume (m³)", | ||
digits=(8, 4), | ||
compute="_compute_volume", | ||
readonly=True, | ||
store=False, | ||
help="volume in cubic meters", | ||
) | ||
|
||
@api.depends("lngth", "width", "height") | ||
def _compute_volume(self): | ||
for pack in self: | ||
pack.volume = (pack.lngth * pack.width * pack.height) / 1000.0 ** 3 | ||
|
||
def auto_assign_packaging(self): | ||
self = self.with_context(_auto_assign_packaging=True) | ||
res = super().auto_assign_packaging() | ||
return res | ||
|
||
def write(self, vals): | ||
res = super().write(vals) | ||
if self.env.context.get("_auto_assign_packaging") and vals.get( | ||
"product_packaging_id" | ||
): | ||
for package in self: | ||
package.onchange_product_packaging_id() | ||
return res | ||
|
||
@api.onchange("product_packaging_id") | ||
def onchange_product_packaging_id(self): | ||
if self.product_packaging_id: | ||
vals = self.product_packaging_id.read( | ||
fields=["lngth", "width", "height", "max_weight"] | ||
)[0] | ||
vals["pack_weight"] = vals["max_weight"] | ||
vals.pop("id") | ||
vals.pop("max_weight") | ||
self.update(vals) |
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 @@ | ||
* Akim Juillerat <akim.juillerat@camptocamp.com> |
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 @@ | ||
This module adds dimension fields on stock packages. |
19 changes: 19 additions & 0 deletions
19
stock_quant_package_dimension/views/stock_quant_package.xml
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,19 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<odoo> | ||
<record id="view_quant_package_form_inherit" model="ir.ui.view"> | ||
<field name="name">stock.quant.package.form.inherit</field> | ||
<field name="model">stock.quant.package</field> | ||
<field name="inherit_id" ref="stock.view_quant_package_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath expr="//group[field[@name='company_id']]" position="after"> | ||
<group name="dimensions" string="Dimensions"> | ||
<field name="lngth" /> | ||
<field name="width" /> | ||
<field name="height" /> | ||
<field name="pack_weight" /> | ||
<field name="volume" /> | ||
</group> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |