Bug
This commit is contained in:
@@ -1123,6 +1123,10 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
|
|||||||
if self.amount_second_currency and amount:
|
if self.amount_second_currency and amount:
|
||||||
return round(abs(self.amount_second_currency) / amount, 6)
|
return round(abs(self.amount_second_currency) / amount, 6)
|
||||||
|
|
||||||
|
def _set_rate_from_amounts(self):
|
||||||
|
if self.amount_second_currency and not self.rate:
|
||||||
|
self.rate = self.get_rate()
|
||||||
|
|
||||||
@fields.depends(
|
@fields.depends(
|
||||||
'debit', 'credit',
|
'debit', 'credit',
|
||||||
'date','second_currency','amount_second_currency', 'rate',
|
'date','second_currency','amount_second_currency', 'rate',
|
||||||
@@ -1286,6 +1290,7 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
|
|||||||
self.amount_second_currency = \
|
self.amount_second_currency = \
|
||||||
self.amount_second_currency.copy_sign(
|
self.amount_second_currency.copy_sign(
|
||||||
(self.debit or 0) - (self.credit or 0))
|
(self.debit or 0) - (self.credit or 0))
|
||||||
|
self._set_rate_from_amounts()
|
||||||
|
|
||||||
@fields.depends('account')
|
@fields.depends('account')
|
||||||
def on_change_account(self):
|
def on_change_account(self):
|
||||||
@@ -1590,6 +1595,13 @@ class Line(DescriptionOriginMixin, MoveLineMixin, ModelSQL, ModelView):
|
|||||||
for fname in move_fields(move_name=False):
|
for fname in move_fields(move_name=False):
|
||||||
vals.setdefault(fname, None)
|
vals.setdefault(fname, None)
|
||||||
lines = super(Line, cls).create(vlist)
|
lines = super(Line, cls).create(vlist)
|
||||||
|
to_save = []
|
||||||
|
for line in lines:
|
||||||
|
if line.amount_second_currency and not line.rate:
|
||||||
|
line._set_rate_from_amounts()
|
||||||
|
to_save.append(line)
|
||||||
|
if to_save:
|
||||||
|
cls.save(to_save)
|
||||||
period_and_journals = set((line.period, line.journal)
|
period_and_journals = set((line.period, line.journal)
|
||||||
for line in lines)
|
for line in lines)
|
||||||
for period, journal in period_and_journals:
|
for period, journal in period_and_journals:
|
||||||
|
|||||||
Reference in New Issue
Block a user