Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing from upstream OCA/commission (16.0) #428

Merged
merged 5 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Available addons
----------------
addon | version | maintainers | summary
--- | --- | --- | ---
[account_commission](account_commission/) | 16.0.2.3.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Account commissions
[commission](commission/) | 16.0.2.2.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Commissions
[account_commission](account_commission/) | 16.0.2.4.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Account commissions
[commission](commission/) | 16.0.2.3.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Commissions
[commission_formula](commission_formula/) | 16.0.1.0.0 | | Commissions computed by formulas
[hr_commission](hr_commission/) | 16.0.1.0.0 | | HR commissions
[sale_commission](sale_commission/) | 16.0.1.0.2 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Sales commissions
Expand Down
3 changes: 2 additions & 1 deletion account_commission/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Account commissions
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:160d10472aa0794ac787e52c597d274c4b78c88b593ac1e9b2d78bab3df2fcc3
!! source digest: sha256:8ba2b2321dee20dece1882cb3f664fb78a27b4fbccb785d1f5410b7d009889c6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -128,6 +128,7 @@ Contributors

* Pedro M. Baeza
* Manuel Calero
* Sergio Teruel

* `Quartile <https://www.quartile.co>`__:

Expand Down
2 changes: 1 addition & 1 deletion account_commission/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
{
"name": "Account commissions",
"version": "16.0.2.3.0",
"version": "16.0.2.4.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"category": "Sales Management",
"license": "AGPL-3",
Expand Down
1 change: 1 addition & 0 deletions account_commission/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

* Pedro M. Baeza
* Manuel Calero
* Sergio Teruel

* `Quartile <https://www.quartile.co>`__:

Expand Down
3 changes: 2 additions & 1 deletion account_commission/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h1 class="title">Account commissions</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:160d10472aa0794ac787e52c597d274c4b78c88b593ac1e9b2d78bab3df2fcc3
!! source digest: sha256:8ba2b2321dee20dece1882cb3f664fb78a27b4fbccb785d1f5410b7d009889c6
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/commission/tree/16.0/account_commission"><img alt="OCA/commission" src="https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/commission-16-0/commission-16-0-account_commission"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/commission&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds the function to calculate commissions in invoices (account moves).</p>
Expand Down Expand Up @@ -473,6 +473,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza</li>
<li>Manuel Calero</li>
<li>Sergio Teruel</li>
</ul>
</li>
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
Expand Down
35 changes: 35 additions & 0 deletions account_commission/tests/test_account_commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,38 @@ def test_invoice_modify_refund(self):
)
self.assertEqual(3, len(settlements.line_ids))
self.assertAlmostEqual(0.6, sum(settlements.mapped("total")), 2)

def _register_payment(self, invoice):
payment_journal = self.env["account.journal"].search(
[("type", "=", "cash"), ("company_id", "=", self.env.company.id)],
limit=1,
)
register_payments = (
self.env["account.payment.register"]
.with_context(active_ids=invoice.id, active_model="account.move")
.create({"journal_id": payment_journal.id})
)
register_payments.action_create_payments()

def test_invoice_pending_settlement(self):
"""Make in one settlement all pending invoices to wizard date"""
fields.Date.today()
self.commission_net_paid.invoice_state = "paid"
invoice1 = self._create_invoice(
self.agent_pending, self.commission_net_paid, "2024-02-15", currency=None
)
# Register payment for the new invoice
invoice2 = self._create_invoice(
self.agent_pending, self.commission_net_paid, "2024-03-15", currency=None
)
invoice3 = self._create_invoice(
self.agent_pending, self.commission_net_paid, "2024-04-15", currency=None
)
# invoice1.invoice_line_ids.agent_ids._compute_amount()
(invoice1 + invoice2 + invoice3).action_post()
self._register_payment(invoice1)
self._register_payment(invoice2)
self._register_payment(invoice3)
self._settle_agent_invoice(self.agent_pending, 1)
settlements = self.settle_model.search([("state", "=", "settled")])
self.assertEqual(len(settlements.line_ids), 3)
3 changes: 2 additions & 1 deletion commission/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Commissions
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:17896cfe6391af1ccfe257a51bea56af1f6273adadc5869b5ba65fe1f6786fa9
!! source digest: sha256:a6a9729b4ac92891ac83e654ab6bfb486274befeb545606bf89298465a437432
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -151,6 +151,7 @@ Contributors

* Pedro M. Baeza
* Manuel Calero
* Sergio Teruel

* `Quartile <https://www.quartile.co>`__:

