odoo-addon-account-commission 16.0.2.4.2__py3-none-any.whl → 17.0.1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. odoo/addons/account_commission/README.rst +80 -64
  2. odoo/addons/account_commission/__manifest__.py +2 -1
  3. odoo/addons/account_commission/i18n/account_commission.pot +15 -17
  4. odoo/addons/account_commission/i18n/es.po +24 -39
  5. odoo/addons/account_commission/i18n/hr.po +6 -17
  6. odoo/addons/account_commission/i18n/it.po +26 -38
  7. odoo/addons/account_commission/i18n/ja.po +101 -116
  8. odoo/addons/account_commission/i18n/pt.po +27 -33
  9. odoo/addons/account_commission/i18n/pt_BR.po +64 -75
  10. odoo/addons/account_commission/i18n/tr.po +16 -26
  11. odoo/addons/account_commission/models/account_move.py +2 -29
  12. odoo/addons/account_commission/models/commission.py +1 -1
  13. odoo/addons/account_commission/models/commission_settlement.py +39 -5
  14. odoo/addons/account_commission/readme/CONFIGURE.md +8 -0
  15. odoo/addons/account_commission/readme/CONTRIBUTORS.md +23 -0
  16. odoo/addons/account_commission/readme/{DESCRIPTION.rst → DESCRIPTION.md} +7 -2
  17. odoo/addons/account_commission/readme/USAGE.md +38 -0
  18. odoo/addons/account_commission/security/account_commission_security.xml +4 -0
  19. odoo/addons/account_commission/static/description/index.html +57 -39
  20. odoo/addons/account_commission/tests/test_account_commission.py +72 -155
  21. odoo/addons/account_commission/views/account_move_views.xml +19 -36
  22. odoo/addons/account_commission/views/commission_settlement_views.xml +4 -4
  23. odoo/addons/account_commission/views/commission_views.xml +1 -1
  24. odoo/addons/account_commission/views/grouped_report_settlement_templates.xml +45 -0
  25. odoo/addons/account_commission/views/report_settlement_templates.xml +8 -14
  26. odoo/addons/account_commission/wizards/wizard_invoice.xml +1 -4
  27. odoo_addon_account_commission-17.0.1.0.1.dist-info/METADATA +198 -0
  28. odoo_addon_account_commission-17.0.1.0.1.dist-info/RECORD +43 -0
  29. {odoo_addon_account_commission-16.0.2.4.2.dist-info → odoo_addon_account_commission-17.0.1.0.1.dist-info}/WHEEL +1 -1
  30. odoo_addon_account_commission-17.0.1.0.1.dist-info/top_level.txt +1 -0
  31. odoo/addons/account_commission/i18n/fr.po +0 -599
  32. odoo/addons/account_commission/readme/CONFIGURE.rst +0 -8
  33. odoo/addons/account_commission/readme/CONTRIBUTORS.rst +0 -25
  34. odoo/addons/account_commission/readme/USAGE.rst +0 -37
  35. odoo_addon_account_commission-16.0.2.4.2.dist-info/METADATA +0 -181
  36. odoo_addon_account_commission-16.0.2.4.2.dist-info/RECORD +0 -43
  37. odoo_addon_account_commission-16.0.2.4.2.dist-info/top_level.txt +0 -1
@@ -7,7 +7,7 @@ from dateutil.relativedelta import relativedelta
7
7
 
8
8
  from odoo import fields
9
9
  from odoo.exceptions import UserError, ValidationError
10
- from odoo.tests import Form, tagged
10
+ from odoo.tests import tagged
11
11
 
12
12
  from odoo.addons.commission.tests.test_commission import TestCommissionBase
13
13
 
@@ -533,164 +533,81 @@ class TestAccountCommission(TestCommissionBase):
533
533
  )
534
534
  self.assertEqual(2, len(settlements))
535
535
 
