Skip to content

Commit 785d49f

Browse files
aliyaqdp-odoo
authored andcommitted
[IMP] account: emphasizes exchange diff entries in payment widget
Task ID: 2712093 Currently: - In the payment widget the exchange difference value is always shown as 0 and is described as "Paid on", which can be confusing for a user Desired: - The exchange difference should have the difference amount and be described as "Exchange difference" (text-muted) - In the payment widget pop-up, show the both the amount in company and foreign currencies closes #82206 Signed-off-by: Quentin De Paoli <qdp@odoo.com>
1 parent bd8f39a commit 785d49f

3 files changed

Lines changed: 53 additions & 34 deletions

File tree

addons/account/models/account_move.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,30 +1633,39 @@ def _compute_payments_widget_to_reconcile_info(self):
16331633
def _get_reconciled_info_JSON_values(self):
16341634
self.ensure_one()
16351635
reconciled_vals = []
1636-
for partial, amount, counterpart_line in self._get_reconciled_invoices_partials():
1637-
reconciled_vals.append(self._get_reconciled_vals(partial, amount, counterpart_line))
1638-
return reconciled_vals
1636+
reconciled_partials, exchange_diff_moves = self._get_reconciled_invoices_partials()
1637+
for partial, amount, counterpart_line in reconciled_partials:
1638+
if counterpart_line.move_id.ref:
1639+
reconciliation_ref = '%s (%s)' % (counterpart_line.move_id.name, counterpart_line.move_id.ref)
1640+
else:
1641+
reconciliation_ref = counterpart_line.move_id.name
16391642

1640-
def _get_reconciled_vals(self, partial, amount, counterpart_line):
1641-
if counterpart_line.move_id.ref:
1642-
reconciliation_ref = '%s (%s)' % (counterpart_line.move_id.name, counterpart_line.move_id.ref)
1643-
else:
1644-
reconciliation_ref = counterpart_line.move_id.name
1645-
return {
1646-
'name': counterpart_line.name,
1647-
'journal_name': counterpart_line.journal_id.name,
1648-
'amount': amount,
1649-
'currency': self.currency_id.symbol,
1650-
'digits': [69, self.currency_id.decimal_places],
1651-
'position': self.currency_id.position,
1652-
'date': counterpart_line.date,
1653-
'payment_id': counterpart_line.id,
1654-
'partial_id': partial.id,
1655-
'account_payment_id': counterpart_line.payment_id.id,
1656-
'payment_method_name': counterpart_line.payment_id.payment_method_line_id.name,
1657-
'move_id': counterpart_line.move_id.id,
1658-
'ref': reconciliation_ref,
1659-
}
1643+
currency = self.currency_id
1644+
is_exchange = counterpart_line.move_id.id in exchange_diff_moves
1645+
if is_exchange:
1646+
amount = counterpart_line.move_id.amount_total_signed
1647+
currency = self.company_id.currency_id
1648+
1649+
reconciled_vals.append({
1650+
'name': counterpart_line.name,
1651+
'journal_name': counterpart_line.journal_id.name,
1652+
'amount': amount,
1653+
'currency': currency.symbol,
1654+
'digits': [69, currency.decimal_places],
1655+
'position': currency.position,
1656+
'date': counterpart_line.date,
1657+
'payment_id': counterpart_line.id,
1658+
'partial_id': partial.id,
1659+
'account_payment_id': counterpart_line.payment_id.id,
1660+
'payment_method_name': counterpart_line.payment_id.payment_method_line_id.name,
1661+
'move_id': counterpart_line.move_id.id,
1662+
'ref': reconciliation_ref,
1663+
# these are necessary for the views to change depending on the values
1664+
'is_exchange': is_exchange,
1665+
'amount_company_currency': formatLang(self.env, abs(counterpart_line.balance), currency_obj=counterpart_line.company_id.currency_id),
1666+
'amount_foreign_currency': formatLang(self.env, abs(counterpart_line.amount_currency), currency_obj=counterpart_line.currency_id) if counterpart_line.currency_id != counterpart_line.company_id.currency_id else False
1667+
})
1668+
return reconciled_vals
16601669

