diff --git a/sale_commission_delivery_partner/README.rst b/sale_commission_delivery_partner/README.rst new file mode 100644 index 000000000..294db6306 --- /dev/null +++ b/sale_commission_delivery_partner/README.rst @@ -0,0 +1,100 @@ +=========================== +Commission Delivery Partner +=========================== + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:64fbc27f93c0a21e84b27ee30b1a1ce3713b17b3a816c677eacf1f86f8b2fb98 + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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_delivery_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_delivery_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 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module solves inconsistency problems between SO and invoices +regarding the selected agent commissioners. + +Installing this module will make sure to use the Delivery Address' agents instead + +**Table of contents** + +.. contents:: + :local: + +Changelog +========= + +14.0.1.0.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Initial release + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Ooops +* PyTech SRL + +Contributors +~~~~~~~~~~~~ + +* `PyTech SRL `_: + * Sebastiano Picchi + +* `Ooops404 `_: + * Eduard Brahas + +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +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-PicchiSeba| image:: https://github.com/PicchiSeba.png?size=40px + :target: https://github.com/PicchiSeba + :alt: PicchiSeba + +Current `maintainer `__: + +|maintainer-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. diff --git a/sale_commission_delivery_partner/__init__.py b/sale_commission_delivery_partner/__init__.py new file mode 100644 index 000000000..0650744f6 --- /dev/null +++ b/sale_commission_delivery_partner/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_commission_delivery_partner/__manifest__.py b/sale_commission_delivery_partner/__manifest__.py new file mode 100644 index 000000000..3029265b4 --- /dev/null +++ b/sale_commission_delivery_partner/__manifest__.py @@ -0,0 +1,20 @@ +{ + "name": "Commission Delivery Partner", + "summary": "Advanced commissions rules", + "version": "14.0.1.0.0", + "author": "Ooops, " "PyTech SRL," "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/commission", + "category": "Sales Management", + "license": "AGPL-3", + "depends": [ + "sale_commission_geo_assign", + "sale_commission_product_criteria_domain", + ], + "data": [ + "views/res_partner_view.xml", + ], + "demo": [], + "maintainers": ["PicchiSeba"], + "application": False, + "installable": True, +} diff --git a/sale_commission_delivery_partner/i18n/it.po b/sale_commission_delivery_partner/i18n/it.po new file mode 100644 index 000000000..00ccf0610 --- /dev/null +++ b/sale_commission_delivery_partner/i18n/it.po @@ -0,0 +1,70 @@ +# Francesco @ Ooops , 2024. +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-05-14 21:41+0200\n" +"PO-Revision-Date: 2024-05-14 19:41+0000\n" +"Last-Translator: Francesco @ Ooops \n" +"Language-Team: Italian \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.4-dev\n" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_partner__parent_agent_ids +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_users__parent_agent_ids +msgid "Agents" +msgstr "Agenti" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_partner__parent_commission_item_agent_ids +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_users__parent_commission_item_agent_ids +msgid "Commission Items Groups" +msgstr "Gruppi di righe provvigioni" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model,name:ooops_sale_commission_delivery_partner.model_res_partner +msgid "Contact" +msgstr "Contatto" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_account_move_line__display_name +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_partner__display_name +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_sale_order_line__display_name +msgid "Display Name" +msgstr "Nome visualizzato" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_partner__parent_no_geo_assign_update +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_users__parent_no_geo_assign_update +msgid "Do not allow update with Geo Assign" +msgstr "Non permettere aggiornamento con geo-assegnazione" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_account_move_line__id +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_partner__id +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_sale_order_line__id +msgid "ID" +msgstr "ID" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model,name:ooops_sale_commission_delivery_partner.model_account_move_line +msgid "Journal Item" +msgstr "Movimento contabile" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_account_move_line____last_update +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_res_partner____last_update +#: model:ir.model.fields,field_description:ooops_sale_commission_delivery_partner.field_sale_order_line____last_update +msgid "Last Modified on" +msgstr "Ultima modifica il" + +#. module: ooops_sale_commission_delivery_partner +#: model:ir.model,name:ooops_sale_commission_delivery_partner.model_sale_order_line +msgid "Sales Order Line" +msgstr "Riga ordine di vendita" diff --git a/sale_commission_delivery_partner/models/__init__.py b/sale_commission_delivery_partner/models/__init__.py new file mode 100644 index 000000000..a5190e62d --- /dev/null +++ b/sale_commission_delivery_partner/models/__init__.py @@ -0,0 +1,3 @@ +from . import account_move_line +from . import res_partner +from . import sale_order_line diff --git a/sale_commission_delivery_partner/models/account_move_line.py b/sale_commission_delivery_partner/models/account_move_line.py new file mode 100644 index 000000000..1495ae743 --- /dev/null +++ b/sale_commission_delivery_partner/models/account_move_line.py @@ -0,0 +1,14 @@ +from odoo import api, models + + +class AccountMoveLine(models.Model): + _inherit = "account.move.line" + + @api.depends("move_id", "move_id.partner_shipping_id") + def _compute_agent_ids(self): + self.agent_ids = False + for record in self.filtered(lambda x: x.move_id.partner_shipping_id): + if not record.commission_free: + record.agent_ids = record._prepare_agents_vals_partner( + record.move_id.partner_shipping_id + ) diff --git a/sale_commission_delivery_partner/models/res_partner.py b/sale_commission_delivery_partner/models/res_partner.py new file mode 100644 index 000000000..78099bd1f --- /dev/null +++ b/sale_commission_delivery_partner/models/res_partner.py @@ -0,0 +1,17 @@ +from odoo import fields, models + + +class ResPartner(models.Model): + _inherit = "res.partner" + + parent_agent_ids = fields.Many2many( + "res.partner", + related="parent_id.agent_ids", + ) + parent_commission_item_agent_ids = fields.One2many( + "commission.item.agent", + related="parent_id.commission_item_agent_ids", + ) + parent_no_geo_assign_update = fields.Boolean( + related="parent_id.no_geo_assign_update" + ) diff --git a/sale_commission_delivery_partner/models/sale_order_line.py b/sale_commission_delivery_partner/models/sale_order_line.py new file mode 100644 index 000000000..c2940f4fb --- /dev/null +++ b/sale_commission_delivery_partner/models/sale_order_line.py @@ -0,0 +1,14 @@ +from odoo import api, models + + +class SaleOrderLine(models.Model): + _inherit = "sale.order.line" + + @api.depends("order_id", "order_id.partner_shipping_id") + def _compute_agent_ids(self): + self.agent_ids = False + for record in self.filtered(lambda x: x.order_id.partner_shipping_id): + if not record.commission_free: + record.agent_ids = record._prepare_agents_vals_partner( + record.order_id.partner_shipping_id + ) diff --git a/sale_commission_delivery_partner/readme/CONTRIBUTORS.rst b/sale_commission_delivery_partner/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..bcd1459e2 --- /dev/null +++ b/sale_commission_delivery_partner/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* `PyTech SRL `_: + * Sebastiano Picchi + +* `Ooops404 `_: + * Eduard Brahas diff --git a/sale_commission_delivery_partner/readme/DESCRIPTION.rst b/sale_commission_delivery_partner/readme/DESCRIPTION.rst new file mode 100644 index 000000000..df078c18a --- /dev/null +++ b/sale_commission_delivery_partner/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +This module solves inconsistency problems between SO and invoices +regarding the selected agent commissioners. + +Installing this module will make sure to use the Delivery Address' agents instead diff --git a/sale_commission_delivery_partner/readme/HISTORY.rst b/sale_commission_delivery_partner/readme/HISTORY.rst new file mode 100644 index 000000000..f838e0c68 --- /dev/null +++ b/sale_commission_delivery_partner/readme/HISTORY.rst @@ -0,0 +1,4 @@ +14.0.1.0.0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +* Initial release diff --git a/sale_commission_delivery_partner/static/description/icon.png b/sale_commission_delivery_partner/static/description/icon.png new file mode 100644 index 000000000..3a0328b51 Binary files /dev/null and b/sale_commission_delivery_partner/static/description/icon.png differ diff --git a/sale_commission_delivery_partner/static/description/index.html b/sale_commission_delivery_partner/static/description/index.html new file mode 100644 index 000000000..7893959b6 --- /dev/null +++ b/sale_commission_delivery_partner/static/description/index.html @@ -0,0 +1,444 @@ + + + + + +Commission Delivery Partner + + + +
+

Commission Delivery Partner

+ + +

Beta License: AGPL-3 OCA/commission Translate me on Weblate Try me on Runboat

+

This module solves inconsistency problems between SO and invoices +regarding the selected agent commissioners.

+

Installing this module will make sure to use the Delivery Address’ agents instead

+

Table of contents

+ +
+

Changelog

+
+

14.0.1.0.0

+
    +
  • Initial release
  • +
+
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Ooops
  • +
  • PyTech SRL
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +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:

+

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.

+
+
+
+ + diff --git a/sale_commission_delivery_partner/tests/__init__.py b/sale_commission_delivery_partner/tests/__init__.py new file mode 100644 index 000000000..f95df182c --- /dev/null +++ b/sale_commission_delivery_partner/tests/__init__.py @@ -0,0 +1 @@ +from . import test_sale_commission_delivery_partner diff --git a/sale_commission_delivery_partner/tests/test_sale_commission_delivery_partner.py b/sale_commission_delivery_partner/tests/test_sale_commission_delivery_partner.py new file mode 100644 index 000000000..650e34769 --- /dev/null +++ b/sale_commission_delivery_partner/tests/test_sale_commission_delivery_partner.py @@ -0,0 +1,84 @@ +from odoo.tests.common import TransactionCase + + +class TestSaleCommissionDeliveryPartner(TransactionCase): + def setUp(self): + super(TestSaleCommissionDeliveryPartner, self).setUp() + + self.user = self.env["res.users"].create( + { + "name": "Test User", + "login": "test_user", + "email": "test_user@example.com", + "groups_id": [ + ( + 6, + 0, + [ + self.env.ref("base.group_user").id, + self.env.ref("sale.group_delivery_invoice_address").id, + self.env.ref("sales_team.group_sale_manager").id, + ], + ) + ], + } + ) + + self.partner = self.env["res.partner"].create( + { + "name": "Test Partner", + "email": "test@partner.com", + } + ) + self.product = self.env["product.product"].create( + { + "name": "Test Product", + "list_price": 100.0, + "standard_price": 50.0, + "invoice_policy": "order", + "type": "product", + } + ) + + def test_create_sale_order(self): + sale_order = ( + self.env["sale.order"] + .with_user(self.user.id) + .create( + { + "partner_id": self.partner.id, + "order_line": [ + ( + 0, + 0, + { + "product_id": self.product.id, + "product_uom_qty": 5, + "price_unit": self.product.list_price, + }, + ) + ], + } + ) + ) + + sale_order.action_confirm() + self.assertEqual(sale_order.state, "sale") + + context = {"active_model": "sale.order", "active_ids": sale_order.ids} + invoice_wizard = ( + self.env["sale.advance.payment.inv"] + .with_context(context) + .create( + { + "advance_payment_method": "delivered", + } + ) + ) + invoice_wizard.create_invoices() + + invoice = self.env["account.move"].search( + [("invoice_origin", "=", sale_order.name)], limit=1 + ) + + self.assertEqual(sale_order.partner_shipping_id, invoice.partner_shipping_id) diff --git a/sale_commission_delivery_partner/views/res_partner_view.xml b/sale_commission_delivery_partner/views/res_partner_view.xml new file mode 100644 index 000000000..20a66a043 --- /dev/null +++ b/sale_commission_delivery_partner/views/res_partner_view.xml @@ -0,0 +1,38 @@ + + + + res.partner.form + res.partner + + + + + + + + + + + + + + + + + + + diff --git a/setup/sale_commission_delivery_partner/odoo/addons/sale_commission_delivery_partner b/setup/sale_commission_delivery_partner/odoo/addons/sale_commission_delivery_partner new file mode 120000 index 000000000..f501c07aa --- /dev/null +++ b/setup/sale_commission_delivery_partner/odoo/addons/sale_commission_delivery_partner @@ -0,0 +1 @@ +../../../../sale_commission_delivery_partner \ No newline at end of file diff --git a/setup/sale_commission_delivery_partner/setup.py b/setup/sale_commission_delivery_partner/setup.py new file mode 100644 index 000000000..28c57bb64 --- /dev/null +++ b/setup/sale_commission_delivery_partner/setup.py @@ -0,0 +1,6 @@ +import setuptools + +setuptools.setup( + setup_requires=['setuptools-odoo'], + odoo_addon=True, +)