From c051217def5a6fda9c7bf7ebf0fd4425577dffee 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 18a970f45..cb46a41c7 100644 --- a/sale_commission_product_criteria/models/commission.py +++ b/sale_commission_product_criteria/models/commission.py @@ -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)] ) 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 cf9bda14f..780f883b2 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 @@ -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): @@ -202,3 +202,19 @@ def _invoice_sale_order(self, sale_order, date=None): wizard.create_invoices() invoice = sale_order.invoice_ids - old_invoices 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 d647a51561ea265a0810d593b5641b05f3cc145f 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 | 74 +++++++++---------- .../README.rst | 13 +++- .../__manifest__.py | 7 +- .../static/description/index.html | 16 ++-- 4 files changed, 63 insertions(+), 47 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 780f883b2..b016128be 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 @@ -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() @@ -166,43 +203,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.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_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 aeb57088d..783399436 100644 --- a/sale_commission_product_criteria_discount/README.rst +++ b/sale_commission_product_criteria_discount/README.rst @@ -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 `__: +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 64e14d763..fba330b88 100644 --- a/sale_commission_product_criteria_discount/__manifest__.py +++ b/sale_commission_product_criteria_discount/__manifest__.py @@ -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", diff --git a/sale_commission_product_criteria_discount/static/description/index.html b/sale_commission_product_criteria_discount/static/description/index.html index 048da40ef..34ec7b1f2 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 { @@ -426,12 +426,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.