[16.0][MIG] account_payment_mode_auto_reconcile: Migrate to version 16.0#537
[16.0][MIG] account_payment_mode_auto_reconcile: Migrate to version 16.0#537
Conversation
sonhd91
commented
Mar 10, 2023
- 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
- amount_residual now include the tax_price, so we recal amount_residual
|
@sonhd91 can you please rebase to have a runboat to test? |
00341af to
f440e10
Compare
|
@sonhd91 Look to work well, thx 👍 However, the view on invoices looks broken with the alert message message not displayed properly, can you please fix? 🙏 |
f440e10 to
e97a4aa
Compare
I updated it, please check again |
|
@sonhd91 Could you rebase ? |
rousseldenis
left a comment
There was a problem hiding this comment.
Code and functional review
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
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 <akim.juillerat@camptocamp.com> * Update account_payment_mode_auto_reconcile/tests/test_partner_auto_reconcile.py Co-Authored-By: Akim Juillerat <akim.juillerat@camptocamp.com>
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
@rousseldenis |
|
This PR has the |
|
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. |
| states={"draft": [("readonly", False)], "open": [("readonly", False)]} | ||
| states={"draft": [("readonly", False)], "posted": [("readonly", False)]} |
There was a problem hiding this comment.
Do we still need this? AFAIU it means readonly is only applied on cancel?
| continue | ||
| payment_mode = invoice.payment_mode_id | ||
| invoice_lines = invoice.line_ids.filtered( | ||
| lambda line: line.account_type == "asset_receivable" |
There was a problem hiding this comment.
Not sure about that one, but somehow you're restricting this feature to customer invoices. I guess it would make more sense to use the filtering on payment term lines?
invoice_lines = invoice.line_ids.filtered(lambda l: l.display_type == 'payment_term')
| def auto_reconcile_credits(self, partial_allowed=True): | ||
| for invoice in self: | ||
| if not invoice.has_outstanding: | ||
| invoice._compute_payments_widget_to_reconcile_info() |
There was a problem hiding this comment.
It seems weird to me that you have to explicitely call this before accessing the value 😕
| ) | ||
| refund_id = cls.refund_wiz.reverse_moves().get("res_id") | ||
| cls.refund = cls.env["account.move"].browse(refund_id) | ||
| cls.payment = cls.env["account.payment"].create( |
There was a problem hiding this comment.
Why do you need to create a payment here? 🤔
| self.invoice_copy.button_draft() | ||
| self.invoice_copy.write({"payment_mode_id": False}) | ||
| self.assertEqual(self.invoice_copy.residual, 1500) | ||
| self.assertEqual(auto_rec_invoice.state, "paid") |
There was a problem hiding this comment.
IMO you should still assert invoice was paid.
|
Hi @grindtildeath , |

