bug padding

This commit is contained in:
2026-04-28 12:19:06 +02:00
parent ca20d418cc
commit 4faa7fd83c
2 changed files with 11 additions and 8 deletions

View File

@@ -1120,11 +1120,13 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
def get_rate(self,name=None):
amount = self.credit if self.credit else self.debit
if self.amount_second_currency and amount:
return round(abs(self.amount_second_currency) / amount, 6)
amount_second_currency = getattr(self, 'amount_second_currency', None)
if amount_second_currency and amount:
return round(abs(amount_second_currency) / amount, 6)
def _set_rate_from_amounts(self):
if self.amount_second_currency and not self.rate:
if (getattr(self, 'amount_second_currency', None)
and not getattr(self, 'rate', None)):
self.rate = self.get_rate()
@fields.depends(
@@ -1597,7 +1599,8 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
lines = super(Line, cls).create(vlist)
to_save = []
for line in lines:
if line.amount_second_currency and not line.rate:
if (getattr(line, 'amount_second_currency', None)
and not getattr(line, 'rate', None)):
line._set_rate_from_amounts()
to_save.append(line)
if to_save: