line: fix write() - get 'bookingtype' from line if not in values

This commit is contained in:
Frederik Jaeckel 2023-02-05 11:35:55 +01:00
parent e38d02ff9d
commit 438035cca2

View file

@ -150,10 +150,10 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
cashbook = Cashbook.browse([id_cashbook])[0]
if isinstance(values, dict):
type_ = values.get('bookingtype', None)
type_ = values.get('bookingtype', getattr(line, 'bookingtype', None))
quantity = values.get('quantity', None)
else :
type_ = getattr(values, 'bookingtype', None)
type_ = getattr(values, 'bookingtype', getattr(line, 'bookingtype', None))
quantity = getattr(values, 'quantity', None)
if (type_ is not None) and (cashbook.feature == 'asset'):
@ -170,6 +170,7 @@ class Line(SecondUomMixin, metaclass=PoolMeta):
})
else :
raise ValueError('invalid "bookingtype"')
return result
@classmethod