From b780a4e81dd3777f361acc7b5c9f458efafc0afb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 31 Jan 2017 16:37:34 +0100 Subject: [PATCH] Use weight from stock_shipment_measurements issue6157 review31021002 --- INSTALL | 1 + account.py | 16 ++-------------- tryton.cfg | 1 + 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/INSTALL b/INSTALL index a333c18f5c..91269ed19a 100644 --- a/INSTALL +++ b/INSTALL @@ -9,6 +9,7 @@ Prerequisites * trytond_account_stock_landed_cost (http://www.tryton.org/) * trytond_product (http://www.tryton.org/) * trytond_product_measurements (http://www.tryton.org/) + * trytond_stock_shipment_measurements (http://www.tryton.org/) Installation ------------ diff --git a/account.py b/account.py index e89a22945e..861d164c2b 100644 --- a/account.py +++ b/account.py @@ -2,7 +2,7 @@ # this repository contains the full copyright notices and license terms. from decimal import Decimal -from trytond.pool import PoolMeta, Pool +from trytond.pool import PoolMeta __all__ = ['LandedCost'] @@ -21,25 +21,13 @@ class LandedCost: def _get_weight_factors(self): "Return the factor for each move based on weight" - pool = Pool() - ModelData = pool.get('ir.model.data') - Uom = pool.get('product.uom') - - kg = Uom(ModelData.get_id('product', 'uom_kilogram')) moves = [m for s in self.shipments for m in s.incoming_moves if m.state != 'cancel'] sum_weight = Decimal(0) weights = {} for move in moves: - if not move.product.weight: - weight = 0 - else: - weight = Uom.compute_qty( - move.product.weight_uom, - move.product.weight * move.internal_quantity, - kg, round=False) - weight = Decimal(str(weight)) + weight = Decimal(str(move.internal_weight or 0)) weights[move.id] = weight sum_weight += weight factors = {} diff --git a/tryton.cfg b/tryton.cfg index 245b41b4e9..fffc0f828d 100644 --- a/tryton.cfg +++ b/tryton.cfg @@ -5,3 +5,4 @@ depends: ir product product_measurements + stock_shipment_measurements