diff --git a/CHANGELOG b/CHANGELOG index 1193c79204..5c75912414 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +* Add delegated amount on move lines * Add support for Python 3.10 * Remove support for Python 3.6 diff --git a/account.py b/account.py index 71c540adc4..c0d3f0a78c 100644 --- a/account.py +++ b/account.py @@ -1,7 +1,7 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. from sql import Literal, Null, Select, Window -from sql.aggregate import BoolAnd, Min, Sum +from sql.aggregate import BoolAnd, BoolOr, Min, Sum from sql.functions import CurrentTimestamp, FirstValue from trytond.model import ModelSQL, ModelView, fields @@ -47,7 +47,16 @@ class MoveLineGroup(MoveLineMixin, ModelSQL, ModelView): 'get_amount') amount_currency = fields.Function(fields.Many2One( 'currency.currency', "Amount Currency"), 'get_amount_currency') + delegated_amount = fields.Function(Monetary( + "Delegated Amount", + currency='amount_currency', digits='amount_currency', + states={ + 'invisible': ~Eval('partially_reconciled', False), + }), + 'get_delegated_amount') + partially_reconciled = fields.Boolean( + "Partially Reconciled", readonly=True) reconciled = fields.Boolean("Reconciled", readonly=True) amount_reconciled = Monetary( "Amount Reconciled", @@ -136,6 +145,7 @@ class MoveLineGroup(MoveLineMixin, ModelSQL, ModelView): Sum(line.debit).as_('debit'), Sum(line.credit).as_('credit'), Sum(line.amount_second_currency).as_('amount_second_currency'), + BoolOr(line.reconciliation != Null).as_('partially_reconciled'), BoolAnd(line.reconciliation != Null).as_('reconciled'), Sum( line.debit + line.credit, @@ -153,6 +163,10 @@ class MoveLineGroup(MoveLineMixin, ModelSQL, ModelView): if self.account: return self.account.currency.id + def get_delegated_amount(self, name): + return self.amount_currency.round( + sum(l.delegated_amount for l in self.lines if l.delegated_amount)) + class MoveLineGroup_MoveLine(ModelSQL): "Account Move Line Group - Move Line" diff --git a/tests/scenario_account_move_line_grouping.rst b/tests/scenario_account_move_line_grouping.rst index 5a447176c9..20ff9c5dd3 100644 --- a/tests/scenario_account_move_line_grouping.rst +++ b/tests/scenario_account_move_line_grouping.rst @@ -109,6 +109,10 @@ Check lines grouped:: ... ]) >>> line.amount_reconciled == Decimal(22) True + >>> line.partially_reconciled + True + >>> line.delegated_amount + Decimal('0.00') >>> if backend.name != 'sqlite': ... len(line.lines) ... else: @@ -125,4 +129,3 @@ Check lines grouped:: ... else: ... 1 1 - diff --git a/view/move_line_group_form.xml b/view/move_line_group_form.xml index 8514317a91..193773b832 100644 --- a/view/move_line_group_form.xml +++ b/view/move_line_group_form.xml @@ -40,6 +40,8 @@ this repository contains the full copyright notices and license terms. -->