-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: 16.0
Are you sure you want to change the base?
Conversation
be43eb9
to
5e696bb
Compare
continue | ||
payment_mode = invoice.payment_mode_id | ||
invoice_lines = invoice.line_ids |
There was a problem hiding this comment.
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
There was a problem hiding this 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: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
8e36546
to
ba9b11e
Compare
res = super(AccountInvoice, self).invoice_validate() | ||
for invoice in self: | ||
if invoice.type != "out_invoice": | ||
@api.model_create_multi |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | ||
) |
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plz keep open
ba9b11e
to
8ebff3f
Compare
) | ||
if ( | ||
invoice.move_type != "out_invoice" | ||
or invoice.state == "posted" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not update
8ebff3f
to
00341af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
f440e10
to
e97a4aa
Compare
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.
e97a4aa
to
17386a6
Compare
No description provided.