From ca7e7604d5ff6b6f34c8c2fbd00fee4465c2dc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 30 Jan 2022 01:32:51 +0100 Subject: [PATCH] Add packages weight issue11123 review373001002 --- 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(+) create mode 100644 view/shipment_form.xml create mode 100644 view/shipment_form_package.xml create mode 100644 view/shipment_list_package.xml diff --git a/CHANGELOG b/CHANGELOG index af9df97998..2f84fb1a68 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add packages weight * Add support for Python 3.10 * Remove support for Python 3.6 diff --git a/__init__.py b/__init__.py index c7603f3abf..4e58eb23db 100644 --- a/__init__.py +++ b/__init__.py @@ -18,6 +18,8 @@ def register(): 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 --git a/stock.py b/stock.py index de05144e72..974c893e5c 100644 --- a/stock.py +++ b/stock.py @@ -294,3 +294,23 @@ class Package(MeasurementsMixin, object, metaclass=PoolMeta): 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 --git a/stock.xml b/stock.xml index 058614fc81..9809872111 100644 --- a/stock.xml +++ b/stock.xml @@ -8,21 +8,42 @@ this repository contains the full copyright notices and license terms. --> shipment_list + + stock.shipment.in + + shipment_form + stock.shipment.in.return shipment_list + + stock.shipment.in.return + + shipment_form + stock.shipment.out shipment_list + + stock.shipment.out + + shipment_form + stock.shipment.out.return shipment_list + + stock.shipment.out.return + + shipment_form + + @@ -40,5 +61,31 @@ this repository contains the full copyright notices and license terms. --> package_form + + + stock.shipment.in.return + + + shipment_list_package + + + stock.shipment.in.return + + + shipment_form_package + + + + stock.shipment.out + + + shipment_list_package + + + stock.shipment.out + + + shipment_form_package + diff --git a/view/shipment_form.xml b/view/shipment_form.xml new file mode 100644 index 0000000000..26a6c4468c --- /dev/null +++ b/view/shipment_form.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/view/shipment_form_package.xml b/view/shipment_form_package.xml new file mode 100644 index 0000000000..edcf4f0040 --- /dev/null +++ b/view/shipment_form_package.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/view/shipment_list_package.xml b/view/shipment_list_package.xml new file mode 100644 index 0000000000..a9fbf209c1 --- /dev/null +++ b/view/shipment_list_package.xml @@ -0,0 +1,8 @@ + + + + + + +