536
- def test_invoice_partial_refund(self):
537
- commission = self.commission_net_paid
538
- agent = self.agent_monthly
539
- today = fields.Date.today()
540
- # Create an invoice
541
- invoice = self._create_invoice(agent, commission, today, currency=None)
542
- invoice.action_post()
543
- # Register payment for invoice
544
- payment_journal = self.env["account.journal"].search(
545
- [("type", "=", "cash"), ("company_id", "=", invoice.company_id.id)],
546
- limit=1,
547
- )
548
- register_payments = (
549
- self.env["account.payment.register"]
550
- .with_context(active_ids=invoice.id, active_model="account.move")
551
- .create({"journal_id": payment_journal.id})
552
- )
553
- register_payments.action_create_payments()
554
- # Make a parcial refund for the invoice
555
- move_reversal = (
556
- self.env["account.move.reversal"]
557
- .with_context(active_model="account.move", active_ids=invoice.id)
558
- .create(
559
- {
560
- "reason": "no reason",
561
- "refund_method": "refund",
562
- "journal_id": invoice.journal_id.id,
563
- }
564
- )
565
- )
566
- refund_form = Form(
567
- self.env["account.move"].browse(move_reversal.reverse_moves()["res_id"])
568
- )
569
- with refund_form.invoice_line_ids.edit(0) as line:
570
- line.price_unit -= 2
571
- refund = refund_form.save()
572
- refund.action_post()
573
- # Register payment for the refund
574
- register_payments = (
575
- self.env["account.payment.register"]
576
- .with_context(active_ids=refund.id, active_model="account.move")
577
- .create({"journal_id": payment_journal.id})
578
- )
579
- register_payments.action_create_payments()
580
- # check settlement creation. The commission must be (5 - 3) * 0.2 = 0.4
581
- self._settle_agent_invoice(agent, 1)
582
- settlements = self.settle_model.search([("agent_id", "=", agent.id)])
583
- self.assertEqual(2, len(settlements.line_ids))
584
- self.assertEqual(0.4, sum(settlements.mapped("total")))
585
-
586
- def test_invoice_full_refund(self):
587
- commission = self.commission_net_paid
588
- agent = self.agent_monthly
589
- today = fields.Date.today()
590
- # Create an invoice and refund it
591
- invoice = self._create_invoice(agent, commission, today, currency=None)
592
- invoice.action_post()
593
- move_reversal = (
594
- self.env["account.move.reversal"]
595
- .with_context(active_model="account.move", active_ids=invoice.id)
596
- .create(
597
- {
598
- "reason": "no reason",
599
- "refund_method": "cancel",
600
- "journal_id": invoice.journal_id.id,
601
- }
602
- )
603
- )
604
- move_reversal.reverse_moves()
605
- # check settlement creation. The commission must be: (5 - 5) * 0.2 = 0
606
- self._settle_agent_invoice(agent, 1)
607
- settlements = self.settle_model.search(
608
- [
609
- ("agent_id", "=", agent.id),
610
- ]
611
- )
612
- self.assertEqual(2, len(settlements.line_ids))
613
- self.assertEqual(0, sum(settlements.mapped("total")))
614
-
615
- def test_invoice_modify_refund(self):
616
- commission = self.commission_net_paid
617
- agent = self.agent_monthly
618
- today = fields.Date.today()
619
- # Create an invoice
620
- invoice = self._create_invoice(agent, commission, today, currency=None)
621
- invoice.action_post()
622
- # Create a full refund and a new invoice
623
- move_reversal = (
624
- self.env["account.move.reversal"]
625
- .with_context(active_model="account.move", active_ids=invoice.id)
626
- .create(
627
- {
628
- "reason": "no reason",
629
- "refund_method": "modify",
630
- "journal_id": invoice.journal_id.id,
631
- }
632
- )
633
- )
634
- invoice2_form = Form(
635
- self.env["account.move"].browse(move_reversal.reverse_moves()["res_id"])
636
- )
637
- with invoice2_form.invoice_line_ids.edit(0) as line:
638
- line.price_unit -= 2
639
- invoice2 = invoice2_form.save()
640
- invoice2.action_post()
641
- # Register payment for the new invoice
642
- payment_journal = self.env["account.journal"].search(
643
- [("type", "=", "cash"), ("company_id", "=", invoice.company_id.id)],
644
- limit=1,
536
+ def test_grouped_report_lines_sale_invoice(self):
537
+ """Test grouped report lines for settlements coming from sale invoices."""
538
+ invoice = self.env["account.move"].create(
539
+ {
540
+ "move_type": "out_invoice",
541
+ "partner_id": self.partner.id,
542
+ "invoice_date": fields.Date.today(),
543
+ "invoice_line_ids": [
544
+ (0, 0, {"name": "Line 1", "price_unit": 100.0, "quantity": 1.0}),
545
+ (0, 0, {"name": "Line 2", "price_unit": 50.0, "quantity": 1.0}),
546
+ ],
547
+ }
645
548
  )
646
- register_payments = (
647
- self.env["account.payment.register"]
648
- .with_context(active_ids=invoice2.id, active_model="account.move")
649
- .create({"journal_id": payment_journal.id})
549
+ agent_line1 = self.env["account.invoice.line.agent"].create(
550
+ {
551
+ "object_id": invoice.invoice_line_ids[0].id,
552
+ "commission_id": self.commission_net_paid.id,
553
+ "amount": 20.0,
554
+ "agent_id": self.agent_monthly.id,
555
+ "invoice_date": fields.Date.today(),
556
+ "company_id": self.company.id,
557
+ }
650
558
  )
651
- register_payments.action_create_payments()
652
-
653
- # check settlement creation. The commission must be (5 - 5 + 3) * 0.2 = 0.6
654
- self._settle_agent_invoice(agent, 1)
655
- settlements = self.settle_model.search(
656
- [
657
- ("agent_id", "=", agent.id),
658
- ]
559
+ agent_line2 = self.env["account.invoice.line.agent"].create(
560
+ {
561
+ "object_id": invoice.invoice_line_ids[1].id,
562
+ "commission_id": self.commission_net_paid.id,
563
+ "amount": 10.0,
564
+ "agent_id": self.agent_monthly.id,
565
+ "invoice_date": fields.Date.today(),
566
+ "company_id": self.company.id,
567
+ }
659
568
  )
660
- self.assertEqual(3, len(settlements.line_ids))
661
- self.assertAlmostEqual(0.6, sum(settlements.mapped("total")), 2)
662
-
663
- def _register_payment(self, invoice):
664
- payment_journal = self.env["account.journal"].search(
665
- [("type", "=", "cash"), ("company_id", "=", self.env.company.id)],
666
- limit=1,
569
+ settlement = self.settle_model.create(
570
+ {
571
+ "agent_id": self.agent_monthly.id,
572
+ "date_from": fields.Date.today(),
573
+ "date_to": fields.Date.today(),
574
+ "settlement_type": "sale_invoice",
575
+ "company_id": self.company.id,
576
+ "line_ids": [
577
+ (
578
+ 0,
579
+ 0,
580
+ {
581
+ "date": fields.Date.today(),
582
+ "agent_id": self.agent_monthly.id,
583
+ "commission_id": self.commission_net_paid.id,
584
+ "settled_amount": 20.0,
585
+ "invoice_agent_line_id": agent_line1.id,
586
+ "currency_id": self.company.currency_id.id,
587
+ },
588
+ ),
589
+ (
590
+ 0,
591
+ 0,
592
+ {
593
+ "date": fields.Date.today(),
594
+ "agent_id": self.agent_monthly.id,
595
+ "commission_id": self.commission_net_paid.id,
596
+ "settled_amount": 10.0,
597
+ "invoice_agent_line_id": agent_line2.id,
598
+ "currency_id": self.company.currency_id.id,
599
+ },
600
+ ),
601
+ ],
602
+ }
667
603
  )
668
- register_payments = (
669
- self.env["account.payment.register"]
670
- .with_context(active_ids=invoice.id, active_model="account.move")
671
- .create({"journal_id": payment_journal.id})
604
+ grouped_lines = settlement.grouped_report_lines()
605
+ self.assertEqual(
606
+ len(grouped_lines), 1, "Lines from same invoice should be grouped together"
672
607
  )
673
- register_payments.action_create_payments()
674
608
 
675
- def test_invoice_pending_settlement(self):
676
- """Make in one settlement all pending invoices to wizard date"""
677
- fields.Date.today()
678
- self.commission_net_paid.invoice_state = "paid"
679
- invoice1 = self._create_invoice(
680
- self.agent_pending, self.commission_net_paid, "2024-02-15", currency=None
681
- )
682
- # Register payment for the new invoice
683
- invoice2 = self._create_invoice(
684
- self.agent_pending, self.commission_net_paid, "2024-03-15", currency=None
609
+ gl = grouped_lines[0]
610
+ self.assertEqual(
611
+ gl["settled_amount"], 30.0, "Grouped settled amount should be summed"
685
612
  )
686
- invoice3 = self._create_invoice(
687
- self.agent_pending, self.commission_net_paid, "2024-04-15", currency=None
688
- )
689
- # invoice1.invoice_line_ids.agent_ids._compute_amount()
690
- (invoice1 + invoice2 + invoice3).action_post()
691
- self._register_payment(invoice1)
692
- self._register_payment(invoice2)
693
- self._register_payment(invoice3)
694
- self._settle_agent_invoice(self.agent_pending, 1)
695
- settlements = self.settle_model.search([("state", "=", "settled")])
696
- self.assertEqual(len(settlements.line_ids), 3)
613
+ self.assertEqual(gl["invoice"], invoice.name)
@@ -15,7 +15,7 @@
15
15
  widget="monetary"
16
16
  options="{'currency_field': 'currency_id'}"
17
17
  />
18
- <field name="currency_id" invisible="1" />
18
+ <field name="currency_id" column_invisible="1" />
19
19
  </tree>
20
20
  </field>
21
21
  </record>
@@ -28,15 +28,12 @@
28
28
  <group
29
29
  string="Commissions"
30
30
  name="group_commission"
31
- attrs="{'invisible': [('agent_ids', '=', [])], 'readonly': [('any_settled', '=', True)]}"
31
+ invisible="not agent_ids"
32
+ readonly="any_settled"
32
33
  >
33
34
  <field name="any_settled" invisible="1" />
34
35
  <field name="commission_free" force_save="1" />
35
- <field
36
- name="agent_ids"
37
- attrs="{'readonly': [('commission_free', '=', True)]}"
38
- force_save="1"
39
- />
36
+ <field name="agent_ids" readonly="commission_free" force_save="1" />
40
37
  </group>
41
38
  </xpath>
42
39
  </field>
@@ -52,7 +49,7 @@
52
49
  type="object"
53
50
  class="oe_stat_button"
54
51
  icon="fa-pencil-square-o"
55
- attrs="{'invisible': [('settlement_count', '=', 0)]}"
52
+ invisible="(settlement_count == 0)"
56
53
  >
57
54
  <field
58
55
  name="settlement_count"
@@ -65,28 +62,20 @@
65
62
  expr="//field[@name='invoice_line_ids']/tree//field[@name='price_subtotal']"
66
63
  position="after"
67
64
  >
68
- <field name="settlement_id" invisible="1" />
69
- <field name="commission_free" invisible="1" />
70
- <field name="any_settled" invisible="1" />
65
+ <field name="settlement_id" column_invisible="1" />
66
+ <field name="commission_free" column_invisible="1" />
67
+ <field name="any_settled" column_invisible="1" />
71
68
  <button
72
69
  name="button_edit_agents"
73
70
  title="Edit agents"
74
71
  icon="fa-users"
75
- attrs="{'invisible': [
76
- '|',
77
- ('commission_free', '=', True),
78
- ('any_settled', '=', True),
79
- ],
80
- 'column_invisible': [
81
- ('parent.move_type', 'not in', ['out_invoice', 'out_refund'])
82
- ]}"
72
+ invisible="commission_free or any_settled"
73
+ column_invisible="(parent.move_type not in ('out_invoice', 'out_refund'))"
83
74
  type="object"
84
75
  />
85
76
  <field
86
77
  name="commission_status"
87
- attrs="{'column_invisible': [
88
- ('parent.move_type', 'not in', ['out_invoice', 'out_refund'])
89
- ]}"
78
+ column_invisible="(parent.move_type not in ('out_invoice', 'out_refund'))"
90
79
  />
91
80
  </xpath>
92
81
  <xpath expr="//field[@name='invoice_line_ids']" position="after">
@@ -94,28 +83,22 @@
94
83
  name="recompute_lines_agents"
95
84
  type="object"
96
85
  string="Regenerate agents"
97
- attrs="{'invisible': [
98
- '|',
99
- ('move_type', 'not in', ['out_invoice', 'out_refund']),
100
- ('state', '!=', 'draft')
101
- ]}"
86
+ invisible="(move_type not in ['out_invoice', 'out_refund']) or (state != 'draft')"
102
87
  />
