changeset 7115dc98fd72 in modules/account_tax_cash:default
details:
https://hg.tryton.org/modules/account_tax_cash?cmd=changeset;node=7115dc98fd72
description:
Update cash basis on reconciliation
The reconciled lines must be added to the payment amount and
reconciliation
should trigger the update of cash basis via process call.
issue8207
review249121002
diffstat:
account.py | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diffs (59 lines):
diff -r f726093955eb -r 7115dc98fd72 account.py
--- a/account.py Sun Mar 24 18:00:01 2019 +0100
+++ b/account.py Wed Mar 27 00:35:37 2019 +0100
@@ -249,7 +249,11 @@
ratio = 0
else:
payment_amount = sum(
- l.debit - l.credit for l in self.payment_lines)
+ l.debit - l.credit for l in self.payment_lines
+ if not l.reconciliation)
+ payment_amount -= sum(
+ l.debit - l.credit for l in self.lines_to_pay
+ if l.reconciliation)
if amount:
ratio = abs(payment_amount / amount)
else:
@@ -259,21 +263,35 @@
@classmethod
def write(cls, *args):
- pool = Pool()
- TaxLine = pool.get('account.tax.line')
- Date = pool.get('ir.date')
- Period = pool.get('account.period')
-
super(Invoice, cls).write(*args)
invoices = []
actions = iter(args)
for records, values in zip(actions, actions):
- if ('payment_lines' in values
- or values.get('state') in {'paid', 'cancel', 'posted'}):
+ if 'payment_lines' in values:
invoices.extend(records)
invoices = cls.browse(sum(args[0:None:2], []))
invoices = [i for i in invoices if i.move]
+ cls._update_tax_cash_basis(invoices)
+
+ @classmethod
+ def process(cls, invoices):
+ super(Invoice, cls).process(invoices)
+ cls._update_tax_cash_basis(invoices)
+
+ @classmethod
+ @ModelView.button
+ @Workflow.transition('cancel')
+ def cancel(cls, invoices):
+ super(Invoice, cls).cancel(invoices)
+ cls._update_tax_cash_basis(invoices)
+
+ @classmethod
+ def _update_tax_cash_basis(cls, invoices):
+ pool = Pool()
+ TaxLine = pool.get('account.tax.line')
+ Date = pool.get('ir.date')
+ Period = pool.get('account.period')
# Call update_cash_basis grouped per period and ratio only because
# group_cash_basis_key already group per move_line.