Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing from upstream OCA/commission (14.0) #304

Merged
merged 12 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ addon | version | maintainers | summary
[sale_commission_formula](sale_commission_formula/) | 14.0.1.0.0 | | Sale commissions computed by formulas
[sale_commission_geo_assign](sale_commission_geo_assign/) | 14.0.1.0.1 | [![eLBati](https://github.com/eLBati.png?size=30px)](https://github.com/eLBati) | Assign agents to partners according to their location
[sale_commission_pricelist](sale_commission_pricelist/) | 14.0.1.0.0 | | Sales commissions by pricelist
[sale_commission_product_criteria](sale_commission_product_criteria/) | 14.0.1.1.0 | [![ilyasProgrammer](https://github.com/ilyasProgrammer.png?size=30px)](https://github.com/ilyasProgrammer) | Advanced commissions rules
[sale_commission_product_criteria_discount](sale_commission_product_criteria_discount/) | 14.0.1.0.1 | [![ilyasProgrammer](https://github.com/ilyasProgrammer.png?size=30px)](https://github.com/ilyasProgrammer) | Advanced commissions rules with discount
[sale_commission_product_criteria](sale_commission_product_criteria/) | 14.0.1.1.1 | [![ilyasProgrammer](https://github.com/ilyasProgrammer.png?size=30px)](https://github.com/ilyasProgrammer) | Advanced commissions rules
[sale_commission_product_criteria_discount](sale_commission_product_criteria_discount/) | 14.0.1.0.2 | [![ilyasProgrammer](https://github.com/ilyasProgrammer.png?size=30px)](https://github.com/ilyasProgrammer) | Advanced commissions rules with discount
[sale_commission_product_criteria_domain](sale_commission_product_criteria_domain/) | 14.0.1.0.1 | [![ilyasProgrammer](https://github.com/ilyasProgrammer.png?size=30px)](https://github.com/ilyasProgrammer) | Sale Commission Product Criteria Domain
[sale_commission_queued](sale_commission_queued/) | 14.0.1.0.0 | [![pedrobaeza](https://github.com/pedrobaeza.png?size=30px)](https://github.com/pedrobaeza) | Sales commissions queued
[sale_commission_salesman](sale_commission_salesman/) | 14.0.1.0.0 | | Sales commissions from salesman
[sale_quick_commission](sale_quick_commission/) | 14.0.1.0.0 | | Makes modules compatible
Expand Down
2 changes: 1 addition & 1 deletion sale_commission_product_criteria/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Sale Commission Product Criteria",
"summary": "Advanced commissions rules",
"version": "14.0.1.1.0",
"version": "14.0.1.1.1",
"author": "Ilyas, Ooops404, Odoo Community Association (OCA)",
"maintainers": ["ilyasProgrammer"],
"website": "https://github.com/OCA/commission",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _get_commission_items(self, commission, product):
AND (item.commission_id = %s)
AND (item.active = TRUE)
ORDER BY
item.applied_on, categ.complete_name desc
item.applied_on, item.based_on, categ.complete_name desc
""",
(
product.product_tmpl_id.ids,
Expand Down
2 changes: 1 addition & 1 deletion sale_commission_product_criteria_discount/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Sale Commission Product Criteria Discount",
"summary": "Advanced commissions rules with discount",
"version": "14.0.1.0.1",
"version": "14.0.1.0.2",
"author": "Ilyas," "Ooops404," "Odoo Community Association (OCA)",
"contributors": ["Ilyas"],
"maintainers": ["ilyasProgrammer"],
Expand Down
2 changes: 1 addition & 1 deletion sale_commission_product_criteria_discount/models/sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def _get_single_commission_amount(self, commission, subtotal, product, quantity)
self.ensure_one()
if product.commission_free or not commission:
return 0.0
if commission.commission_type != "product":
if commission.commission_type in ["percentage", "fixed"]:
return self._get_commission_amount(commission, subtotal, product, quantity)
item_ids = self._get_commission_items(commission, product)
if not item_ids:
Expand Down
110 changes: 110 additions & 0 deletions sale_commission_product_criteria_domain/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
=======================================
Sale Commission Product Criteria Domain
=======================================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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_product_criteria_domain
: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_product_criteria_domain
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/165/14.0
:alt: Try me on Runbot

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows to limit applied commission items for specific groups.

**Table of contents**

.. contents::
:local:

Usage
=====

Go to Sales > Commission management > Commission Type Items Groups

Create one or more new Groups, eg. “Italy” and “Spain”

Create new Commission type, select type “Product Criteria (with restrictions)”, eg: “Southern Europe”

Add lines to Commission type; for each line one Group must be set, eg.

Product: Conference Chair, value: $20, group: Italy

Product: Conference Chair, value: $10, group: Spain


Go to Agent A, assign Commission type: “Southern Europe” > add “Allowed Commission Groups”: “Italy”, “Spain”

In this way, we are allowing Commission type lines for both “Spain” and “Italy” to be applied to this agent.

Go to customer X, set agent: “Agent A” > in table “Commission items group” set group “Spain”

Go to customer Y, set agent: “Agent A” > in table “Commission items group” set group “Italy”

On sales for customer X, only Commission type lines with group “Spain” will be applied to agent; on sales for customer Y, only Commission type lines with group “Italy” will be applied to agent.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/commission/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/OCA/commission/issues/new?body=module:%20sale_commission_product_criteria_domain%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
~~~~~~~

* Ilyas
* Ooops404

Contributors
~~~~~~~~~~~~

* `Ooops404 <https://www.ooops404.com>`__:

* Ilyas <[email protected]>

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-ilyasProgrammer| image:: https://github.com/ilyasProgrammer.png?size=40px
:target: https://github.com/ilyasProgrammer
:alt: ilyasProgrammer

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

|maintainer-ilyasProgrammer|

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sale_commission_product_criteria_domain/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
26 changes: 26 additions & 0 deletions sale_commission_product_criteria_domain/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# © 2023 ooops404
# License AGPL-3 - See https://www.gnu.org/licenses/agpl-3.0.html
{
"name": "Sale Commission Product Criteria Domain",
"version": "14.0.1.0.1",
"author": "Ilyas," "Ooops404," "Odoo Community Association (OCA)",
"contributors": ["Ilyas"],
"maintainers": ["ilyasProgrammer"],
"website": "https://github.com/OCA/commission",
"category": "Sales Management",
"license": "AGPL-3",
"depends": [
"sale_commission_product_criteria",
"web_domain_field",
],
"demo": [
"demo/demo_data.xml",
],
"data": [
"views/views.xml",
"security/ir.model.access.csv",
],
"application": False,
"installable": True,
"auto_install": False,
}
132 changes: 132 additions & 0 deletions sale_commission_product_criteria_domain/demo/demo_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?xml version="1.0" ?>
<odoo>
<!-- Commissions -->
<record id="demo_commission_rules_restrict" model="sale.commission">
<field name="name">Based on Rules Restricted</field>
<field name="commission_type">product_restricted</field>
</record>

<!-- Commission Groups -->
<record id="demo_cig_spain" model="commission.items.group">
<field name="name">Spain</field>
<field
name="commission_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_commission_rules_restrict')])]"
/>
</record>

<record id="demo_cig_italy" model="commission.items.group">
<field name="name">Italy</field>
<field
name="commission_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_commission_rules_restrict')])]"
/>
</record>

<!-- Commission Items -->
<record id="demo_crr_item_1" model="commission.item">
<field name="commission_id" ref="demo_commission_rules_restrict" />
<field name="sequence" eval="1" />
<field name="based_on">sol</field>
<field name="applied_on">3_global</field>
<field name="commission_type">fixed</field>
<field name="fixed_amount">10</field>
<field name="group_id" ref="demo_cig_italy" />
</record>

<record id="demo_crr_item_2" model="commission.item">
<field name="commission_id" ref="demo_commission_rules_restrict" />
<field name="sequence" eval="2" />
<field name="based_on">sol</field>
<field name="applied_on">2_product_category</field>
<field name="commission_type">fixed</field>
<field name="fixed_amount">20</field>
<field name="categ_id" ref="product.product_category_5" />
<field name="group_id" ref="demo_cig_spain" />
</record>

<record id="demo_crr_item_3" model="commission.item">
<field name="commission_id" ref="demo_commission_rules_restrict" />
<field name="sequence" eval="3" />
<field name="based_on">sol</field>
<field name="applied_on">1_product</field>
<field name="commission_type">percentage</field>
<field name="percent_amount">5</field>
<field
name="product_tmpl_id"
ref="product.product_product_4_product_template"
/>
<field name="group_id" ref="demo_cig_spain" />
</record>

<record id="demo_crr_item_4" model="commission.item">
<field name="commission_id" ref="demo_commission_rules_restrict" />
<field name="sequence" eval="4" />
<field name="based_on">sol</field>
<field name="applied_on">0_product_variant</field>
<field name="commission_type">percentage</field>
<field name="percent_amount">15</field>
<field name="product_id" ref="product.product_product_4" />
<field name="group_id" ref="demo_cig_spain" />
</record>

<!-- Agents -->
<record id="demo_agent_rules_restricted_italy" model="res.partner">
<field name="name">Agent Rules Restricted Italy</field>
<field name="is_company">True</field>
<field name="agent">True</field>
<field name="commission_id" ref="demo_commission_rules_restrict" />
<field
name="allowed_commission_group_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_cig_italy')])]"
/>
</record>
<record id="demo_agent_rules_restricted_spain" model="res.partner">
<field name="name">Agent Rules Restricted Spain</field>
<field name="is_company">True</field>
<field name="agent">True</field>
<field name="commission_id" ref="demo_commission_rules_restrict" />
<field
name="allowed_commission_group_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_cig_spain')])]"
/>
</record>

<!-- Azure -->
<record id="base.res_partner_12" model="res.partner">
<field name="apply_commission_restrictions" eval="True" />
<field
name="agent_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_agent_rules_restricted_spain')])]"
/>
</record>
<record id="cia_azure" model="commission.item.agent">
<field name="partner_id" ref="base.res_partner_12" />
<field
name="group_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_cig_spain')])]"
/>
<field name="agent_id" ref="demo_agent_rules_restricted_spain" />
</record>

<!-- Deco -->
<record id="base.res_partner_2" model="res.partner">
<field name="apply_commission_restrictions" eval="True" />
<field
name="agent_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_agent_rules_restricted_italy')])]"
/>
</record>
<record id="cia_deco" model="commission.item.agent">
<field name="partner_id" ref="base.res_partner_2" />
<field
name="group_ids"
eval="[(6, 0, [ref('sale_commission_product_criteria_domain.demo_cig_italy')])]"
/>
<field
name="agent_id"
ref="sale_commission_product_criteria_domain.demo_agent_rules_restricted_italy"
/>
</record>

</odoo>
Loading
Loading