103
88
  </xpath>
104
89
  <!-- Needed for fields in invoice lines to be saved -->
105
90
  <xpath expr="//field[@name='line_ids']/tree" position="inside">
106
- <field name="settlement_id" invisible="1" />
107
- <field name="commission_free" invisible="1" />
108
- <field name="any_settled" invisible="1" />
109
- <field name="commission_status" invisible="1" />
91
+ <field name="settlement_id" column_invisible="1" />
92
+ <field name="commission_free" column_invisible="1" />
93
+ <field name="any_settled" column_invisible="1" />
94
+ <field name="commission_status" column_invisible="1" />
110
95
  </xpath>
111
96
  <field name="tax_totals" position="after">
112
97
  <field
113
98
  name="commission_total"
114
99
  widget="monetary"
115
100
  options="{'currency_field': 'currency_id'}"
116
- attrs="{'invisible': [
117
- ('move_type', 'not in', ['out_invoice', 'out_refund'])
118
- ]}"
101
+ invisible="(move_type not in ('out_invoice', 'out_refund'))"
119
102
  />
120
103
  </field>
121
104
  </field>
@@ -132,9 +115,9 @@
132
115
  class="oe_stat_button"
133
116
  icon="fa-pencil-square-o"
134
117
  string="Settlements"
135
- attrs="{'invisible': [('settlement_count', '=', 0)]}"
118
+ invisible="(settlement_count == 0)"
136
119
  />
