Skip to content

Commit

Permalink
Merge pull request #163 from eLBati/11.0-porting-sale_commission_pric…
Browse files Browse the repository at this point in the history
…elist

11.0 porting sale_commission_pricelist
  • Loading branch information
pedrobaeza committed Aug 22, 2018
2 parents a09c60c + 6e498ed commit 2740d55
Show file tree
Hide file tree
Showing 18 changed files with 3,296 additions and 0 deletions.
87 changes: 87 additions & 0 deletions sale_commission_pricelist/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
==============================
Sales commissions by pricelist
==============================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! 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/11.0/sale_commission_pricelist
:alt: OCA/commission
.. |badge4| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
:target: https://runbot.odoo-community.org/runbot/165/11.0
:alt: Try me on Runbot

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

This module extends the functionality of sale_commission to allow you set a
commission to pricelist item.

The commission is applied when the pricelist rule is applied, that is after changing product or quantity of sale order line.

**Table of contents**

.. contents::
:local:

Usage
=====

To use this module, you need to:

#. Go to Sales -> Configuration -> Settings -> Pricing -> Sale Price and
activate: "Advanced pricing based on formulas (discounts, margins,
rounding)"
#. Go to Sales -> Configuration -> Price-list and edit an existing one or
create a new one
#. In the pricelist -> add a new item or open a new one
#. You will find the field commission in the pricelist item

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.

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

Credits
=======

Authors
~~~~~~~

* Tecnativa

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

* `Tecnativa <https://www.tecnativa.com>`_:
* Carlos Dauden
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>

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.

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

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions sale_commission_pricelist/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

from . import models
19 changes: 19 additions & 0 deletions sale_commission_pricelist/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2018 Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

{
'name': 'Sales commissions by pricelist',
'version': '11.0.1.0.0',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'category': 'Sales',
'website': 'https://github.com/OCA/commission',
'license': 'AGPL-3',
'depends': [
'sale_commission',
],
'data': [
'views/product_pricelist_view.xml',
],
'installable': True,
}
34 changes: 34 additions & 0 deletions sale_commission_pricelist/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_commission_pricelist
#
# Translators:
# OCA Transbot <transbot@odoo-community.org>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-02 02:42+0000\n"
"PO-Revision-Date: 2018-05-02 02:42+0000\n"
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2018\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: sale_commission_pricelist
#: model:ir.model.fields,field_description:sale_commission_pricelist.field_product_pricelist_item_commission_id
msgid "Commission"
msgstr "Comisión"

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_product_pricelist_item
msgid "Pricelist item"
msgstr "Elemento de la tarifa"

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_sale_order_line
msgid "Sales Order Line"
msgstr "Línea de pedido de venta"
34 changes: 34 additions & 0 deletions sale_commission_pricelist/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_commission_pricelist
#
# Translators:
# Lixon Jean-Yves <jy.lixon@ls-development.net>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-02 02:42+0000\n"
"PO-Revision-Date: 2018-05-02 02:42+0000\n"
"Last-Translator: Lixon Jean-Yves <jy.lixon@ls-development.net>, 2018\n"
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: sale_commission_pricelist
#: model:ir.model.fields,field_description:sale_commission_pricelist.field_product_pricelist_item_commission_id
msgid "Commission"
msgstr "Commission"

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_product_pricelist_item
msgid "Pricelist item"
msgstr ""

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_sale_order_line
msgid "Sales Order Line"
msgstr ""
34 changes: 34 additions & 0 deletions sale_commission_pricelist/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_commission_pricelist
#
# Translators:
# Lorenzo Battistini <lorenzo.battistini@agilebg.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 02:07+0000\n"
"PO-Revision-Date: 2018-05-05 02:07+0000\n"
"Last-Translator: Lorenzo Battistini <lorenzo.battistini@agilebg.com>, 2018\n"
"Language-Team: Italian (https://www.transifex.com/oca/teams/23907/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: it\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#. module: sale_commission_pricelist
#: model:ir.model.fields,field_description:sale_commission_pricelist.field_product_pricelist_item_commission_id
msgid "Commission"
msgstr "Commissione"

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_product_pricelist_item
msgid "Pricelist item"
msgstr ""

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_sale_order_line
msgid "Sales Order Line"
msgstr "Riga ordine di vendita"
34 changes: 34 additions & 0 deletions sale_commission_pricelist/i18n/tr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_commission_pricelist
#
# Translators:
# Ediz Duman <neps1192@gmail.com>, 2018
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-05 02:07+0000\n"
"PO-Revision-Date: 2018-05-05 02:07+0000\n"
"Last-Translator: Ediz Duman <neps1192@gmail.com>, 2018\n"
"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: tr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#. module: sale_commission_pricelist
#: model:ir.model.fields,field_description:sale_commission_pricelist.field_product_pricelist_item_commission_id
msgid "Commission"
msgstr "Komisyon"

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_product_pricelist_item
msgid "Pricelist item"
msgstr ""

#. module: sale_commission_pricelist
#: model:ir.model,name:sale_commission_pricelist.model_sale_order_line
msgid "Sales Order Line"
msgstr "Satış Sipariş Satırı"
3 changes: 3 additions & 0 deletions sale_commission_pricelist/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

from . import product_pricelist
from . import sale_order
14 changes: 14 additions & 0 deletions sale_commission_pricelist/models/product_pricelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2018 Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductPricelistItem(models.Model):
_inherit = 'product.pricelist.item'

commission_id = fields.Many2one(
comodel_name='sale.commission',
string='Commission',
ondelete='restrict',
)
39 changes: 39 additions & 0 deletions sale_commission_pricelist/models/sale_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2018 Tecnativa - Carlos Dauden <carlos.dauden@tecnativa.com>
# Copyright 2018 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import api, models


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

def _get_commission_from_pricelist(self):
self.ensure_one()
if not self.product_id or not self.order_id.pricelist_id:
return False
rule_id = self.order_id.pricelist_id.get_product_price_rule(
product=self.product_id,
quantity=self.product_uom_qty or 1.0,
partner=self.order_id.partner_id,
date=self.order_id.date_order,
uom_id=self.product_uom.id)[1]
rule = self.env['product.pricelist.item'].browse(rule_id)
return rule.commission_id

@api.onchange('product_id', 'product_uom_qty')
def _onchange_product_id_sale_commission_pricelist(self):
commission = self._get_commission_from_pricelist()
if commission:
self.agents.update({
'commission': commission.id,
})

def _prepare_agents_vals(self):
self.ensure_one()
res = super(SaleOrderLine, self)._prepare_agents_vals()
commission = self._get_commission_from_pricelist()
if commission:
for vals in res:
vals['commission'] = commission.id
return res
3 changes: 3 additions & 0 deletions sale_commission_pricelist/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* `Tecnativa <https://www.tecnativa.com>`_:
* Carlos Dauden
* Lorenzo Battistini <lorenzo.battistini@agilebg.com>
4 changes: 4 additions & 0 deletions sale_commission_pricelist/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This module extends the functionality of sale_commission to allow you set a
commission to pricelist item.

The commission is applied when the pricelist rule is applied, that is after changing product or quantity of sale order line.
9 changes: 9 additions & 0 deletions sale_commission_pricelist/readme/USAGE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
To use this module, you need to:

#. Go to Sales -> Configuration -> Settings -> Pricing -> Sale Price and
activate: "Advanced pricing based on formulas (discounts, margins,
rounding)"
#. Go to Sales -> Configuration -> Price-list and edit an existing one or
create a new one
#. In the pricelist -> add a new item or open a new one
#. You will find the field commission in the pricelist item
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2740d55

Please sign in to comment.