formatting

This commit is contained in:
Frederik Jaeckel 2023-12-03 17:31:42 +01:00
parent 41e04482d4
commit 53f020b4d0
5 changed files with 150 additions and 224 deletions

View file

@ -28,12 +28,11 @@ class SecondUomMixin(object):
digits=(16, Eval('quantity2nd_digits', 4)),
states={
'readonly': Or(
STATESQ['readonly'],
~Bool(Eval('quantity2nd'))
),
STATESQ['readonly'],
~Bool(Eval('quantity2nd'))),
'required': Bool(Eval('quantity2nd')),
'invisible': ~Bool(Eval('quantity2nd')),
}, depends=DEPENDSQ+['quantity2nd_digits', 'quantity2nd'])
'invisible': ~Bool(Eval('quantity2nd'))},
depends=DEPENDSQ+['quantity2nd_digits', 'quantity2nd'])
factor_2nd_uom = fields.Function(fields.Numeric(
string='Conversion factor',
help='Conversion factor between the units of the ' +
@ -41,12 +40,11 @@ class SecondUomMixin(object):
digits=uom_conversion_digits,
states={
'readonly': Or(
STATESQ['readonly'],
~Bool(Eval('quantity2nd'))
),
STATESQ['readonly'],
~Bool(Eval('quantity2nd'))),
'required': Bool(Eval('quantity2nd')),
'invisible': ~Bool(Eval('quantity2nd')),
}, depends=DEPENDSQ+['quantity2nd_digits', 'quantity2nd']),
'invisible': ~Bool(Eval('quantity2nd'))},
depends=DEPENDSQ+['quantity2nd_digits', 'quantity2nd']),
'on_change_with_factor_2nd_uom', setter='set_factor_2nd_uom')
quantity2nd = fields.Function(fields.Many2One(
@ -86,8 +84,7 @@ class SecondUomMixin(object):
raise UserError(gettext(
'cashbook_investment.msg_uomcat_mismatch',
cat1=from_uom.category.rec_name,
cat2=booktransf.quantity_uom.category.rec_name,
))
cat2=booktransf.quantity_uom.category.rec_name))
values['quantity_2nd_uom'] = Decimal(UOM.compute_qty(
from_uom,
@ -96,8 +93,7 @@ class SecondUomMixin(object):
round=False,
)).quantize(Decimal(
Decimal(1) /
10 ** booktransf.quantity_digits)
)
10 ** booktransf.quantity_digits))
return values
@classmethod
@ -175,8 +171,7 @@ class SecondUomMixin(object):
self.quantity_uom,
float(self.quantity),
self.booktransf.quantity_uom,
round=False,
))
round=False))
if self.quantity != Decimal('0.0'):
self.factor_2nd_uom = (
self.quantity_2nd_uom / self.quantity