137
- <field name="settlement_count" invisible="1" />
120
+ <field name="settlement_count" column_invisible="1" />
138
121
  </field>
139
122
  </field>
140
123
  </record>
@@ -21,7 +21,7 @@
21
21
  <button name="action_cancel" position="before">
22
22
  <button
23
23
  string="Make invoice"
24
- attrs="{'invisible': ['|', ('state', '!=', 'settled'), ('agent_type', '!=', 'agent')]}"
24
+ invisible="(state != 'settled') or (agent_type != 'agent')"
25
25
  class="oe_highlight"
26
26
  type="object"
27
27
  name="action_invoice"
@@ -29,7 +29,7 @@
29
29
  />
30
30
  <button
31
31
  string="Reset to draft"
32
- attrs="{'invisible': [('state', '!=', 'except_invoice')]}"
32
+ invisible="(state != 'except_invoice')"
33
33
  type="object"
34
34
  name="action_draft"
35
35
  groups="account.group_account_invoice"
@@ -38,7 +38,7 @@
38
38
  <field name="settlement_type" position="after">
39
39
  <field
40
40
  name="invoice_id"
41
- attrs="{'invisible': [('state', '!=', 'invoiced')]}"
41
+ invisible="(state != 'invoiced')"
42
42
  groups="account.group_account_invoice"
