From cb08557fad03d833666e86607fbaeb8d4a181498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 22 Aug 2023 13:18:33 +0200 Subject: [PATCH] Rename Uom to Unit for move and inventory Closes #2221 --- modules/account_invoice_stock/account.py | 2 +- modules/account_invoice_stock/stock.py | 4 +- modules/account_stock_anglo_saxon/stock.py | 25 ++-- modules/account_stock_continental/stock.py | 4 +- modules/account_stock_eu/stock.py | 15 +- modules/carrier_weight/common.py | 2 +- modules/commission/stock.py | 2 +- modules/product_cost_fifo/move.py | 10 +- modules/product_cost_fifo/product.py | 4 +- .../tests/scenario_product_cost_fifo.rst | 10 +- .../scenario_product_cost_fifo_no_in.rst | 6 +- .../tests/scenario_product_cost_fifo_uom.rst | 10 +- modules/product_cost_warehouse/stock.py | 2 +- modules/product_kit/common.py | 6 +- modules/product_kit/purchase.py | 2 +- modules/product_kit/sale.py | 2 +- modules/product_kit/stock.py | 2 +- modules/production/production.py | 19 +-- modules/purchase/purchase.py | 13 +- modules/purchase/view/move_list_shipment.xml | 2 +- .../tests/scenario_purchase_request.rst | 2 +- modules/purchase_secondary_unit/purchase.py | 2 +- modules/purchase_shipment_cost/stock.py | 5 +- modules/sale/sale.py | 13 +- modules/sale/view/move_list_shipment.xml | 2 +- modules/sale_gift_card/sale.py | 4 +- modules/sale_point/sale.py | 2 +- modules/sale_secondary_unit/sale.py | 2 +- modules/sale_shipment_tolerance/sale.py | 2 +- modules/sale_supply/sale.py | 8 +- modules/sale_supply_drop_shipment/stock.py | 12 +- modules/stock/CHANGELOG | 1 + modules/stock/delivery_note.fodt | 4 +- modules/stock/internal_shipment.fodt | 2 +- modules/stock/inventory.py | 34 ++--- modules/stock/move.py | 60 ++++---- modules/stock/picking_list.fodt | 2 +- modules/stock/product.py | 2 +- modules/stock/shipment.py | 24 ++-- modules/stock/supplier_restocking_list.fodt | 2 +- .../scenario_stock_average_cost_price.rst | 16 +-- .../stock/tests/scenario_stock_inventory.rst | 8 +- ...cenario_stock_inventory_empty_quantity.rst | 2 +- ..._stock_product_quantities_by_warehouse.rst | 8 +- .../stock/tests/scenario_stock_reporting.rst | 6 +- .../scenario_stock_shipment_in_return.rst | 2 +- ...o_stock_shipment_in_same_storage_input.rst | 2 +- .../scenario_stock_shipment_internal.rst | 2 +- .../tests/scenario_stock_shipment_out.rst | 8 +- ...shipment_out_return_same_storage_input.rst | 2 +- ...stock_shipment_out_same_storage_output.rst | 2 +- modules/stock/tests/test_module.py | 132 +++++++++--------- .../view/inventory_count_quantity_form.xml | 4 +- modules/stock/view/inventory_line_form.xml | 4 +- .../stock/view/inventory_line_list_simple.xml | 4 +- modules/stock/view/inventory_line_tree.xml | 4 +- modules/stock/view/move_form.xml | 4 +- modules/stock/view/move_list_shipment.xml | 2 +- modules/stock/view/move_list_shipment_in.xml | 2 +- modules/stock/view/move_tree.xml | 2 +- modules/stock/view/move_tree_simple.xml | 2 +- modules/stock_assign_manual/stock.py | 8 +- .../tests/scenario_stock_assign_manual.rst | 4 +- modules/stock_consignment/stock.py | 4 +- modules/stock_forecast/forecast.py | 2 +- modules/stock_forecast/tests/test_module.py | 8 +- modules/stock_lot/stock.py | 6 +- .../tests/scenario_stock_lot_assign_try.rst | 2 +- .../tests/scenario_stock_lot_shipment_out.rst | 2 +- modules/stock_lot/tests/test_module.py | 26 ++-- modules/stock_lot_sled/tests/test_module.py | 2 +- modules/stock_lot_unit/stock.py | 4 +- .../tests/scenario_stock_package.rst | 2 +- modules/stock_secondary_unit/stock.py | 24 ++-- modules/stock_shipment_measurements/stock.py | 26 ++-- .../tests/test_module.py | 8 +- modules/stock_split/stock.py | 23 +-- .../tests/scenario_stock_split_shipment.rst | 2 +- modules/stock_split/tests/test_module.py | 2 +- modules/stock_split/view/split_start_form.xml | 4 +- modules/stock_supply/shipment.py | 2 +- ...scenario_stock_supply_purchase_request.rst | 2 +- .../tests/test_module.py | 2 +- 83 files changed, 362 insertions(+), 348 deletions(-) diff --git a/modules/account_invoice_stock/account.py b/modules/account_invoice_stock/account.py index c7cc7b679d..f63bcaa7cb 100644 --- a/modules/account_invoice_stock/account.py +++ b/modules/account_invoice_stock/account.py @@ -107,7 +107,7 @@ class InvoiceLine(metaclass=PoolMeta): for stock_move in self.stock_moves: if stock_move.state != 'cancelled': quantity += Uom.compute_qty( - stock_move.uom, stock_move.quantity, self.unit) + stock_move.unit, stock_move.quantity, self.unit) return quantity def get_shipments(self, name): diff --git a/modules/account_invoice_stock/stock.py b/modules/account_invoice_stock/stock.py index 63bde5c613..fd88c8a5ca 100644 --- a/modules/account_invoice_stock/stock.py +++ b/modules/account_invoice_stock/stock.py @@ -61,7 +61,7 @@ class Move(metaclass=PoolMeta): for invoice_line in self.invoice_lines: if invoice_line.invoice_state != 'cancelled': quantity += Uom.compute_qty( - invoice_line.unit, invoice_line.quantity, self.uom) + invoice_line.unit, invoice_line.quantity, self.unit) return quantity @classmethod @@ -109,7 +109,7 @@ class Move(metaclass=PoolMeta): line.invoice.currency, line.amount, self.currency) if line.invoice.type == 'out' or not line.correction: quantity += UoM.compute_qty( - line.unit, line.quantity, self.uom) + line.unit, line.quantity, self.unit) if quantity: unit_price = round_price(amount / Decimal(str(quantity))) return unit_price diff --git a/modules/account_stock_anglo_saxon/stock.py b/modules/account_stock_anglo_saxon/stock.py index f599ed8665..2dccd2087d 100644 --- a/modules/account_stock_anglo_saxon/stock.py +++ b/modules/account_stock_anglo_saxon/stock.py @@ -54,8 +54,8 @@ class Move(metaclass=PoolMeta): cost_price_method = self.product.get_multivalue( 'cost_price_method', **self._cost_price_pattern) if type_.endswith('supplier') and cost_price_method == 'fixed': - cost_price = Uom.compute_price(self.product.default_uom, - self.cost_price, self.uom) + cost_price = Uom.compute_price( + self.product.default_uom, self.cost_price, self.unit) with Transaction().set_context(date=self.effective_date): unit_price = Currency.compute(self.currency, self.unit_price, self.company.currency, round=False) @@ -102,9 +102,10 @@ class Move(metaclass=PoolMeta): consumed_qty = 0.0 for move in moves: - qty = Uom.compute_qty(move.uom, - move.quantity - getattr(move, as_qty_field), - move.product.default_uom, round=False) + qty = Uom.compute_qty( + move.unit, + move.quantity - getattr(move, as_qty_field), + move.product.default_uom, round=False) if qty <= 0.0: continue if qty > quantity - consumed_qty: @@ -116,8 +117,8 @@ class Move(metaclass=PoolMeta): with Transaction().set_context(date=move.effective_date): unit_price = Currency.compute(move.currency, move.unit_price, move.company.currency, round=False) - cost_price = Uom.compute_price(move.uom, - unit_price, move.product.default_uom) + cost_price = Uom.compute_price( + move.unit, unit_price, move.product.default_uom) else: cost_price = move.cost_price @@ -126,7 +127,7 @@ class Move(metaclass=PoolMeta): @classmethod def update_anglo_saxon_quantity_product_cost(cls, product, moves, - quantity, uom, type_): + quantity, unit, type_): ''' Return the cost for quantity based on lines. Update anglo_saxon_quantity on the concerned moves. @@ -138,8 +139,8 @@ class Move(metaclass=PoolMeta): assert type_.startswith('in_') or type_.startswith('out_'), \ 'wrong type' - total_qty = Uom.compute_qty(uom, quantity, product.default_uom, - round=False) + total_qty = Uom.compute_qty( + unit, quantity, product.default_uom, round=False) as_qty_field = _get_field(type_) cost = Decimal('0.0') @@ -151,11 +152,11 @@ class Move(metaclass=PoolMeta): cost += move_cost_price * Decimal(str(move_qty)) move_qty = Uom.compute_qty( - product.default_uom, move_qty, move.uom, round=False) + product.default_uom, move_qty, move.unit, round=False) # Avoid float rounding issue but allow only rounding precision lost new_qty = (getattr(move, as_qty_field) or 0.0) + move_qty - assert move.uom.round(new_qty) <= move.quantity + assert move.unit.round(new_qty) <= move.quantity new_qty = min(new_qty, move.quantity) cls.write([move], { as_qty_field: new_qty, diff --git a/modules/account_stock_continental/stock.py b/modules/account_stock_continental/stock.py index f8ddeb66b1..45af021712 100644 --- a/modules/account_stock_continental/stock.py +++ b/modules/account_stock_continental/stock.py @@ -31,8 +31,8 @@ class Move(metaclass=PoolMeta): unit_price = self.unit_price_company else: unit_price = self.cost_price - unit_price = Uom.compute_price(self.product.default_uom, - unit_price, self.uom) + unit_price = Uom.compute_price( + self.product.default_uom, unit_price, self.unit) amount = self.company.currency.round( Decimal(str(self.quantity)) * unit_price) diff --git a/modules/account_stock_eu/stock.py b/modules/account_stock_eu/stock.py index 2cccc9a179..b19d9eed74 100644 --- a/modules/account_stock_eu/stock.py +++ b/modules/account_stock_eu/stock.py @@ -421,21 +421,22 @@ class Move(metaclass=PoolMeta): self.company.intrastat_currency, round=False), ndigits) - def _intrastat_quantity(self, uom): + def _intrastat_quantity(self, unit): pool = Pool() UoM = pool.get('product.uom') - if self.uom.category == uom.category: - return UoM.compute_qty(self.uom, self.quantity, uom, round=False) + if self.unit.category == unit.category: + return UoM.compute_qty(self.unit, self.quantity, unit, round=False) elif (getattr(self, 'secondary_unit', None) - and self.secondary_unit.category == uom.category): + and self.secondary_unit.category == unit.category): return UoM.compute_qty( - self.secondary_unit, self.secondary_quantity, uom, round=False) + self.secondary_unit, self.secondary_quantity, unit, + round=False) if (self.product.volume - and self.product.volume_uom.category == uom.category): + and self.product.volume_uom.category == unit.category): return UoM.compute_qty( self.product.volume_uom, self.internal_quantity * self.product.volume, - uom, round=False) + unit, round=False) def _intrastat_counterparty(self): pool = Pool() diff --git a/modules/carrier_weight/common.py b/modules/carrier_weight/common.py index c22a0f1408..07a8ffe91d 100644 --- a/modules/carrier_weight/common.py +++ b/modules/carrier_weight/common.py @@ -3,7 +3,7 @@ from trytond.pool import Pool -def parcel_weight(parcel, carrier_uom, uom_field='uom'): +def parcel_weight(parcel, carrier_uom, uom_field='unit'): pool = Pool() Uom = pool.get('product.uom') diff --git a/modules/commission/stock.py b/modules/commission/stock.py index 5a715c0be7..8f0276effd 100644 --- a/modules/commission/stock.py +++ b/modules/commission/stock.py @@ -47,7 +47,7 @@ class Move(metaclass=PoolMeta): total += amount if line.invoice.type == 'out' or not line.correction: quantity += UoM.compute_qty( - line.unit, line.quantity, self.uom) + line.unit, line.quantity, self.unit) if quantity: unit_price = round_price(total / Decimal(str(quantity))) else: diff --git a/modules/product_cost_fifo/move.py b/modules/product_cost_fifo/move.py index d122ad0a3a..77c8295b29 100644 --- a/modules/product_cost_fifo/move.py +++ b/modules/product_cost_fifo/move.py @@ -77,8 +77,8 @@ class Move(metaclass=PoolMeta): pool = Pool() Uom = pool.get('product.uom') - total_qty = Uom.compute_qty(self.uom, self.quantity, - self.product.default_uom, round=False) + total_qty = Uom.compute_qty( + self.unit, self.quantity, self.product.default_uom, round=False) with Transaction().set_context(company=self.company.id): fifo_moves = self.product.get_fifo_move(total_qty) @@ -90,11 +90,11 @@ class Move(metaclass=PoolMeta): consumed_qty += move_qty cost_price += move.get_cost_price() * Decimal(str(move_qty)) - move_qty = Uom.compute_qty(self.product.default_uom, move_qty, - move.uom, round=False) + move_qty = Uom.compute_qty( + self.product.default_uom, move_qty, move.unit, round=False) move.fifo_quantity = (move.fifo_quantity or 0.0) + move_qty # Due to float, the fifo quantity result can exceed the quantity. - assert move.quantity >= move.fifo_quantity - move.uom.rounding + assert move.quantity >= move.fifo_quantity - move.unit.rounding move.fifo_quantity = min(move.fifo_quantity, move.quantity) to_save.append(move) diff --git a/modules/product_cost_fifo/product.py b/modules/product_cost_fifo/product.py index 490cba0cca..2f0ea5fef3 100644 --- a/modules/product_cost_fifo/product.py +++ b/modules/product_cost_fifo/product.py @@ -74,7 +74,7 @@ class Product(metaclass=PoolMeta): for move in moves(): qty = move.fifo_quantity_available if not date else move.quantity qty = Uom.compute_qty( - move.uom, qty, self.default_uom, round=False) + move.unit, qty, self.default_uom, round=False) avail_qty -= qty if avail_qty <= quantity: @@ -204,7 +204,7 @@ class Product(metaclass=PoolMeta): cost_price = Revision.apply_up_to( revisions, cost_price, move.effective_date) - qty = Uom.compute_qty(move.uom, move.quantity, self.default_uom) + qty = Uom.compute_qty(move.unit, move.quantity, self.default_uom) qty = Decimal(str(qty)) if out_move(move): qty *= -1 diff --git a/modules/product_cost_fifo/tests/scenario_product_cost_fifo.rst b/modules/product_cost_fifo/tests/scenario_product_cost_fifo.rst index bf48f4527a..da742a46c3 100644 --- a/modules/product_cost_fifo/tests/scenario_product_cost_fifo.rst +++ b/modules/product_cost_fifo/tests/scenario_product_cost_fifo.rst @@ -52,7 +52,7 @@ Make 4 units of the product available @ 10 :: >>> StockMove = Model.get('stock.move') >>> incoming_move = StockMove() >>> incoming_move.product = product - >>> incoming_move.uom = unit + >>> incoming_move.unit = unit >>> incoming_move.quantity = 4 >>> incoming_move.from_location = supplier_loc >>> incoming_move.to_location = storage_loc @@ -72,7 +72,7 @@ Add 2 more units @ 25 from production:: >>> incoming_move = StockMove() >>> incoming_move.product = product - >>> incoming_move.uom = unit + >>> incoming_move.unit = unit >>> incoming_move.quantity = 2 >>> incoming_move.from_location = production_loc >>> incoming_move.to_location = storage_loc @@ -92,7 +92,7 @@ Sell 3 units @ 50:: >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = unit + >>> outgoing_move.unit = unit >>> outgoing_move.quantity = 3 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc @@ -117,7 +117,7 @@ Sell twice 1 more units @ 50:: >>> outgoing_moves = [] >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = unit + >>> outgoing_move.unit = unit >>> outgoing_move.quantity = 1 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc @@ -130,7 +130,7 @@ Sell twice 1 more units @ 50:: >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = unit + >>> outgoing_move.unit = unit >>> outgoing_move.quantity = 1 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc diff --git a/modules/product_cost_fifo/tests/scenario_product_cost_fifo_no_in.rst b/modules/product_cost_fifo/tests/scenario_product_cost_fifo_no_in.rst index 711095c338..df7d0d18f8 100644 --- a/modules/product_cost_fifo/tests/scenario_product_cost_fifo_no_in.rst +++ b/modules/product_cost_fifo/tests/scenario_product_cost_fifo_no_in.rst @@ -50,7 +50,7 @@ Make 2 units of the product not available @ 60 and 80 :: >>> StockMove = Model.get('stock.move') >>> incoming_move = StockMove() >>> incoming_move.product = product - >>> incoming_move.uom = unit + >>> incoming_move.unit = unit >>> incoming_move.quantity = 1 >>> incoming_move.from_location = supplier_loc >>> incoming_move.to_location = storage_loc @@ -63,7 +63,7 @@ Make 2 units of the product not available @ 60 and 80 :: >>> incoming_move = StockMove() >>> incoming_move.product = product - >>> incoming_move.uom = unit + >>> incoming_move.unit = unit >>> incoming_move.quantity = 1 >>> incoming_move.from_location = supplier_loc >>> incoming_move.to_location = storage_loc @@ -79,7 +79,7 @@ Sell 1 unit @ 200:: >>> StockMove = Model.get('stock.move') >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = unit + >>> outgoing_move.unit = unit >>> outgoing_move.quantity = 1 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc diff --git a/modules/product_cost_fifo/tests/scenario_product_cost_fifo_uom.rst b/modules/product_cost_fifo/tests/scenario_product_cost_fifo_uom.rst index 78a6de7006..7e9dfcc294 100644 --- a/modules/product_cost_fifo/tests/scenario_product_cost_fifo_uom.rst +++ b/modules/product_cost_fifo/tests/scenario_product_cost_fifo_uom.rst @@ -52,7 +52,7 @@ Make 4 kg of the product available @ 10 :: >>> StockMove = Model.get('stock.move') >>> incoming_move = StockMove() >>> incoming_move.product = product - >>> incoming_move.uom = kg + >>> incoming_move.unit = kg >>> incoming_move.quantity = 4 >>> incoming_move.from_location = supplier_loc >>> incoming_move.to_location = storage_loc @@ -72,7 +72,7 @@ Add 2000 more g @ 0.025:: >>> incoming_move = StockMove() >>> incoming_move.product = product - >>> incoming_move.uom = g + >>> incoming_move.unit = g >>> incoming_move.quantity = 2000 >>> incoming_move.from_location = supplier_loc >>> incoming_move.to_location = storage_loc @@ -92,7 +92,7 @@ Sell 3 kg @ 50:: >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = kg + >>> outgoing_move.unit = kg >>> outgoing_move.quantity = 3 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc @@ -115,7 +115,7 @@ Sell twice 1 more kg @ 50:: >>> outgoing_moves = [] >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = kg + >>> outgoing_move.unit = kg >>> outgoing_move.quantity = 1 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc @@ -128,7 +128,7 @@ Sell twice 1 more kg @ 50:: >>> outgoing_move = StockMove() >>> outgoing_move.product = product - >>> outgoing_move.uom = g + >>> outgoing_move.unit = g >>> outgoing_move.quantity = 1000 >>> outgoing_move.from_location = storage_loc >>> outgoing_move.to_location = customer_loc diff --git a/modules/product_cost_warehouse/stock.py b/modules/product_cost_warehouse/stock.py index ec62bac4b5..0bb24b1b07 100644 --- a/modules/product_cost_warehouse/stock.py +++ b/modules/product_cost_warehouse/stock.py @@ -95,7 +95,7 @@ class Move(metaclass=PoolMeta): for outgoing_move in move.shipment.outgoing_moves: if outgoing_move.product == move.product: qty = Uom.compute_qty( - outgoing_move.uom, outgoing_move.quantity, + outgoing_move.unit, outgoing_move.quantity, move.product.default_uom) qty = Decimal(str(qty)) cost += qty * outgoing_move.cost_price diff --git a/modules/product_kit/common.py b/modules/product_kit/common.py index 5b13bb92bb..cfacc23298 100644 --- a/modules/product_kit/common.py +++ b/modules/product_kit/common.py @@ -326,7 +326,7 @@ def order_line_component_mixin(prefix): for move in self.moves: if move not in skips: quantity += Uom.compute_qty( - move.uom, move.quantity, self.unit) + move.unit, move.quantity, self.unit) return quantity @property @@ -339,7 +339,7 @@ def order_line_component_mixin(prefix): for move in self.moves: if move.state == 'done' or move in ignored: quantity -= Uom.compute_qty( - move.uom, move.quantity, self.unit) + move.unit, move.quantity, self.unit) return quantity def get_moves_exception(self, name): @@ -365,7 +365,7 @@ def order_line_component_mixin(prefix): for move in self.moves: if move.state != 'done': continue - qty = Uom.compute_qty(move.uom, move.quantity, self.unit) + qty = Uom.compute_qty(move.unit, move.quantity, self.unit) dest_type = self.line.to_location.type if (move.to_location.type == dest_type and move.from_location.type != dest_type): diff --git a/modules/product_kit/purchase.py b/modules/product_kit/purchase.py index 295f4bebf5..ce6ac0f29d 100644 --- a/modules/product_kit/purchase.py +++ b/modules/product_kit/purchase.py @@ -104,7 +104,7 @@ class LineComponent( move = Move() move.quantity = quantity - move.uom = self.unit + move.unit = self.unit move.product = self.product move.from_location = self.line.from_location move.to_location = self.line.to_location diff --git a/modules/product_kit/sale.py b/modules/product_kit/sale.py index 7b5598cb47..41452509ad 100644 --- a/modules/product_kit/sale.py +++ b/modules/product_kit/sale.py @@ -101,7 +101,7 @@ class LineComponent( move = Move() move.quantity = quantity - move.uom = self.unit + move.unit = self.unit move.product = self.product move.from_location = self.line.from_location move.to_location = self.line.to_location diff --git a/modules/product_kit/stock.py b/modules/product_kit/stock.py index 5b135e15f2..e7836e1bb9 100644 --- a/modules/product_kit/stock.py +++ b/modules/product_kit/stock.py @@ -26,7 +26,7 @@ class Move(metaclass=PoolMeta): amount *= self.origin.price_ratio if quantity: unit_price = round_price(amount / Decimal(str(quantity))) - unit_price = UoM.compute_price(self.origin.unit, unit_price, self.uom) + unit_price = UoM.compute_price(self.origin.unit, unit_price, self.unit) return unit_price diff --git a/modules/production/production.py b/modules/production/production.py index 7823628511..f1c86f6238 100644 --- a/modules/production/production.py +++ b/modules/production/production.py @@ -364,7 +364,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): assert type in {'input', 'output'} move = Move( product=product, - uom=unit, + unit=unit, quantity=quantity, company=self.company, currency=self.company.currency if self.company else None) @@ -401,8 +401,9 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): move = self._explode_move_values('input', input_, quantity) if move: inputs.append(move) - quantity = Uom.compute_qty(input_.uom, quantity, - input_.product.default_uom, round=False) + quantity = Uom.compute_qty( + input_.uom, quantity, input_.product.default_uom, + round=False) self.inputs = inputs outputs = [] @@ -475,13 +476,13 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): for input_ in self.inputs: if (input_.product is None - or input_.uom is None + or input_.unit is None or input_.quantity is None or input_.state == 'cancelled'): continue product = input_.product - quantity = Uom.compute_qty(input_.uom, input_.quantity, - product.default_uom) + quantity = Uom.compute_qty( + input_.unit, input_.quantity, product.default_uom) cost += Decimal(str(quantity)) * product.cost_price return cost @@ -573,7 +574,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): cost_price = ( input_costs[product] / input_quantities[product]) unit_price = round_price(Uom.compute_price( - product.default_uom, cost_price, output.uom)) + product.default_uom, cost_price, output.unit)) if (output.unit_price != unit_price or output.currency != production.company.currency): output.unit_price = unit_price @@ -599,7 +600,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): continue product_price = (Decimal(str(output.quantity)) * Uom.compute_price( - product.default_uom, list_price, output.uom)) + product.default_uom, list_price, output.unit)) prices[output] = product_price sum_ += product_price @@ -608,7 +609,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView): for output in outputs: if output.product == production.product: quantity = Uom.compute_qty( - output.uom, output.quantity, + output.unit, output.quantity, output.product.default_uom, round=False) quantity = Decimal(str(quantity)) prices[output] = quantity diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index 9769c22d5e..d303197387 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -1312,7 +1312,8 @@ class Line(sequence_ordered(), ModelSQL, ModelView): quantity = abs(self.quantity) for move in self.moves: if move.state == 'done' or move in skips: - quantity -= Uom.compute_qty(move.uom, move.quantity, self.unit) + quantity -= Uom.compute_qty( + move.unit, move.quantity, self.unit) return quantity def get_moves_exception(self, name): @@ -1699,7 +1700,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView): for move in self.moves: if move.state != 'done': continue - qty = Uom.compute_qty(move.uom, move.quantity, self.unit) + qty = Uom.compute_qty(move.unit, move.quantity, self.unit) # Test only against from_location # as it is what matters for purchase src_type = 'supplier' @@ -1769,7 +1770,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView): party=self.purchase.party.rec_name)) move = Move() move.quantity = quantity - move.uom = self.unit + move.unit = self.unit move.product = self.product move.from_location = self.from_location move.to_location = self.to_location @@ -1796,8 +1797,8 @@ class Line(sequence_ordered(), ModelSQL, ModelView): skip = set(self.moves_recreated) for move in self.moves: if move not in skip: - quantity += Uom.compute_qty(move.uom, move.quantity, - self.unit) + quantity += Uom.compute_qty( + move.unit, move.quantity, self.unit) return quantity def _get_move_invoice_lines(self, move_type): @@ -1816,7 +1817,7 @@ class Line(sequence_ordered(), ModelSQL, ModelView): for move in self.moves: if move.state != 'cancelled' and self.unit: moved_quantity += Uom.compute_qty( - move.uom, move.quantity, self.unit, round=False) + move.unit, move.quantity, self.unit, round=False) if self.quantity < 0: moved_quantity *= -1 invoiced_quantity = 0 diff --git a/modules/purchase/view/move_list_shipment.xml b/modules/purchase/view/move_list_shipment.xml index a34ffb6727..b407e6163a 100644 --- a/modules/purchase/view/move_list_shipment.xml +++ b/modules/purchase/view/move_list_shipment.xml @@ -5,7 +5,7 @@ this repository contains the full copyright notices and license terms. --> - +