changeset 3f95d21c3513 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset;node=3f95d21c3513
description:
        Set correct date on invoice and lines account context

        It is required to correctly compute the active accounts depending on 
the date

        issue8523
        review287821002
diffstat:

 invoice.py |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (38 lines):

diff -r 6d481209a7e0 -r 3f95d21c3513 invoice.py
--- a/invoice.py        Fri Jul 26 09:39:36 2019 +0200
+++ b/invoice.py        Fri Jul 26 09:44:39 2019 +0200
@@ -145,13 +145,19 @@
             },
         depends=['company'])
     account = fields.Many2One('account.account', 'Account', required=True,
-        states=_STATES, depends=_DEPENDS + ['type', 'company'],
+        states=_STATES, depends=_DEPENDS + [
+            'type', 'company', 'accounting_date', 'invoice_date'],
         domain=[
             ('company', '=', Eval('company', -1)),
             If(Eval('type') == 'out',
                 ('type.receivable', '=', True),
                 ('type.payable', '=', True)),
-            ])
+            ],
+        context={
+            'date': If(Eval('accounting_date'),
+                Eval('accounting_date'),
+                Eval('invoice_date')),
+            })
     payment_term = fields.Many2One('account.invoice.payment_term',
         'Payment Term', states=_STATES, depends=_DEPENDS)
     lines = fields.One2Many('account.invoice.line', 'invoice', 'Lines',
@@ -1616,9 +1622,9 @@
             'readonly': _states['readonly'],
             },
         context={
-            'date': If(Bool(Eval('_parent_invoice.accounting_date')),
-                Eval('_parent_invoice.accounting_date'),
-                Eval('_parent_invoice.invoice_date')),
+            'date': If(Eval('_parent_invoice', {}).get('accounting_date'),
+                Eval('_parent_invoice', {}).get('accounting_date'),
+                Eval('_parent_invoice', {}).get('invoice_date')),
             },
         depends=['type', 'invoice_type', 'company'] + _depends)
     unit_price = fields.Numeric('Unit Price', digits=price_digits,

Reply via email to