43
43
  />
44
44
  </field>
@@ -48,7 +48,7 @@
48
48
  >
49
49
  <field
50
50
  name="invoice_line_id"
51
- attrs="{'column_invisible': [('parent.settlement_type', '!=', 'sale_invoice')]}"
51
+ column_invisible="(parent.settlement_type != 'sale_invoice')"
52
52
  groups="account.group_account_invoice"
53
53
  />
54
54
  </xpath>
@@ -8,7 +8,7 @@
8
8
  <xpath expr="//group[@name='commision_params']" position="inside">
9
9
  <field
10
10
  name="invoice_state"
11
- attrs="{'required': [('settlement_type', '=', 'sale_invoice')]}"
11
+ required="(settlement_type == 'sale_invoice')"
12
12
  />
13
13
  </xpath>
14
14
  </field>
@@ -0,0 +1,45 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <odoo>
3
+ <template
4
+ id="grouped_report_settlement_document"
5
+ inherit_id="commission.grouped_report_settlement_document"
6
+ >
7
+ <xpath expr="//th[@name='th_commission']" position="attributes">
8
+ <attribute name="t-if">o.settlement_type != 'sale_invoice'</attribute>
9
+ </xpath>
10
+ <xpath expr="//td[@name='td_commission']" position="attributes">
11
+ <attribute name="t-if">o.settlement_type != 'sale_invoice'</attribute>
12
+ </xpath>
13
+ <xpath expr="//th[@name='th_date']" position="after">
14
+ <t t-if="o.settlement_type == 'sale_invoice'">
15
+ <th class="text-start">Invoice</th>
16
+ <th class="text-start">Partner</th>
17
+ <th class="text-start">Subtotal</th>
18
+ </t>
19
+ </xpath>
20
+ <xpath expr="//td[@name='td_date']" position="after">
21
+ <t t-if="o.settlement_type == 'sale_invoice'">
22
+ <td><span t-out="l.get('invoice')" /></td>
23
+ <td><span t-out="l.get('partner')" /></td>
24
+ <td><span t-out="round(l.get('base_commission', 0.0), 2)" /></td>
25
+ </t>
26
+ </xpath>
27
+ <xpath expr="//tr[td[@name='td_total']]" position="after">
28
+ <tr t-if="o.settlement_type == 'sale_invoice'">
29
+ <td />
30
+ <td />
31
+ <td />
32
+ <td class="text-end"><strong>Total</strong></td>
33
+ <td class="text-end">
34
+ <span
35
+ t-field="o.total"
36
+ t-options="{'widget': 'monetary', 'display_currency': o.currency_id}"
37
+ />
38
+ </td>
39
+ </tr>
40
+ </xpath>
41
+ <xpath expr="//tr[td[@name='td_total']]" position="attributes">
42
+ <attribute name="t-if">o.settlement_type != 'sale_invoice'</attribute>
43
+ </xpath>
44
+ </template>
45
+ </odoo>
@@ -12,30 +12,24 @@
12
12
  </xpath>
