Skip to content

Commit 5da75d7

Browse files
[IMP] sale_automatic_workflow: manage 'in payment' state and no entry payments
Make sure payments that dont generate an entry are properly related to the invoice. Also, make sure no duplicate payments are created when using odoo enterprise having the 'in_payment' state
1 parent 7f33671 commit 5da75d7

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

sale_automatic_workflow/data/automatic_workflow_data.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<field name="model_id">account.move</field>
4141
<field
4242
name="domain"
43-
>[('state', '=', 'posted'), ('move_type', '=', 'out_invoice'), ('payment_state','!=','paid')]</field>
43+
>[('state', '=', 'posted'), ('move_type', '=', 'out_invoice'), ('payment_state','=','not_paid')]</field>
4444
<field name="user_ids" eval="[(4, ref('base.user_root'))]" />
4545
</record>
4646
<record id="automatic_validation" model="sale.workflow.process">

sale_automatic_workflow/models/automatic_workflow_job.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,11 @@ def _register_payment_invoice(self, invoice):
166166
payment.action_post()
167167

168168
domain = [
169-
("account_type", "in", ("asset_receivable", "liability_payable")),
169+
(
170+
"account_type",
171+
"in",
172+
self.env["account.payment"]._get_valid_payment_account_types(),
173+
),
170174
("reconciled", "=", False),
171175
]
172176
payment_lines = payment.move_id.line_ids.filtered_domain(domain)
@@ -175,6 +179,7 @@ def _register_payment_invoice(self, invoice):
175179
(payment_lines + lines).filtered_domain(
176180
[("account_id", "=", account.id), ("reconciled", "=", False)]
177181
).reconcile()
182+
lines.move_id.matched_payment_ids += payment
178183
return payment
179184

180185
@api.model

sale_automatic_workflow/tests/test_automatic_workflow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ def test_create_payment_with_invoice_currency_id(self):
214214
)
215215
self.assertTrue(payment_id)
216216
self.assertEqual(invoice.currency_id.id, payment_id.currency_id.id)
217+
self.assertEqual(invoice.payment_state, invoice._get_invoice_in_payment_state())
217218

218219
def test_create_payment_with_specified_payment_journal(self):
219220
workflow = self.create_full_automatic()

0 commit comments

Comments
 (0)