Add delegated amount on lines to pay

issue10345
review346191002
This commit is contained in:
Nicolas Évrard
2022-04-11 19:19:54 +02:00
parent 22271d30e6
commit 1d11822903
5 changed files with 37 additions and 0 deletions
+1
View File
@@ -1,3 +1,4 @@
* Add delegated amount on move lines
* Enforce same type for children account as their parent
* Show debit / credit columns in ledgers when they contain lines
* Count number of lines in Account and General Ledger
+21
View File
@@ -841,6 +841,13 @@ class Line(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('reconciliation', False),
}),
'get_delegated_amount')
del _states
@@ -1035,6 +1042,20 @@ class Line(MoveLineMixin, ModelSQL, ModelView):
order_move_origin = MoveLineMixin._order_move_field('origin')
order_move_state = MoveLineMixin._order_move_field('state')
def get_delegated_amount(self, name):
def final_delegated_line(line):
if not line.reconciliation or not line.reconciliation.delegate_to:
return line
return final_delegated_line(line.reconciliation.delegate_to)
final_delegation = final_delegated_line(self)
if final_delegation == self:
return None
elif final_delegation.reconciliation:
return final_delegation.amount_currency.round(0)
else:
return final_delegation.amount
@classmethod
def query_get(cls, table):
'''
+11
View File
@@ -117,6 +117,14 @@ Group lines::
>>> payable.balance, payable.amount_second_currency
(Decimal('0.00'), Decimal('0.00'))
>>> delegated_line1, delegated_line2 = lines
>>> delegated_line1.reload()
>>> delegated_line2.reload()
>>> delegated_line1.delegated_amount
Decimal('45')
>>> delegated_line2.delegated_amount
Decimal('45')
>>> Reconciliation = Model.get('account.move.reconciliation')
>>> reconciliations = Reconciliation.find([])
>>> len(reconciliations)
@@ -151,3 +159,6 @@ Cancelling the delegation move::
>>> cancel.execute('cancel')
>>> Reconciliation.find([('id', '=', reconciliations[0].id)])
[]
>>> delegated_line1.reload()
>>> delegated_line1.delegated_amount
+3
View File
@@ -34,8 +34,11 @@ this repository contains the full copyright notices and license terms. -->
<field name="maturity_date"/>
<label name="party"/>
<field name="party"/>
<newline/>
<label name="reconciliation"/>
<field name="reconciliation"/>
<label name="delegated_amount"/>
<field name="delegated_amount" symbol="amount_currency"/>
<label name="amount_second_currency"/>
<field name="amount_second_currency"/>
<label name="second_currency"/>
+1
View File
@@ -11,6 +11,7 @@ this repository contains the full copyright notices and license terms. -->
<field name="party" expand="1"/>
<field name="debit" sum="Debit"/>
<field name="credit" sum="Credit"/>
<field name="delegated_amount" optional="0"/>
<field name="tax_lines" optional="1"/>
<field name="description" expand="1" optional="1"/>
<field name="move_description" expand="1" optional="1"/>