changeset 28194f054878 in modules/stock_shipment_measurements:default
details:
https://hg.tryton.org/modules/stock_shipment_measurements?cmd=changeset&node=28194f054878
description:
Add packages weight
issue11123
review373001002
diffstat:
CHANGELOG | 1 +
__init__.py | 2 +
stock.py | 20 +++++++++++++++++
stock.xml | 47 ++++++++++++++++++++++++++++++++++++++++++
view/shipment_form.xml | 13 +++++++++++
view/shipment_form_package.xml | 9 ++++++++
view/shipment_list_package.xml | 8 +++++++
7 files changed, 100 insertions(+), 0 deletions(-)
diffs (167 lines):
diff -r b1228f8f5b6e -r 28194f054878 CHANGELOG
--- a/CHANGELOG Thu Jan 20 19:00:53 2022 +0100
+++ b/CHANGELOG Sun Jan 30 01:32:51 2022 +0100
@@ -1,3 +1,4 @@
+* Add packages weight
* Add support for Python 3.10
* Remove support for Python 3.6
diff -r b1228f8f5b6e -r 28194f054878 __init__.py
--- a/__init__.py Thu Jan 20 19:00:53 2022 +0100
+++ b/__init__.py Sun Jan 30 01:32:51 2022 +0100
@@ -18,6 +18,8 @@
module='stock_shipment_measurements', type_='model')
Pool.register(
stock.Package,
+ stock.ShipmentOutPackage,
+ stock.ShipmentInReturnPackage,
module='stock_shipment_measurements', type_='model',
depends=['stock_package'])
Pool.register(
diff -r b1228f8f5b6e -r 28194f054878 stock.py
--- a/stock.py Thu Jan 20 19:00:53 2022 +0100
+++ b/stock.py Sun Jan 30 01:32:51 2022 +0100
@@ -294,3 +294,23 @@
self.packaging_weight_uom, self.packaging_weight, kg,
round=False)
return measurement
+
+
+class MeasurementsPackageMixin:
+ __slots__ = ()
+
+ packages_weight = fields.Function(
+ fields.Float("Packages Weight", digits=None,
+ help="The total weight of the packages in kg."),
+ 'get_packages_weight')
+
+ def get_packages_weight(self, name):
+ return sum(p.total_weight for p in self.root_packages)
+
+
+class ShipmentOutPackage(MeasurementsPackageMixin, metaclass=PoolMeta):
+ __name__ = 'stock.shipment.out'
+
+
+class ShipmentInReturnPackage(MeasurementsPackageMixin, metaclass=PoolMeta):
+ __name__ = 'stock.shipment.in.return'
diff -r b1228f8f5b6e -r 28194f054878 stock.xml
--- a/stock.xml Thu Jan 20 19:00:53 2022 +0100
+++ b/stock.xml Sun Jan 30 01:32:51 2022 +0100
@@ -8,21 +8,42 @@
<field name="inherit" ref="stock.shipment_in_view_tree"/>
<field name="name">shipment_list</field>
</record>
+ <record model="ir.ui.view" id="shipment_in_view_form">
+ <field name="model">stock.shipment.in</field>
+ <field name="inherit" ref="stock.shipment_in_view_form"/>
+ <field name="name">shipment_form</field>
+ </record>
<record model="ir.ui.view" id="shipment_in_return_view_list">
<field name="model">stock.shipment.in.return</field>
<field name="inherit" ref="stock.shipment_in_return_view_tree"/>
<field name="name">shipment_list</field>
</record>
+ <record model="ir.ui.view" id="shipment_in_return_view_form">
+ <field name="model">stock.shipment.in.return</field>
+ <field name="inherit" ref="stock.shipment_in_return_view_form"/>
+ <field name="name">shipment_form</field>
+ </record>
<record model="ir.ui.view" id="shipment_out_view_list">
<field name="model">stock.shipment.out</field>
<field name="inherit" ref="stock.shipment_out_view_tree"/>
<field name="name">shipment_list</field>
</record>
+ <record model="ir.ui.view" id="shipment_out_view_form">
+ <field name="model">stock.shipment.out</field>
+ <field name="inherit" ref="stock.shipment_out_view_form"/>
+ <field name="name">shipment_form</field>
+ </record>
<record model="ir.ui.view" id="shipment_out_return_view_list">
<field name="model">stock.shipment.out.return</field>
<field name="inherit" ref="stock.shipment_out_return_view_tree"/>
<field name="name">shipment_list</field>
</record>
+ <record model="ir.ui.view" id="shipment_out_return_view_form">
+ <field name="model">stock.shipment.out.return</field>
+ <field name="inherit" ref="stock.shipment_out_return_view_form"/>
+ <field name="name">shipment_form</field>
+ </record>
+
</data>
<data depends="stock_package">
<record model="ir.ui.view" id="package_view_tree">
@@ -40,5 +61,31 @@
<field name="inherit" ref="stock_package.package_view_form"/>
<field name="name">package_form</field>
</record>
+
+ <record model="ir.ui.view" id="shipment_in_return_view_list_package">
+ <field name="model">stock.shipment.in.return</field>
+ <field name="inherit" ref="stock.shipment_in_return_view_tree"/>
+ <field name="priority" eval="20"/>
+ <field name="name">shipment_list_package</field>
+ </record>
+ <record model="ir.ui.view" id="shipment_in_return_view_form_package">
+ <field name="model">stock.shipment.in.return</field>
+ <field name="inherit" ref="stock.shipment_in_return_view_form"/>
+ <field name="priority" eval="20"/>
+ <field name="name">shipment_form_package</field>
+ </record>
+
+ <record model="ir.ui.view" id="shipment_out_view_list_package">
+ <field name="model">stock.shipment.out</field>
+ <field name="inherit" ref="stock.shipment_out_view_tree"/>
+ <field name="priority" eval="20"/>
+ <field name="name">shipment_list_package</field>
+ </record>
+ <record model="ir.ui.view" id="shipment_out_view_form_package">
+ <field name="model">stock.shipment.out</field>
+ <field name="inherit" ref="stock.shipment_out_view_form"/>
+ <field name="priority" eval="20"/>
+ <field name="name">shipment_form_package</field>
+ </record>
</data>
</tryton>
diff -r b1228f8f5b6e -r 28194f054878 view/shipment_form.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/view/shipment_form.xml Sun Jan 30 01:32:51 2022 +0100
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath expr="//page[@id='other']" position="inside">
+ <separator id="measurements" colspan="4" string="Measurements"/>
+ <label name="weight"/>
+ <field name="weight"/>
+ <label name="volume"/>
+ <field name="volume"/>
+ <newline/>
+ </xpath>
+</data>
diff -r b1228f8f5b6e -r 28194f054878 view/shipment_form_package.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/view/shipment_form_package.xml Sun Jan 30 01:32:51 2022 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath expr="//field[@name='weight']" position="after">
+ <label name="packages_weight"/>
+ <field name="packages_weight"/>
+ </xpath>
+</data>
diff -r b1228f8f5b6e -r 28194f054878 view/shipment_list_package.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/view/shipment_list_package.xml Sun Jan 30 01:32:51 2022 +0100
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<data>
+ <xpath expr="/tree/field[@name='weight']" position="after">
+ <field name="packages_weight"/>
+ </xpath>
+</data>