diff --git a/modules/production/CHANGELOG b/modules/production/CHANGELOG
index 45bbfde062..9f10156183 100644
--- a/modules/production/CHANGELOG
+++ b/modules/production/CHANGELOG
@@ -1,3 +1,4 @@
+* Rename Uom to Unit for bill of material
* Rename Uom to Unit for production
* Reschedule planned date for late productions
diff --git a/modules/production/bom.py b/modules/production/bom.py
index 1ec6816839..a62b4b4e12 100644
--- a/modules/production/bom.py
+++ b/modules/production/bom.py
@@ -16,7 +16,7 @@ class BOM(DeactivableMixin, ModelSQL, ModelView):
output_products = fields.Many2Many('production.bom.output',
'bom', 'product', 'Output Products')
- def compute_factor(self, product, quantity, uom):
+ def compute_factor(self, product, quantity, unit):
'''
Compute factor for an output product
'''
@@ -25,7 +25,7 @@ class BOM(DeactivableMixin, ModelSQL, ModelView):
for output in self.outputs:
if output.product == product:
output_quantity += Uom.compute_qty(
- output.uom, output.quantity, uom, round=False)
+ output.unit, output.quantity, unit, round=False)
if output_quantity:
return quantity / output_quantity
else:
@@ -50,11 +50,13 @@ class BOMInput(ModelSQL, ModelView):
product = fields.Many2One('product.product', 'Product', required=True)
uom_category = fields.Function(fields.Many2One(
'product.uom.category', 'Uom Category'), 'on_change_with_uom_category')
- uom = fields.Many2One('product.uom', 'Uom', required=True,
+ unit = fields.Many2One(
+ 'product.uom', "Unit", required=True,
domain=[
('category', '=', Eval('uom_category')),
])
- quantity = fields.Float('Quantity', digits='uom', required=True,
+ quantity = fields.Float(
+ "Quantity", digits='unit', required=True,
domain=['OR',
('quantity', '>=', 0),
('quantity', '=', None),
@@ -68,6 +70,13 @@ class BOMInput(ModelSQL, ModelView):
@classmethod
def __register__(cls, module):
+ table_h = cls.__table_handler__(module)
+
+ # Migration from 6.8: rename uom to unit
+ if (table_h.column_exist('uom')
+ and not table_h.column_exist('unit')):
+ table_h.column_rename('uom', 'unit')
+
super().__register__(module)
table_h = cls.__table_handler__(module)
@@ -78,14 +87,14 @@ class BOMInput(ModelSQL, ModelView):
def get_product_types(cls):
return ['goods', 'assets']
- @fields.depends('product', 'uom')
+ @fields.depends('product', 'unit')
def on_change_product(self):
if self.product:
category = self.product.default_uom.category
- if not self.uom or self.uom.category != category:
- self.uom = self.product.default_uom
+ if not self.unit or self.unit.category != category:
+ self.unit = self.product.default_uom
else:
- self.uom = None
+ self.unit = None
@fields.depends('product')
def on_change_with_uom_category(self, name=None):
@@ -111,7 +120,7 @@ class BOMInput(ModelSQL, ModelView):
self.product.check_bom_recursion()
def compute_quantity(self, factor):
- return self.uom.ceil(self.quantity * factor)
+ return self.unit.ceil(self.quantity * factor)
class BOMOutput(BOMInput):
@@ -120,7 +129,7 @@ class BOMOutput(BOMInput):
_table = 'production_bom_output' # Needed to override BOMInput._table
def compute_quantity(self, factor):
- return self.uom.floor(self.quantity * factor)
+ return self.unit.floor(self.quantity * factor)
@classmethod
def delete(cls, outputs):
@@ -151,12 +160,12 @@ class BOMTree(ModelView):
__name__ = 'production.bom.tree'
product = fields.Many2One('product.product', 'Product')
- quantity = fields.Float('Quantity', digits='uom')
- uom = fields.Many2One('product.uom', 'Uom')
+ quantity = fields.Float('Quantity', digits='unit')
+ unit = fields.Many2One('product.uom', "Unit")
childs = fields.One2Many('production.bom.tree', None, 'Childs')
@classmethod
- def tree(cls, product, quantity, uom, bom=None):
+ def tree(cls, product, quantity, unit, bom=None):
Input = Pool().get('production.bom.input')
result = []
@@ -165,19 +174,19 @@ class BOMTree(ModelView):
return result
bom = product.boms[0].bom
- factor = bom.compute_factor(product, quantity, uom)
+ factor = bom.compute_factor(product, quantity, unit)
for input_ in bom.inputs:
quantity = Input.compute_quantity(input_, factor)
- childs = cls.tree(input_.product, quantity, input_.uom)
+ childs = cls.tree(input_.product, quantity, input_.unit)
values = {
'product': input_.product.id,
'product.': {
'rec_name': input_.product.rec_name,
},
'quantity': quantity,
- 'uom': input_.uom.id,
- 'uom.': {
- 'rec_name': input_.uom.rec_name,
+ 'unit': input_.unit.id,
+ 'unit.': {
+ 'rec_name': input_.unit.rec_name,
},
'childs': childs,
}
@@ -189,8 +198,9 @@ class OpenBOMTreeStart(ModelView):
'Open BOM Tree'
__name__ = 'production.bom.tree.open.start'
- quantity = fields.Float('Quantity', digits='uom', required=True)
- uom = fields.Many2One('product.uom', 'Unit', required=True,
+ quantity = fields.Float('Quantity', digits='unit', required=True)
+ unit = fields.Many2One(
+ 'product.uom', "Unit", required=True,
domain=[
('category', '=', Eval('category')),
])
@@ -211,20 +221,20 @@ class OpenBOMTreeTree(ModelView):
readonly=True)
@classmethod
- def tree(cls, bom, product, quantity, uom):
+ def tree(cls, bom, product, quantity, unit):
pool = Pool()
Tree = pool.get('production.bom.tree')
- childs = Tree.tree(product, quantity, uom, bom=bom)
+ childs = Tree.tree(product, quantity, unit, bom=bom)
bom_tree = [{
'product': product.id,
'product.': {
'rec_name': product.rec_name,
},
'quantity': quantity,
- 'uom': uom.id,
- 'uom.': {
- 'rec_name': uom.rec_name,
+ 'unit': unit.id,
+ 'unit.': {
+ 'rec_name': unit.rec_name,
},
'childs': childs,
}]
@@ -252,10 +262,10 @@ class OpenBOMTree(Wizard):
defaults = {}
product = self.record
defaults['category'] = product.default_uom.category.id
- if getattr(self.start, 'uom', None):
- defaults['uom'] = self.start.uom.id
+ if getattr(self.start, 'unit', None):
+ defaults['unit'] = self.start.unit.id
else:
- defaults['uom'] = product.default_uom.id
+ defaults['unit'] = product.default_uom.id
defaults['product'] = product.id
if getattr(self.start, 'bom', None):
defaults['bom'] = self.start.bom.id
@@ -268,4 +278,4 @@ class OpenBOMTree(Wizard):
pool = Pool()
BomTree = pool.get('production.bom.tree.open.tree')
return BomTree.tree(self.start.bom.bom, self.start.product,
- self.start.quantity, self.start.uom)
+ self.start.quantity, self.start.unit)
diff --git a/modules/production/production.py b/modules/production/production.py
index f1c86f6238..251ec2b5e5 100644
--- a/modules/production/production.py
+++ b/modules/production/production.py
@@ -380,7 +380,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
@fields.depends(methods=['_move'])
def _explode_move_values(self, type, bom_io, quantity):
- move = self._move(type, bom_io.product, bom_io.uom, quantity)
+ move = self._move(type, bom_io.product, bom_io.unit, quantity)
move.unit_price_required = move.on_change_with_unit_price_required()
return move
@@ -402,7 +402,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
if move:
inputs.append(move)
quantity = Uom.compute_qty(
- input_.uom, quantity, input_.product.default_uom,
+ input_.unit, quantity, input_.product.default_uom,
round=False)
self.inputs = inputs
@@ -509,7 +509,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
quantity = input_.compute_quantity(factor)
product = input_.product
move = production._move(
- 'input', product, input_.uom, quantity)
+ 'input', product, input_.unit, quantity)
if move:
to_save.append(move)
@@ -517,7 +517,7 @@ class Production(ShipmentAssignMixin, Workflow, ModelSQL, ModelView):
quantity = output.compute_quantity(factor)
product = output.product
move = production._move(
- 'output', product, output.uom, quantity)
+ 'output', product, output.unit, quantity)
if move:
move.unit_price = Decimal(0)
move.currency = production.company.currency
diff --git a/modules/production/tests/scenario_production.rst b/modules/production/tests/scenario_production.rst
index 1bdce9ff11..40396a6106 100644
--- a/modules/production/tests/scenario_production.rst
+++ b/modules/production/tests/scenario_production.rst
@@ -81,7 +81,7 @@ Create Bill of Material::
>>> bom.inputs.append(input2)
>>> input2.product = component2
>>> input2.quantity = 150
- >>> input2.uom = centimeter
+ >>> input2.unit = centimeter
>>> output = BOMOutput()
>>> bom.outputs.append(output)
>>> output.product = product
diff --git a/modules/production/view/bom_input_form.xml b/modules/production/view/bom_input_form.xml
index a68bc129fe..b765e01d0b 100644
--- a/modules/production/view/bom_input_form.xml
+++ b/modules/production/view/bom_input_form.xml
@@ -10,6 +10,6 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
diff --git a/modules/production/view/bom_input_list.xml b/modules/production/view/bom_input_list.xml
index 6531df465d..548176ee73 100644
--- a/modules/production/view/bom_input_list.xml
+++ b/modules/production/view/bom_input_list.xml
@@ -4,5 +4,5 @@ this repository contains the full copyright notices and license terms. -->
-
+
diff --git a/modules/production/view/bom_output_form.xml b/modules/production/view/bom_output_form.xml
index a68bc129fe..b765e01d0b 100644
--- a/modules/production/view/bom_output_form.xml
+++ b/modules/production/view/bom_output_form.xml
@@ -10,6 +10,6 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
diff --git a/modules/production/view/bom_output_list.xml b/modules/production/view/bom_output_list.xml
index 6531df465d..548176ee73 100644
--- a/modules/production/view/bom_output_list.xml
+++ b/modules/production/view/bom_output_list.xml
@@ -4,5 +4,5 @@ this repository contains the full copyright notices and license terms. -->
-
+
diff --git a/modules/production/view/bom_tree_open_start_form.xml b/modules/production/view/bom_tree_open_start_form.xml
index 82b2088976..2d0858bd5d 100644
--- a/modules/production/view/bom_tree_open_start_form.xml
+++ b/modules/production/view/bom_tree_open_start_form.xml
@@ -7,6 +7,6 @@ this repository contains the full copyright notices and license terms. -->
-
-
+
+
diff --git a/modules/production/view/bom_tree_tree.xml b/modules/production/view/bom_tree_tree.xml
index fee67116e3..d63423d565 100644
--- a/modules/production/view/bom_tree_tree.xml
+++ b/modules/production/view/bom_tree_tree.xml
@@ -3,6 +3,6 @@
this repository contains the full copyright notices and license terms. -->
-
+
diff --git a/modules/stock_product_location/tests/scenario_stock_product_location.rst b/modules/stock_product_location/tests/scenario_stock_product_location.rst
index 78355ef5e5..fb27b404a2 100644
--- a/modules/stock_product_location/tests/scenario_stock_product_location.rst
+++ b/modules/stock_product_location/tests/scenario_stock_product_location.rst
@@ -83,7 +83,7 @@ Add one shipment line of product::
>>> move = shipment_in.incoming_moves.new()
>>> move.product = product
- >>> move.uom = unit
+ >>> move.unit = unit
>>> move.quantity = 1
>>> move.from_location = supplier_loc
>>> move.to_location = input_loc
@@ -110,7 +110,7 @@ Add one shipment return line::
>>> move = shipment_out_return.incoming_moves.new()
>>> move.product = product
- >>> move.uom =unit
+ >>> move.unit =unit
>>> move.quantity = 1
>>> move.from_location = customer_loc
>>> move.to_location = input_loc
diff --git a/modules/stock_product_location/tests/scenario_stock_product_location_production.rst b/modules/stock_product_location/tests/scenario_stock_product_location_production.rst
index f4761cac55..6159e27961 100644
--- a/modules/stock_product_location/tests/scenario_stock_product_location_production.rst
+++ b/modules/stock_product_location/tests/scenario_stock_product_location_production.rst
@@ -89,7 +89,7 @@ Create Bill of Material::
>>> bom.inputs.append(input2)
>>> input2.product = component2
>>> input2.quantity = 150
- >>> input2.uom = centimeter
+ >>> input2.unit = centimeter
>>> output = BOMOutput()
>>> bom.outputs.append(output)
>>> output.product = product
diff --git a/modules/stock_product_location/tests/scenario_stock_product_location_template.rst b/modules/stock_product_location/tests/scenario_stock_product_location_template.rst
index d8dd4a5ea5..7c88fde330 100644
--- a/modules/stock_product_location/tests/scenario_stock_product_location_template.rst
+++ b/modules/stock_product_location/tests/scenario_stock_product_location_template.rst
@@ -82,7 +82,7 @@ Add one shipment line of product::
>>> move = shipment_in.incoming_moves.new()
>>> move.product = product
- >>> move.uom = unit
+ >>> move.unit = unit
>>> move.quantity = 1
>>> move.from_location = supplier_loc
>>> move.to_location = input_loc
@@ -109,7 +109,7 @@ Add one shipment return line::
>>> move = shipment_out_return.incoming_moves.new()
>>> move.product = product
- >>> move.uom =unit
+ >>> move.unit =unit
>>> move.quantity = 1
>>> move.from_location = customer_loc
>>> move.to_location = input_loc