Skip to content

Commit

Permalink
Merge PR #416 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Aug 20, 2023
2 parents 503b91e + 225e3a0 commit 1fea5c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions account_commission/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ def fields_view_get(
res["arch"] = etree.tostring(invoice_xml)
return res

def unlink(self):
"""Put 'invoiced' settlements associated to the invoices back in settled state."""
self.invoice_line_ids.settlement_id.filtered(
lambda s: s.state == "invoiced"
).write({"state": "settled"})
return super().unlink()


class AccountMoveLine(models.Model):
_inherit = [
Expand Down
11 changes: 11 additions & 0 deletions account_commission/tests/test_account_commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,14 @@ def test_account_commission_multiple_settlement_ids(self):
settlements.make_invoices(self.journal, self.commission_product, grouped=True)
invoices = settlements.mapped("invoice_id")
self.assertEqual(2, invoices.settlement_count)

def test_unlink_settlement_invoice(self):
settlements = self._create_multi_settlements()
invoices = settlements.make_invoices(self.journal, self.commission_product)
self.assertTrue(
all(state == "invoiced" for state in settlements.mapped("state"))
)
invoices.unlink()
self.assertTrue(
all(state == "settled" for state in settlements.mapped("state"))
)

0 comments on commit 1fea5c6

Please sign in to comment.