Skip to content

Commit

Permalink
[MIG] commission_delegated_partner: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
etobella committed Jan 21, 2025
1 parent eab6c11 commit 3e55fd8
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 80 deletions.
10 changes: 5 additions & 5 deletions commission_delegated_partner/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Sale Commission Delegate Partner
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fcommission-lightgray.png?logo=github
:target: https://github.com/OCA/commission/tree/14.0/sale_commission_delegated_partner
:target: https://github.com/OCA/commission/tree/16.0/commission_delegated_partner
:alt: OCA/commission
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/commission-14-0/commission-14-0-sale_commission_delegated_partner
:target: https://translation.odoo-community.org/projects/commission-16-0/commission-16-0-commission_delegated_partner
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/commission&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -51,7 +51,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_delegated_partner%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20commission_delegated_partner%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -81,6 +81,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/14.0/sale_commission_delegated_partner>`_ project on GitHub.
This module is part of the `OCA/commission <https://github.com/OCA/commission/tree/16.0/commission_delegated_partner>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
4 changes: 2 additions & 2 deletions commission_delegated_partner/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"name": "Sale Commission Delegate Partner",
"summary": """
Allow to delegate the invoices of agent to a delegate partner""",
"version": "14.0.1.0.1",
"version": "16.0.1.0.1",
"license": "AGPL-3",
"author": "Creu Blanca,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/commission",
"depends": ["sale_commission"],
"depends": ["account_commission"],
"data": ["views/res_partner.xml"],
"demo": [],
}
2 changes: 1 addition & 1 deletion commission_delegated_partner/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import res_partner
from . import sale_commission_settlement
from . import commission_settlement
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from odoo import _, fields, models


class SaleCommissionSettlement(models.Model):
_inherit = "sale.commission.settlement"
class CommissionSettlement(models.Model):
_inherit = "commission.settlement"

invoice_partner_id = fields.Many2one(
"res.partner", compute="_compute_invoice_partner_id"
)
Expand All @@ -15,7 +16,7 @@ def _compute_invoice_partner_id(self):
record.invoice_partner_id = record._get_invoice_partner()

def _get_invoice_grouping_keys(self):
res = super(SaleCommissionSettlement, self)._get_invoice_grouping_keys()
res = super()._get_invoice_grouping_keys()
new_res = []
for key in res:
if key == "agent_id":
Expand All @@ -28,9 +29,9 @@ def _get_invoice_partner(self):
agent = self[0].agent_id
if agent.delegated_agent_id:
return agent.delegated_agent_id
return super(SaleCommissionSettlement, self)._get_invoice_partner()
return super()._get_invoice_partner()

def _post_process_line(self, line_form):
if self.agent_id.delegated_agent_id:
line_form.name += "\n" + _("Agent: %s") % self.agent_id.display_name
super()._post_process_line(line_form)
return super()._post_process_line(line_form)

Check warning on line 37 in commission_delegated_partner/models/commission_settlement.py

View check run for this annotation

Codecov / codecov/patch

commission_delegated_partner/models/commission_settlement.py#L36-L37

Added lines #L36 - L37 were not covered by tests
18 changes: 10 additions & 8 deletions commission_delegated_partner/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand All @@ -9,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -275,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -301,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -369,7 +369,7 @@ <h1 class="title">Sale Commission Delegate Partner</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:81932d2770674164aabdeb003eb1e6f26388ef85e95cf244a27697235e5574d1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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/14.0/sale_commission_delegated_partner"><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-14-0/commission-14-0-sale_commission_delegated_partner"><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=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<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_delegated_partner"><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_delegated_partner"><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>Allows to delegate the invoice from the agent to a related partner</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -399,7 +399,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/commission/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_delegated_partner%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/commission/issues/new?body=module:%20commission_delegated_partner%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand All @@ -419,11 +419,13 @@ <h2><a class="toc-backref" href="#toc-entry-5">Contributors</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/commission/tree/14.0/sale_commission_delegated_partner">OCA/commission</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/commission/tree/16.0/commission_delegated_partner">OCA/commission</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion commission_delegated_partner/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from . import test_sale_commission_delegate_partner
from . import test_commission_delegate_partner
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import dateutil.relativedelta

from odoo import fields
from odoo.tests.common import SavepointCase
from odoo.tests.common import TransactionCase