13
13
  <xpath expr="//th" position="after">
14
14
  <t t-if="o.settlement_type == 'sale_invoice'">
15
- <th class="text-start">Invoice</th>
16
- <th class="text-start">Customer</th>
17
- <th class="text-start">Description</th>
15
+ <th class="text-start">Invoice line</th>
18
16
  <th class="text-start">Quantity</th>
19
- <th class="text-start">Amount</th>
20
17
  </t>
21
18
  </xpath>
22
19
  <xpath expr="//table/tbody/tr/td" position="after">
23
20
  <t t-if="o.settlement_type == 'sale_invoice'">
24
21
  <td>
25
- <span t-field="l.invoice_line_id.move_id.name" />
26
- </td>
27
- <td>
28
- <span t-field="l.invoice_line_id.move_id.partner_id" />
29
- </td>
30
- <td>
31
- <span t-field="l.invoice_line_id.name" />
22
+ <span t-field="l.invoice_line_id" />
32
23
  </td>
33
24
  <td>
34
25
  <span t-field="l.invoice_line_id.quantity" />
35
26
  </td>
36
- <td>
37
- <span t-field="l.invoice_line_id.price_subtotal" />
38
- </td>
27
+ </t>
28
+ </xpath>
29
+ <xpath expr="//table/tfoot/tr/td" position="before">
30
+ <t t-if="o.settlement_type == 'sale_invoice'">
31
+ <td />
32
+ <td />
39
33
  </t>
40
34
  </xpath>
41
35
  </template>
@@ -11,10 +11,7 @@
11
11
  <field name="product_id" />
12
12
  <field name="date" />
13
13
  </group>
14
- <group
15
- string="Settlements"
16
- attrs="{'invisible': [('from_settlement', '=', True)]}"
17
- >
14
+ <group string="Settlements" invisible="from_settlement">
18
15
  <p
19
16
  colspan="4"
20
17
  >(keep empty for invoicing all the pending settlements)</p>