From 69c9058d4b2a4be8ce1960926b03843e85bcaedd Mon Sep 17 00:00:00 2001 From: PicchiSeba Date: Tue, 15 Oct 2024 15:08:44 +0200 Subject: [PATCH 1/2] [FIX]sale_commission_product_criteria: ignore error on create --- .../models/commission.py | 2 ++ .../test_sale_commission_product_criteria.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sale_commission_product_criteria/models/commission.py b/sale_commission_product_criteria/models/commission.py index b43e87979..4cd64481e 100644 --- a/sale_commission_product_criteria/models/commission.py +++ b/sale_commission_product_criteria/models/commission.py @@ -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)] ) diff --git a/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py b/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py index 128e6118e..00462846c 100644 --- a/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py +++ b/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py @@ -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): @@ -198,3 +198,19 @@ def _invoice_sale_order(self, sale_order, date=None): invoice = sale_order.invoice_ids - old_invoices invoice.flush() return invoice + + 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") + + so.action_confirm() + with self.assertRaises(ValidationError): + self.rules_commission_id.commission_type = "fixed" + self.rules_commission_id.onchange_commission_type() From 393caf6022b59a6bf56df94a481cbad577059519 Mon Sep 17 00:00:00 2001 From: PicchiSeba Date: Tue, 15 Oct 2024 17:06:59 +0200 Subject: [PATCH 2/2] [IMP]sale_commission_product_criteria: reorder test functions, add maintainers --- .../test_sale_commission_product_criteria.py | 68 +++++++++---------- .../README.rst | 13 +++- .../__manifest__.py | 7 +- .../static/description/index.html | 16 +++-- 4 files changed, 60 insertions(+), 44 deletions(-) diff --git a/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py b/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py index 00462846c..aeb63b09e 100644 --- a/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py +++ b/sale_commission_product_criteria/tests/test_sale_commission_product_criteria.py @@ -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() @@ -165,40 +199,6 @@ 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 _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_on_create_check(self): f = Form(self.commission_model) f.name = "New commission type" diff --git a/sale_commission_product_criteria_discount/README.rst b/sale_commission_product_criteria_discount/README.rst index 6cfb49240..894a60984 100644 --- a/sale_commission_product_criteria_discount/README.rst +++ b/sale_commission_product_criteria_discount/README.rst @@ -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 `__: +Current `maintainers `__: -|maintainer-ilyasProgrammer| +|maintainer-aleuffre| |maintainer-ilyasProgrammer| |maintainer-renda-dev| |maintainer-PicchiSeba| This module is part of the `OCA/commission `_ project on GitHub. diff --git a/sale_commission_product_criteria_discount/__manifest__.py b/sale_commission_product_criteria_discount/__manifest__.py index 4d14b6d62..e31e6c8b0 100644 --- a/sale_commission_product_criteria_discount/__manifest__.py +++ b/sale_commission_product_criteria_discount/__manifest__.py @@ -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", diff --git a/sale_commission_product_criteria_discount/static/description/index.html b/sale_commission_product_criteria_discount/static/description/index.html index 6c49eaccb..4490cfe0b 100644 --- a/sale_commission_product_criteria_discount/static/description/index.html +++ b/sale_commission_product_criteria_discount/static/description/index.html @@ -1,4 +1,3 @@ - @@ -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. @@ -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 } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -422,12 +422,14 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

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.

-

Current maintainer:

-

ilyasProgrammer

+

Current maintainers:

+

aleuffre ilyasProgrammer renda-dev PicchiSeba

This module is part of the OCA/commission project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.