16611670
@api.depends('move_type', 'line_ids.amount_residual')
16621671
def _compute_payments_widget_reconciled_info(self):
@@ -2438,12 +2447,17 @@ def _get_reconciled_invoices_partials(self):
24382447
pay_term_lines = self.line_ids\
24392448
.filtered(lambda line: line.account_internal_type in ('receivable', 'payable'))
24402449
invoice_partials = []
2450+
exchange_diff_moves = []
24412451

24422452
for partial in pay_term_lines.matched_debit_ids:
24432453
invoice_partials.append((partial, partial.credit_amount_currency, partial.debit_move_id))
2454+
if partial.exchange_move_id:
2455+
exchange_diff_moves.append(partial.exchange_move_id.id)
24442456
for partial in pay_term_lines.matched_credit_ids:
24452457
invoice_partials.append((partial, partial.debit_amount_currency, partial.credit_move_id))
2446-
return invoice_partials
2458+
if partial.exchange_move_id:
2459+
exchange_diff_moves.append(partial.exchange_move_id.id)
2460+
return invoice_partials, exchange_diff_moves
24472461

24482462
def _reverse_move_vals(self, default_values, cancel=True):
24492463
''' Reverse values passed as parameter being the copied values of the original journal entry.

addons/account/static/src/xml/account_payment.xml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,24 @@
3737
<td>
3838
<a role="button" tabindex="0" class="js_payment_info fa fa-info-circle" t-att-index="line.index" style="margin-right:5px;" aria-label="Info" title="Journal Entry Info" data-toggle="tooltip"></a>
3939
</td>
40-
<td>
41-
<i class="o_field_widget text-right o_payment_label">Paid on <t t-esc="line.date"></t></i>
40+
<td t-if="!line.is_exchange">
41+
<i class="o_field_widget text-left o_payment_label">Paid on <t t-esc="line.date"></t></i>
42+
</td>
43+
<td t-if="line.is_exchange">
44+
<i class="o_field_widget text-left o_payment_label text-muted">Exchange Difference</i>
4245
</td>
4346
</t>
4447
<td style="text-align:right;">
4548
<span class="oe_form_field oe_form_field_float oe_form_field_monetary" style="margin-left: -10px;">
4649
<t t-if="line.position === 'before'">
4750
<t t-esc="line.currency"/>
4851
</t>
49-
<t t-esc="line.amount"></t>
52+
<t t-if="!line.is_exchange">
53+
<t t-esc="line.amount"/>
54+
</t>
55+
<t t-if="line.is_exchange">
56+
<i class="text-muted"><t t-esc="line.amount"/></i>
57+
</t>
5058
<t t-if="line.position === 'after'">
5159
<t t-esc="line.currency"/>
5260
</t>
@@ -64,12 +72,9 @@
6472
<tr>
6573
<td><strong>Amount: </strong></td>
6674
<td>
67-
<t t-if="position === 'before'">
68-
<t t-esc="currency"/>
69-
</t>
70-
<t t-esc="amount"></t>
71-
<t t-if="position === 'after'">
72-
<t t-esc="currency"/>
75+
<t t-esc="amount_company_currency"></t>
76+
<t t-if="amount_foreign_currency">
77+
(<span class="fa fa-money"/> <t t-esc="amount_foreign_currency"/>)
7378
</t>
7479
</td>
7580
</tr>

addons/account/views/report_invoice.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
<t t-if="o.payment_state != 'invoicing_legacy'">
142142
<t t-set="payments_vals" t-value="o.sudo()._get_reconciled_info_JSON_values()"/>
143143
<t t-foreach="payments_vals" t-as="payment_vals">
144-
<tr>
144+
<tr t-if="payment_vals['is_exchange'] == 0">
145145
<td>
146146
<i class="oe_form_field text-right oe_payment_label">Paid on <t t-esc="payment_vals['date']" t-options='{"widget": "date"}'/></i>
147147
</td>

0 commit comments

Comments
 (0)