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_payment_mode_auto_reconcile: Migrate to version 16.0 #6

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

Conversation

sonhd91
Copy link
Owner

@sonhd91 sonhd91 commented Mar 8, 2023

No description provided.

@sonhd91 sonhd91 force-pushed the 16.0-mig-account_payment_mode_auto_reconcile branch from be43eb9 to 5e696bb Compare March 8, 2023 14:18
continue
payment_mode = invoice.payment_mode_id
invoice_lines = invoice.line_ids
Copy link
Owner Author

@sonhd91 sonhd91 Mar 8, 2023

Choose a reason for hiding this comment

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

account.invoice removed use account.move instead. Since payment_mode_id computed by filtered out lines with existed credits/debit, so we use the same that logic in line 57

Copy link
Owner Author

@sonhd91 sonhd91 left a comment

Choose a reason for hiding this comment

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

Change noted


def write(self, vals):
res = super(AccountMove, self).write(vals)
if "payment_mode_id" in vals or "state" in vals:
Copy link
Owner Author

@sonhd91 sonhd91 Mar 8, 2023

Choose a reason for hiding this comment

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

In Odoo16, only invoice with posted status would list potential payments can be reconciled, so we only auto reconciled after posting the invoice, draft invoice will remove existing reconciled payment

)
auto_rec_invoice.action_post()
self.assertTrue(self.payment_mode.auto_reconcile_outstanding_credits)
self.assertEqual(self.invoice_copy.amount_residual, 1615.5)
Copy link
Owner Author

@sonhd91 sonhd91 Mar 8, 2023

Choose a reason for hiding this comment

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

amount_residual now include the tax_price, so we recal amount_residual

@sonhd91 sonhd91 force-pushed the 16.0-mig-account_payment_mode_auto_reconcile branch 4 times, most recently from 8e36546 to ba9b11e Compare March 9, 2023 02:36
res = super(AccountInvoice, self).invoice_validate()
for invoice in self:
if invoice.type != "out_invoice":
@api.model_create_multi

Choose a reason for hiding this comment

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

I think you should override action_post

continue
payment_mode = invoice.payment_mode_id
invoice_lines = invoice.line_ids

Choose a reason for hiding this comment

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

invoice.line_ids only get receivable lines

self.env["account.payment"]
.browse(payment.get("account_payment_id"))
.line_ids
)

Choose a reason for hiding this comment

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

Why did you add () here?

invoice.line_ids.mapped("matched_debit_ids"),
]
)
if invoice.move_type != "out_invoice" or invoice.state == "posted":

Choose a reason for hiding this comment

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

invoice.state == "paid" -> invoice.state == "posted" is wrong. Plz check payment_state

invoice.payment_mode_warning = ""
invoice.display_payment_mode_warning = False
continue
invoice.display_payment_mode_warning = True
if (
invoice.state != "open"
invoice.state != "draft"

Choose a reason for hiding this comment

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

invoice.state != "open" should be invoice.state == 'posted' and payment_state != 'paid'

Choose a reason for hiding this comment

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

Still not update

@@ -125,8 +142,8 @@ def _compute_payment_mode_warning(self):
" any outstanding credits."
)
elif (
invoice.state == "open"
and invoice.payment_move_line_ids
invoice.state == "draft"

Choose a reason for hiding this comment

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

invoice.state == "draft" is wrong

@@ -137,11 +154,11 @@ def _compute_payment_mode_warning(self):
"reconciled payments."
)
elif (
invoice.state == "open"
and not invoice.payment_move_line_ids
invoice.state == "draft"

Choose a reason for hiding this comment

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

invoice.state == "draft" is wrong

@@ -4,8 +4,8 @@ checked.

Automatic reconciliation of outstanding credits will only happen on customer
invoices at validation if the payment mode is set or when the payment mode is
changed on an open invoice. If a payment mode using auto-reconcile is removed
from an open invoice, the existing auto reconciled payments will be removed.
changed on an draft invoice. If a payment mode using auto-reconcile is removed

Choose a reason for hiding this comment

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

plz keep open

@sonhd91 sonhd91 force-pushed the 16.0-mig-account_payment_mode_auto_reconcile branch from ba9b11e to 8ebff3f Compare March 10, 2023 05:23
)
if (
invoice.move_type != "out_invoice"
or invoice.state == "posted"

Choose a reason for hiding this comment

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

it should be or ( invoice.state == "posted" and invoice.payment_state != "paid")

invoice.payment_mode_warning = ""
invoice.display_payment_mode_warning = False
continue
invoice.display_payment_mode_warning = True
if (
invoice.state != "open"
invoice.state != "draft"

Choose a reason for hiding this comment

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

Still not update

@sonhd91 sonhd91 force-pushed the 16.0-mig-account_payment_mode_auto_reconcile branch from 8ebff3f to 00341af Compare March 10, 2023 06:12
Copy link

@lehoangan lehoangan left a comment

Choose a reason for hiding this comment

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

LGTM

@sonhd91 sonhd91 force-pushed the 16.0-mig-account_payment_mode_auto_reconcile branch 2 times, most recently from f440e10 to e97a4aa Compare June 15, 2023 06:15
grindtildeath and others added 8 commits May 6, 2024 10:36
Override write instead of using onchange

Add missing utf-8 comment

Fix warning message

Restrict to customer invoices

Add readme and load tests

Improvements after reviews

Improve doc

Unreconcile only automatically reconciled payments
* Add auto reconcile only same journal

Add an option to auto reconcile only credits that are on the same
journal than the invoice.
This make sure that unrelated payment will not be used automatically.

* Update account_payment_mode_auto_reconcile/models/account_invoice.py

Co-Authored-By: Akim Juillerat <[email protected]>

* Update account_payment_mode_auto_reconcile/tests/test_partner_auto_reconcile.py

Co-Authored-By: Akim Juillerat <[email protected]>
This small change is needed since action_invoice_open filters
invoices that can be open from other invoices that cannot.

Therefore using invoice_validate here allows for better
customizations by ensuring that the invoices to be handled are
really open (i.e. have a move generated).
As using reverse is not reliable to ensure oldest credits
will be reconciled first, use a function to sort the dicts
according to their id and allows inheritance.
@sonhd91 sonhd91 force-pushed the 16.0-mig-account_payment_mode_auto_reconcile branch from e97a4aa to 17386a6 Compare May 6, 2024 03:36
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.

6 participants