Skip to content

Commit

Permalink
Merge PR #571 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by ilyasProgrammer
  • Loading branch information
OCA-git-bot committed Nov 5, 2024
2 parents c57398b + d647a51 commit 090359c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 45 deletions.
2 changes: 2 additions & 0 deletions sale_commission_product_criteria/models/commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def check_type_change_allowed_sale(self):
)

def check_type_change_allowed_moves(self):
if not self._origin:
return
aila_ids = self.env["account.invoice.line.agent"].search(
[("commission_id", "=", self._origin.id)]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


from odoo.exceptions import ValidationError
from odoo.tests.common import TransactionCase
from odoo.tests.common import Form, TransactionCase


class TestSaleCommission(TransactionCase):
Expand Down Expand Up @@ -52,6 +52,43 @@ def setUpClass(cls):
"sale_commission_product_criteria.demo_commission_rules_item_4"
)

def _create_sale_order(self, product, partner):
return self.sale_order_model.create(
{
"partner_id": partner.id,
"order_line": [
(
0,
0,
{
"name": product.name,
"product_id": product.id,
"product_uom_qty": 1.0,
"product_uom": product.uom_id.id,
"price_unit": 1000,
},
)
],
}
)

def _invoice_sale_order(self, sale_order, date=None):
old_invoices = sale_order.invoice_ids
wizard = self.advance_inv_model.with_context(
**{
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
}
).create(
{
"advance_payment_method": "delivered",
}
)
wizard.create_invoices()
invoice = sale_order.invoice_ids - old_invoices
return invoice

def test_sale_commission_product_criteria_items(self):
# items names
self.com_item_1._compute_commission_item_name_value()
Expand Down Expand Up @@ -166,39 +203,18 @@ def test_sale_commission_product_criteria_items(self):
with self.assertRaises(ValidationError):
self.com_item_4._onchange_product_tmpl_id()

def _create_sale_order(self, product, partner):
return self.sale_order_model.create(
{
"partner_id": partner.id,
"order_line": [
(
0,
0,
{
"name": product.name,
"product_id": product.id,
"product_uom_qty": 1.0,
"product_uom": product.uom_id.id,
"price_unit": 1000,
},
)
],
}
)
def test_on_create_check(self):
f = Form(self.commission_model)
f.name = "New commission type"
f.save()

def _invoice_sale_order(self, sale_order, date=None):
old_invoices = sale_order.invoice_ids
wizard = self.advance_inv_model.with_context(
**{
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
}
).create(
{
"advance_payment_method": "delivered",
}
so = self._create_sale_order(self.product_4, self.partner)
self.assertEqual(
so.order_line.agent_ids.commission_id, self.rules_commission_id
)
wizard.create_invoices()
invoice = sale_order.invoice_ids - old_invoices
return invoice
self.assertEqual(self.rules_commission_id.commission_type, "product")

so.action_confirm()
with self.assertRaises(ValidationError):
self.rules_commission_id.commission_type = "fixed"
self.rules_commission_id.onchange_commission_type()
13 changes: 11 additions & 2 deletions sale_commission_product_criteria_discount/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,22 @@ 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.

.. |maintainer-aleuffre| image:: https://github.com/aleuffre.png?size=40px
:target: https://github.com/aleuffre
:alt: aleuffre
.. |maintainer-ilyasProgrammer| image:: https://github.com/ilyasProgrammer.png?size=40px
:target: https://github.com/ilyasProgrammer
:alt: ilyasProgrammer
.. |maintainer-renda-dev| image:: https://github.com/renda-dev.png?size=40px
:target: https://github.com/renda-dev
:alt: renda-dev
.. |maintainer-PicchiSeba| image:: https://github.com/PicchiSeba.png?size=40px
:target: https://github.com/PicchiSeba
:alt: PicchiSeba

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:
Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-ilyasProgrammer|
|maintainer-aleuffre| |maintainer-ilyasProgrammer| |maintainer-renda-dev| |maintainer-PicchiSeba|

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

Expand Down
7 changes: 6 additions & 1 deletion sale_commission_product_criteria_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
"version": "16.0.1.0.0",
"author": "Ilyas," "Ooops404," "Odoo Community Association (OCA)",
"contributors": ["Ilyas"],
"maintainers": ["ilyasProgrammer"],
"maintainers": [
"aleuffre",
"ilyasProgrammer",
"renda-dev",
"PicchiSeba",
],
"website": "https://github.com/OCA/commission",
"category": "Sales Management",
"license": "AGPL-3",
Expand Down
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 (goodger@python.org)
: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 @@ -426,12 +426,14 @@ <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>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/ilyasProgrammer"><img alt="ilyasProgrammer" src="https://github.com/ilyasProgrammer.png?size=40px" /></a></p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/aleuffre"><img alt="aleuffre" src="https://github.com/aleuffre.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/ilyasProgrammer"><img alt="ilyasProgrammer" src="https://github.com/ilyasProgrammer.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/renda-dev"><img alt="renda-dev" src="https://github.com/renda-dev.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/PicchiSeba"><img alt="PicchiSeba" src="https://github.com/PicchiSeba.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/commission/tree/16.0/sale_commission_product_criteria_discount">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>
Expand Down

0 comments on commit 090359c

Please sign in to comment.