Expand Down
2 changes: 1 addition & 1 deletion commission/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright 2014-2022 Tecnativa - Pedro M. Baeza
{
"name": "Commissions",
"version": "16.0.2.2.0",
"version": "16.0.2.3.0",
"author": "Tecnativa, Odoo Community Association (OCA)",
"category": "Invoicing",
"license": "AGPL-3",
Expand Down
5 changes: 5 additions & 0 deletions commission/i18n/commission.pot
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,11 @@ msgstr ""
msgid "Parent"
msgstr ""

#. module: commission
#: model:ir.model.fields.selection,name:commission.selection__res_partner__settlement__pending
msgid "Pending commissions"
msgstr ""

#. module: commission
#: model:ir.model.fields,field_description:commission.field_commission_section__percent
msgid "Percent"
Expand Down
5 changes: 5 additions & 0 deletions commission/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,11 @@ msgstr "Número de mensajes con error de entrega"
msgid "Parent"
msgstr "Parental"

#. module: commission
#: model:ir.model.fields.selection,name:commission.selection__res_partner__settlement__pending
msgid "Pending commissions"
msgstr ""

#. module: commission
#: model:ir.model.fields,field_description:commission.field_commission_section__percent
msgid "Percent"
Expand Down
5 changes: 5 additions & 0 deletions commission/i18n/it.po
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ msgstr "Numero di messaggi con errore di consegna"
msgid "Parent"
msgstr "Padre"

#. module: commission
#: model:ir.model.fields.selection,name:commission.selection__res_partner__settlement__pending
msgid "Pending commissions"
msgstr ""

#. module: commission
#: model:ir.model.fields,field_description:commission.field_commission_section__percent
msgid "Percent"
Expand Down
5 changes: 5 additions & 0 deletions commission/i18n/ja.po
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ msgstr ""
msgid "Parent"
msgstr "親"

#. module: commission
#: model:ir.model.fields.selection,name:commission.selection__res_partner__settlement__pending
msgid "Pending commissions"
msgstr ""

#. module: commission
#: model:ir.model.fields,field_description:commission.field_commission_section__percent
msgid "Percent"
Expand Down
5 changes: 5 additions & 0 deletions commission/i18n/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,11 @@ msgstr "Número de mensagens com erro de entrega"
msgid "Parent"
msgstr "Ascendente"

#. module: commission
#: model:ir.model.fields.selection,name:commission.selection__res_partner__settlement__pending
msgid "Pending commissions"
msgstr ""

#. module: commission
#: model:ir.model.fields,field_description:commission.field_commission_section__percent
msgid "Percent"
Expand Down
5 changes: 5 additions & 0 deletions commission/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,11 @@ msgstr "Número de mensagens com erro de entrega"
msgid "Parent"
msgstr "Superior"

#. module: commission
#: model:ir.model.fields.selection,name:commission.selection__res_partner__settlement__pending
msgid "Pending commissions"
msgstr ""

#. module: commission
#: model:ir.model.fields,field_description:commission.field_commission_section__percent
msgid "Percent"
Expand Down
1 change: 1 addition & 0 deletions commission/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ResPartner(models.Model):
("quaterly", "Quarterly"),
("semi", "Semi-annual"),
("annual", "Annual"),
("pending", "Pending commissions"),
],
string="Settlement period",
default="monthly",
Expand Down
1 change: 1 addition & 0 deletions commission/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

* Pedro M. Baeza
* Manuel Calero
* Sergio Teruel

* `Quartile <https://www.quartile.co>`__:

Expand Down
3 changes: 2 additions & 1 deletion commission/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ <h1 class="title">Commissions</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:17896cfe6391af1ccfe257a51bea56af1f6273adadc5869b5ba65fe1f6786fa9
!! source digest: sha256:a6a9729b4ac92891ac83e654ab6bfb486274befeb545606bf89298465a437432
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/commission/tree/16.0/commission"><img alt="OCA/commission" src="https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/commission-16-0/commission-16-0-commission"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/commission&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module provides the base functions for commission operations to enable the
Expand Down Expand Up @@ -503,6 +503,7 @@ <h2><a class="toc-backref" href="#toc-entry-7">Contributors</a></h2>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza</li>
<li>Manuel Calero</li>
<li>Sergio Teruel</li>
</ul>
</li>
<li><a class="reference external" href="https://www.quartile.co">Quartile</a>:<ul>
Expand Down
8 changes: 8 additions & 0 deletions commission/tests/test_commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def setUpClass(cls):
"lang": "en_US",
}
)
cls.agent_pending = cls.res_partner_model.create(
{
"name": "Test Agent - Pending",
"agent": True,
"settlement": "pending",
"lang": "en_US",
}
)

# Expected to be used in inheriting modules.
def _get_make_settle_vals(self, agent=None, period=None, date=None):
Expand Down
8 changes: 7 additions & 1 deletion commission/wizards/commission_make_settle.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def _get_period_start(self, agent, date_to):
return date(month=1, year=date_to.year, day=1)
elif agent.settlement == "annual":
return date(month=1, year=date_to.year, day=1)
elif agent.settlement == "pending":
return date(month=date_to.month, year=date_to.year, day=date_to.day)

def _get_next_period_date(self, agent, current_date):
if agent.settlement == "monthly":
Expand All @@ -66,6 +68,10 @@ def _get_next_period_date(self, agent, current_date):
return current_date + relativedelta(months=6)
elif agent.settlement == "annual":
return current_date + relativedelta(years=1)
elif agent.settlement == "pending":
return date(
month=self.date_to.month, year=self.date_to.year, day=self.date_to.day
)

def _get_settlement(self, agent, company, currency, sett_from, sett_to):
self.ensure_one()
Expand Down Expand Up @@ -97,7 +103,7 @@ def _prepare_settlement_line_vals(self, settlement, line):
"settlement_id": settlement.id,
}

def _get_agent_lines(self, date_to_agent):
def _get_agent_lines(self, agent, date_to_agent):
"""Need to be extended according to settlement_type."""
raise NotImplementedError()

Expand Down
Loading