From 6519bdad66b44f14c61c4933062a5bbc4ccd19d1 Mon Sep 17 00:00:00 2001 From: jguenat Date: Sat, 10 Jun 2023 14:57:09 +0200 Subject: [PATCH 1/2] [IMP] commission: use mail thread and improve report --- commission/models/commission_settlement.py | 7 + .../reports/report_settlement_templates.xml | 128 +++++++++++------- commission/tests/test_commission.py | 7 + .../views/commission_settlement_views.xml | 5 + 4 files changed, 95 insertions(+), 52 deletions(-) diff --git a/commission/models/commission_settlement.py b/commission/models/commission_settlement.py index d9355165a..6337bb70e 100644 --- a/commission/models/commission_settlement.py +++ b/commission/models/commission_settlement.py @@ -10,6 +10,7 @@ class CommissionSettlement(models.Model): _name = "commission.settlement" _description = "Settlement" + _inherit = ["mail.thread", "mail.activity.mixin"] name = fields.Char() total = fields.Float(compute="_compute_total", readonly=True, store=True) @@ -79,6 +80,12 @@ def _compute_can_edit(self): def action_cancel(self): self.write({"state": "cancel"}) + def _message_auto_subscribe_followers(self, updated_values, subtype_ids): + res = super()._message_auto_subscribe_followers(updated_values, subtype_ids) + if updated_values.get("agent_id"): + res.append((updated_values["agent_id"], subtype_ids, False)) + return res + class SettlementLine(models.Model): _name = "commission.settlement.line" diff --git a/commission/reports/report_settlement_templates.xml b/commission/reports/report_settlement_templates.xml index f11a6955a..e45ea4e05 100644 --- a/commission/reports/report_settlement_templates.xml +++ b/commission/reports/report_settlement_templates.xml @@ -1,61 +1,85 @@ + + + diff --git a/commission/tests/test_commission.py b/commission/tests/test_commission.py index d7f145f2b..e3b573f01 100644 --- a/commission/tests/test_commission.py +++ b/commission/tests/test_commission.py @@ -167,3 +167,10 @@ def test_res_partner_agent_propagation(self): # Write partner.agent_ids = [(4, self.agent_annual.id)] self.assertEqual(set(child.agent_ids.ids), set(partner.agent_ids.ids)) + + def test_auto_subscribe_agent(self): + settlement = self._create_settlement( + self.agent_monthly, self.commission_net_paid + ) + # Agent must be in the followers + self.assertIn(self.agent_monthly, settlement.message_partner_ids) diff --git a/commission/views/commission_settlement_views.xml b/commission/views/commission_settlement_views.xml index 8118c8554..37ff570c7 100644 --- a/commission/views/commission_settlement_views.xml +++ b/commission/views/commission_settlement_views.xml @@ -104,6 +104,11 @@ +
+ + + +
From c08092939406ef0b3392b07e9781b48807e9bda9 Mon Sep 17 00:00:00 2001 From: jguenat Date: Mon, 12 Jun 2023 21:49:29 +0200 Subject: [PATCH 2/2] [IMP] account_commission: improve report --- .../views/report_settlement_templates.xml | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/account_commission/views/report_settlement_templates.xml b/account_commission/views/report_settlement_templates.xml index a77b4a5e7..235992eb1 100644 --- a/account_commission/views/report_settlement_templates.xml +++ b/account_commission/views/report_settlement_templates.xml @@ -1,21 +1,36 @@ -