Add delegated amount on lines to pay

issue10345
review346191002
This commit is contained in:
Nicolas Évrard committed 2022-04-11 19:19:54 +02:00
1 parent add53fbb77
commit cf82bbea2a
4 files changed
+22 -2

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Add delegated amount on move lines
* Add support for Python 3.10
* Remove support for Python 3.6
+15 -1
View File
@@ -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"
@@ -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
+2
View File
@@ -40,6 +40,8 @@ this repository contains the full copyright notices and license terms. -->
<label name="amount_reconciled"/>
<field name="amount_reconciled"/>
<label name="delegated_amount"/>
<field name="delegated_amount"/>
<label name="amount_second_currency"/>
<field name="amount_second_currency"/>
</page>