Rename Uom to Unit.

This commit is contained in:
Albert Cervera i Areny 2023-09-13 21:12:36 +02:00
parent ee237a38b0
commit 9a408a232f
17 changed files with 38 additions and 39 deletions

View File

@ -114,7 +114,7 @@ class AnimalMixin:
move_date = self.arrival_date or date.today()
return Move(
product=self.lot.product,
uom=self.lot.product.default_uom,
unit=self.lot.product.default_uom,
quantity=getattr(self, 'initial_quantity', 1),
from_location=from_location,
to_location=self.initial_location,

View File

@ -249,7 +249,7 @@ class FarrowingEvent(AbstractEvent, ImportedEventMixin, ModelSQL, ModelView, Wor
return Move(
product=product,
uom=uom,
unit=uom,
quantity=live,
from_location=self.farm.production_location.id,
to_location=self.animal.location.id,

View File

@ -273,7 +273,7 @@ class FeedEventMixin(AbstractEvent):
move = Move(
product=self.feed_product.id,
uom=self.uom.id,
unit=self.uom.id,
quantity=float(self.feed_quantity),
from_location=self.feed_location,
to_location=self.farm.production_location,

View File

@ -198,7 +198,7 @@ class FosterEvent(AbstractEvent, ImportedEventMixin):
to_location = self.specie.foster_location
return Move(
product=self.farrowing_group.lot.product,
uom=self.farrowing_group.lot.product.default_uom,
unit=self.farrowing_group.lot.product.default_uom,
quantity=abs(self.quantity),
from_location=from_location,
to_location=to_location,

View File

@ -204,7 +204,7 @@ class InseminationEvent(AbstractEvent, ImportedEventMixin):
if self.dose_bom:
return Move(
product=self.dose_product.id,
uom=self.dose_product.default_uom.id,
unit=self.dose_product.default_uom.id,
quantity=1,
from_location=self.farm.storage_location.id,
to_location=self.farm.production_location.id,
@ -217,7 +217,7 @@ class InseminationEvent(AbstractEvent, ImportedEventMixin):
else:
return Move(
product=self.specie.semen_product.id,
uom=self.specie.semen_product.default_uom.id,
unit=self.specie.semen_product.default_uom.id,
quantity=1,
from_location=self.farm.storage_location.id,
to_location=self.farm.production_location.id,

View File

@ -246,7 +246,7 @@ class MoveEvent(AbstractEvent):
return Move(
product=lot.product,
uom=lot.product.default_uom,
unit=lot.product.default_uom,
quantity=self.quantity,
from_location=self.from_location,
to_location=self.to_location,

View File

@ -165,7 +165,7 @@ class ReclassficationEvent(AbstractEvent):
production_location = self.farm.production_location
return Move(
product=lot.product,
uom=lot.product.default_uom,
unit=lot.product.default_uom,
quantity=1,
from_location=self.animal.location,
to_location=production_location,
@ -195,7 +195,7 @@ class ReclassficationEvent(AbstractEvent):
return Move(
product=lot.product,
uom=lot.product.default_uom,
unit=lot.product.default_uom,
quantity=1,
from_location=production_location,
to_location=self.to_location,

View File

@ -239,7 +239,7 @@ class RemovalEvent(AbstractEvent):
self.animal_group.lot)
return Move(
product=lot.product.id,
uom=lot.product.default_uom.id,
unit=lot.product.default_uom.id,
quantity=self.quantity,
from_location=self.from_location.id,
to_location=self.specie.removed_location.id,

View File

@ -50,8 +50,7 @@ class SemenExtractionEvent(AbstractEvent):
'invisible': ~Eval('test_required', True),
}, depends=['semen_product', 'id'])
formula_uom = fields.Function(fields.Many2One('product.uom',
'Formula UOM'),
'get_formula_uom')
'Formula UOM'), 'get_formula_uom')
formula_unit_digits = fields.Function(
fields.Integer('Formula Unit Digits'), 'get_formula_unit_digits')
formula_result = fields.Function(fields.Float('Formula Result',
@ -92,7 +91,7 @@ class SemenExtractionEvent(AbstractEvent):
semen_move = fields.Many2One('stock.move', 'Semen Move', readonly=True,
domain=[
('lot', '=', Eval('semen_lot')),
('uom', '=', Eval('formula_uom')),
('unit', '=', Eval('formula_uom')),
], states=_STATES_VALIDATED_ADMIN,
depends=_DEPENDS_VALIDATED_ADMIN + ['semen_lot', 'formula_uom'])
dose_location = fields.Many2One('stock.location', 'Doses Location',
@ -218,7 +217,7 @@ class SemenExtractionEvent(AbstractEvent):
semen_product = self.specie.semen_product
dose_product = self.dose_bom.output_products[0]
dose_uom = self.dose_bom.outputs[0].uom
dose_uom = self.dose_bom.outputs[0].unit
factor = self.dose_bom.compute_factor(dose_product, 1.0, dose_uom)
consumed_semen_qty = 0.0 # by 1 unit of dose
for input_ in self.dose_bom.inputs:
@ -227,7 +226,7 @@ class SemenExtractionEvent(AbstractEvent):
if not self.formula_uom:
continue
consumed_semen_qty = Uom.compute_qty(self.formula_uom,
consumed_semen_qty, input_.uom)
consumed_semen_qty, input_.unit)
break
assert consumed_semen_qty > 0.0, ('BOM of semen extraction event "%s" '
'generetes 0.0 consumed semen qty' % self.id)
@ -381,7 +380,7 @@ class SemenExtractionEvent(AbstractEvent):
return Move(
product=self.specie.semen_product,
uom=self.formula_uom,
unit=self.formula_uom,
quantity=self.semen_qty,
from_location=self.farm.production_location,
to_location=self.dose_location,
@ -591,7 +590,7 @@ class SemenExtractionDose(ModelSQL, ModelView):
return
semen_product = self.event.specie.semen_product
dose_product = self.bom.output_products[0]
dose_uom = self.bom.outputs[0].uom
dose_uom = self.bom.outputs[0].unit
factor = self.bom.compute_factor(dose_product, self.quantity, dose_uom)
semen_qty = 0.0 # by 1 unit of dose
for input_ in self.bom.inputs:
@ -600,7 +599,7 @@ class SemenExtractionDose(ModelSQL, ModelView):
if not self.event.formula_uom:
continue
semen_qty = Uom.compute_qty(self.event.formula_uom, semen_qty,
input_.uom)
input_.unit)
break
return semen_qty
@ -631,7 +630,7 @@ class SemenExtractionDose(ModelSQL, ModelView):
location=self.event.farm.production_location,
product=self.bom.output_products[0],
bom=self.bom,
uom=self.bom.outputs[0].uom,
unit=self.bom.outputs[0].unit,
quantity=self.quantity,
state='draft')

View File

@ -303,7 +303,7 @@ class TransformationEvent(AbstractEvent):
return Move(
product=lot.product.id,
uom=lot.product.default_uom.id,
unit=lot.product.default_uom.id,
quantity=self.quantity,
from_location=self.from_location.id,
to_location=production_location.id,
@ -331,7 +331,7 @@ class TransformationEvent(AbstractEvent):
return Move(
product=lot.product.id,
uom=lot.product.default_uom.id,
unit=lot.product.default_uom.id,
quantity=self.quantity,
from_location=production_location.id,
to_location=self.to_location.id,

View File

@ -379,7 +379,7 @@ class WeaningEvent(AbstractEvent, ImportedEventMixin):
return Move(
product=self.lot.product,
uom=self.lot.product.default_uom,
unit=self.lot.product.default_uom,
quantity=1.0,
from_location=self.animal.location,
to_location=self.female_to_location,
@ -410,7 +410,7 @@ class WeaningEvent(AbstractEvent, ImportedEventMixin):
return Move(
product=self.farrowing_group.lot.product,
uom=self.farrowing_group.lot.product.default_uom,
unit=self.farrowing_group.lot.product.default_uom,
quantity=abs(last_minute_fostered),
from_location=from_location,
to_location=to_location,
@ -440,7 +440,7 @@ class WeaningEvent(AbstractEvent, ImportedEventMixin):
return Move(
product=self.farrowing_group.lot.product,
uom=self.farrowing_group.lot.product.default_uom,
unit=self.farrowing_group.lot.product.default_uom,
quantity=abs(lost_qty),
from_location=from_location,
to_location=to_location,
@ -461,7 +461,7 @@ class WeaningEvent(AbstractEvent, ImportedEventMixin):
if animal:
return Move(
product=animal.lot.product,
uom=animal.lot.product.default_uom,
unit=animal.lot.product.default_uom,
quantity=1,
from_location=self.animal.location,
to_location=self.weaned_to_location,
@ -476,7 +476,7 @@ class WeaningEvent(AbstractEvent, ImportedEventMixin):
return Move(
product=self.farrowing_group.lot.product,
uom=self.farrowing_group.lot.product.default_uom,
unit=self.farrowing_group.lot.product.default_uom,
quantity=self.quantity,
from_location=self.animal.location,
to_location=self.weaned_to_location,

View File

@ -31,7 +31,7 @@ class BOM(metaclass=PoolMeta):
cls.outputs.size = If(Bool(Eval('semen_dose', 0)), 1,
cls.outputs.size or -1)
cls.outputs.domain.append(If(Bool(Eval('semen_dose', 0)),
('uom', '=', Id('product', 'uom_unit')), ()))
('unit', '=', Id('product', 'uom_unit')), ()))
@classmethod
def validate(cls, boms):

View File

@ -93,7 +93,7 @@ Put 5,1 Kg of feed into the silo location::
>>> now = datetime.datetime.now()
>>> provisioning_move = Move()
>>> provisioning_move.product = feed_product
>>> provisioning_move.uom = feed_product.default_uom
>>> provisioning_move.unit = feed_product.default_uom
>>> provisioning_move.quantity = 5.20
>>> provisioning_move.from_location = company.party.supplier_location
>>> provisioning_move.to_location = silo1

View File

@ -212,7 +212,7 @@ second Lot of Feed 3 days before::
>>> provisioning_move1 = Move()
>>> provisioning_move1.product = feed_product
>>> provisioning_move1.lot = feed_lot1
>>> provisioning_move1.uom = feed_product.default_uom
>>> provisioning_move1.unit = feed_product.default_uom
>>> provisioning_move1.quantity = 2000.00
>>> provisioning_move1.from_location = company.party.supplier_location
>>> provisioning_move1.to_location = silo1
@ -227,7 +227,7 @@ second Lot of Feed 3 days before::
>>> provisioning_move2 = Move()
>>> provisioning_move2.product = feed_product
>>> provisioning_move2.lot = feed_lot2
>>> provisioning_move2.uom = feed_product.default_uom
>>> provisioning_move2.unit = feed_product.default_uom
>>> provisioning_move2.quantity = 1500.00
>>> provisioning_move2.from_location = company.party.supplier_location
>>> provisioning_move2.to_location = silo1

View File

@ -86,17 +86,17 @@ Create dose Product, BoM and Lot::
... inputs=[
... BomInput(
... product=blister_product,
... uom=unit,
... unit=unit,
... quantity=1),
... BomInput(
... product=semen_product,
... uom=cm3,
... unit=cm3,
... quantity=100.00),
... ],
... outputs=[
... BomOutput(
... product=dose_product,
... uom=unit,
... unit=unit,
... quantity=1.00),
... ],
... )
@ -120,7 +120,7 @@ Put two units of dose and one of semen in farm storage location::
>>> now = datetime.datetime.now()
>>> provisioning_move1 = Move()
>>> provisioning_move1.product = dose_product
>>> provisioning_move1.uom = unit
>>> provisioning_move1.unit = unit
>>> provisioning_move1.quantity = 2.0
>>> provisioning_move1.from_location = production_location
>>> provisioning_move1.to_location = warehouse.storage_location
@ -135,7 +135,7 @@ Put two units of dose and one of semen in farm storage location::
>>> provisioning_move2 = Move()
>>> provisioning_move2.product = semen_product
>>> provisioning_move2.uom = cm3
>>> provisioning_move2.unit = cm3
>>> provisioning_move2.quantity = 1.0
>>> provisioning_move2.from_location = production_location
>>> provisioning_move2.to_location = warehouse.storage_location

View File

@ -100,7 +100,7 @@ Put 500 g of medication into the laboratory location::
>>> now = datetime.datetime.now()
>>> provisioning_move = Move()
>>> provisioning_move.product = medication_product
>>> provisioning_move.uom = g
>>> provisioning_move.unit = g
>>> provisioning_move.quantity = 500
>>> provisioning_move.from_location = company.party.supplier_location
>>> provisioning_move.to_location = lab1

View File

@ -131,17 +131,17 @@ Create dose Product and BoM::
... inputs=[
... BomInput(
... product=blister_product,
... uom=unit,
... unit=unit,
... quantity=1),
... BomInput(
... product=semen_product,
... uom=cm3,
... unit=cm3,
... quantity=100.00),
... ],
... outputs=[
... BomOutput(
... product=dose_product,
... uom=unit,
... unit=unit,
... quantity=1),
... ],
... )