Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] account_invoice_view_payment: Migration to 16.0 #1852

Open
wants to merge 26 commits into
base: 16.0
Choose a base branch
from

Conversation

anusriNPS
Copy link

Migrating account_invoice_view_payment to 16.0

@anusriNPS anusriNPS marked this pull request as draft November 25, 2024 08:31
@anusriNPS anusriNPS force-pushed the 16.0-mig-account_invoice_view_payment branch from 2bc55d3 to 95d375f Compare November 25, 2024 08:42
oca-transbot and others added 22 commits November 25, 2024 09:51
Currently translated at 100,0% (5 of 5 strings)

Translation: account-invoicing-11.0/account-invoicing-11.0-account_invoice_view_payment
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-11-0/account-invoicing-11-0-account_invoice_view_payment/nl_NL/
Currently translated at 100,0% (5 of 5 strings)

Translation: account-invoicing-11.0/account-invoicing-11.0-account_invoice_view_payment
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-11-0/account-invoicing-11-0-account_invoice_view_payment/de/
Updated by Update PO files to match POT (msgmerge) hook in Weblate.
Currently translated at 100.0% (5 of 5 strings)

Translation: account-invoicing-12.0/account-invoicing-12.0-account_invoice_view_payment
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-12-0/account-invoicing-12-0-account_invoice_view_payment/pt_BR/
Currently translated at 100.0% (5 of 5 strings)

Translation: account-invoicing-15.0/account-invoicing-15.0-account_invoice_view_payment
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-account_invoice_view_payment/es/
creating as many payments as invoices and it was not reconciling
the invoices.
The solution is to remove the Validate & View Payments button because
the standard button "Create Payments" already returns the action
to see the payments involved
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: account-invoicing-15.0/account-invoicing-15.0-account_invoice_view_payment
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-account_invoice_view_payment/
Currently translated at 100.0% (4 of 4 strings)

Translation: account-invoicing-15.0/account-invoicing-15.0-account_invoice_view_payment
Translate-URL: https://translation.odoo-community.org/projects/account-invoicing-15-0/account-invoicing-15-0-account_invoice_view_payment/pt_BR/
@anusriNPS anusriNPS force-pushed the 16.0-mig-account_invoice_view_payment branch 3 times, most recently from 8afc9f6 to 099f5f2 Compare November 25, 2024 09:04
@anusriNPS anusriNPS force-pushed the 16.0-mig-account_invoice_view_payment branch 10 times, most recently from 61876fc to 8829e37 Compare November 28, 2024 09:07
@anusriNPS anusriNPS marked this pull request as ready for review November 28, 2024 09:08
Comment on lines 12 to 66
def _get_reconciled_info_JSON_values(self):
self.ensure_one()
reconciled_vals = []
for move in self:
if move.state == "posted" and move.is_invoice(include_receipts=True):
reconciled_partials = move._get_all_reconciled_invoice_partials()
for reconciled_partial in reconciled_partials:
counterpart_line = reconciled_partial["aml"]
if counterpart_line.move_id.ref:
reconciliation_ref = "%s (%s)" % (
counterpart_line.move_id.name,
counterpart_line.move_id.ref,
)
else:
reconciliation_ref = counterpart_line.move_id.name
if (
counterpart_line.amount_currency
and counterpart_line.currency_id
!= counterpart_line.company_id.currency_id
):
foreign_currency = counterpart_line.currency_id
else:
foreign_currency = False

reconciled_vals.append(
{
"name": counterpart_line.name,
"journal_name": counterpart_line.journal_id.name,
"amount": reconciled_partial["amount"],
"currency_id": move.company_id.currency_id.id
if reconciled_partial["is_exchange"]
else reconciled_partial["currency"].id,
"date": counterpart_line.date,
"partial_id": reconciled_partial["partial_id"],
"account_payment_id": counterpart_line.payment_id.id,
"payment_method_name": counterpart_line.payment_id.payment_method_line_id.name, # noqa: B950
"move_id": counterpart_line.move_id.id,
"ref": reconciliation_ref,
# these are necessary for the views to change
# depending on the values
"is_exchange": reconciled_partial["is_exchange"],
"amount_company_currency": formatLang(
self.env,
abs(counterpart_line.balance),
currency_obj=counterpart_line.company_id.currency_id,
),
"amount_foreign_currency": foreign_currency
and formatLang(
self.env,
abs(counterpart_line.amount_currency),
currency_obj=foreign_currency,
),
}
)
return reconciled_vals
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: I don't think we should reintroduce this function. It changed name and structure slightly, but it's _compute_payments_widget_reconciled_info in v16 and I think you should be able to use it in the same way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Introduced new function as reconciled_vals is not obtainable from existing _compute_payments_widget_reconciled_info() or any other available methods in v16.

However, account_invoice_view_payment only uses payment related information hence using get_reconciled_payments method to achieve the same in order to view payments from invoices.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, nice catch!

@anusriNPS anusriNPS force-pushed the 16.0-mig-account_invoice_view_payment branch from 8829e37 to c30cd58 Compare December 3, 2024 13:56
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

everything else LGTM

Comment on lines 25 to 28
payment = []
for move in self:
if move._get_reconciled_payments().id:
payment.append(move._get_reconciled_payments().id)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: _get_reconciled_payments() could return multiple payments, so .id could then give a SingletonError

I've tested that _get_reconciled_payments is safe to use on a recordset with multiple records, so:

Suggested change
payment = []
for move in self:
if move._get_reconciled_payments().id:
payment.append(move._get_reconciled_payments().id)
payments = move._get_reconciled_payments().ids

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated using ids

@anusriNPS anusriNPS force-pushed the 16.0-mig-account_invoice_view_payment branch from c30cd58 to 2bfabd2 Compare December 3, 2024 14:46
@anusriNPS anusriNPS force-pushed the 16.0-mig-account_invoice_view_payment branch from 2bfabd2 to 8e4253a Compare December 3, 2024 14:53
Copy link

@aleuffre aleuffre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.