Skip to content

Commit

Permalink
Merge PR #568 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by ilyasProgrammer
  • Loading branch information
OCA-git-bot committed Oct 16, 2024
2 parents ee3e0e9 + 393caf6 commit eb61871
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 42 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 @@ -45,6 +45,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 @@ -3,7 +3,7 @@


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


class TestSaleCommission(SavepointCase):
Expand Down Expand Up @@ -51,6 +51,40 @@ 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.create({"advance_payment_method": "delivered"})
wizard.with_context(
{
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
}
).create_invoices()
invoice = sale_order.invoice_ids - old_invoices
invoice.flush()
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 @@ -165,36 +199,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()

so = self._create_sale_order(self.product_4, self.partner)
self.assertEqual(
so.order_line.agent_ids.commission_id, self.rules_commission_id
)
self.assertEqual(self.rules_commission_id.commission_type, "product")

def _invoice_sale_order(self, sale_order, date=None):
old_invoices = sale_order.invoice_ids
wizard = self.advance_inv_model.create({"advance_payment_method": "delivered"})
wizard.with_context(
{
"active_model": "sale.order",
"active_ids": [sale_order.id],
"active_id": sale_order.id,
}
).create_invoices()
invoice = sale_order.invoice_ids - old_invoices
invoice.flush()
return invoice
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 @@ -89,13 +89,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/14.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 @@ -6,7 +6,12 @@
"version": "14.0.1.0.2",
"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 ([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 @@ -422,12 +422,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/14.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 eb61871

Please sign in to comment.