class TestSaleCommissionDelegatePartner(SavepointCase):
class TestSaleCommissionDelegatePartner(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.commission_model = cls.env["sale.commission"]
cls.commission_model = cls.env["commission"]
cls.commission_net_invoice = cls.commission_model.create(
{
"name": "10% fixed commission (Net amount) - Invoice Based",
Expand All @@ -20,15 +20,12 @@ def setUpClass(cls):
}
)
cls.res_partner_model = cls.env["res.partner"]
cls.partner = cls.env.ref("base.res_partner_2")
cls.partner = cls.res_partner_model.create({"name": "Test Partner"})
cls.partner.write({"agent": False})
cls.sale_order_model = cls.env["sale.order"]
cls.advance_inv_model = cls.env["sale.advance.payment.inv"]
cls.settle_model = cls.env["sale.commission.settlement"]
cls.make_settle_model = cls.env["sale.commission.make.settle"]
cls.make_inv_model = cls.env["sale.commission.make.invoice"]
cls.product = cls.env.ref("product.product_product_5")
cls.product.write({"invoice_policy": "order"})
cls.settle_model = cls.env["commission.settlement"]
cls.make_settle_model = cls.env["commission.make.settle"]
cls.make_inv_model = cls.env["commission.make.invoice"]
cls.product = cls.env["product.product"].create({"name": "Test Product"})
cls.journal = cls.env["account.journal"].search(
[("type", "=", "purchase")], limit=1
)
Expand All @@ -51,56 +48,41 @@ def setUpClass(cls):
}
)

def _create_sale_order(self, agent, commission):
sale_order = self.sale_order_model.create(
{
"partner_id": self.partner.id,
"order_line": [
(
0,
0,
{
"name": self.product.name,
"product_id": self.product.id,
"product_uom_qty": 1.0,
"product_uom": self.ref("uom.product_uom_unit"),
"price_unit": self.product.lst_price,
"agent_ids": [
(
0,
0,
{
"agent_id": agent.id,
"commission_id": commission.id,
},
)
],
},
)
],
}
)
sale_order.action_confirm()
self.assertEqual(len(sale_order.invoice_ids), 0)
payment = self.advance_inv_model.create({"advance_payment_method": "delivered"})
context = {
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
def _create_invoice(self, agent, commission, date=None, currency=None):
vals = {
"move_type": "out_invoice",
"partner_id": self.partner.id,
"invoice_line_ids": [
(
0,
0,
{
"product_id": self.product.id,
"agent_ids": [
(
0,
0,
{"agent_id": agent.id, "commission_id": commission.id},
)
],
},
)
],
}
payment.with_context(context).create_invoices()
self.assertEqual(len(sale_order.invoice_ids), 1)
for invoice in sale_order.invoice_ids:
invoice.flush()
invoice.action_post()
self.assertEqual(invoice.state, "posted")
if date:
vals.update({"invoice_date": date, "date": date})

Check warning on line 73 in commission_delegated_partner/tests/test_commission_delegate_partner.py

View check run for this annotation

Codecov / codecov/patch

commission_delegated_partner/tests/test_commission_delegate_partner.py#L73

Added line #L73 was not covered by tests
if currency:
vals.update({"currency_id": currency.id})

Check warning on line 75 in commission_delegated_partner/tests/test_commission_delegate_partner.py

View check run for this annotation

Codecov / codecov/patch

commission_delegated_partner/tests/test_commission_delegate_partner.py#L75

Added line #L75 was not covered by tests
move = self.env["account.move"].create([vals])
move.action_post()
return move

def test_settlement(self):
self._create_sale_order(
self._create_invoice(
self.agent_monthly,
self.commission_net_invoice,
)
self._create_sale_order(
self._create_invoice(
self.agent_monthly_02,
self.commission_net_invoice,
)
Expand All @@ -109,13 +91,14 @@ def test_settlement(self):
"date_to": (
fields.Datetime.from_string(fields.Datetime.now())
+ dateutil.relativedelta.relativedelta(months=1)
)
),
"settlement_type": "sale_invoice",
}
)
wizard.action_settle()
settlements = self.settle_model.search([("state", "=", "settled")])
self.assertEqual(len(settlements), 2)
self.env["sale.commission.make.invoice"].with_context(
self.env["commission.make.invoice"].with_context(
settlement_ids=settlements.ids
).create(
{
Expand Down
2 changes: 1 addition & 1 deletion commission_delegated_partner/views/res_partner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
name="name"
>res.partner.form (in sale_commission_delegate_partner)</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="sale_commission.view_partner_form_agent" />
<field name="inherit_id" ref="commission.view_partner_form_agent" />
<field name="arch" type="xml">
<field name="commission_id" position="after">
<field name="delegated_agent_id" options="{'no_create': True}" />
Expand Down
6 changes: 6 additions & 0 deletions setup/commission_delegated_partner/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 3e55fd8

Please sign in to comment.