From daef58a3b15a93e722ff4a17be6b9279d6c4cc88 Mon Sep 17 00:00:00 2001 From: Luis Felipe Mileo Date: Mon, 21 Mar 2016 13:54:28 -0300 Subject: [PATCH] [NEW] Add l10n_br_sale_commission module --- .gitignore | 0 LICENSE | 0 README.md | 0 l10n_br_sale_commission/README.rst | 63 +++++++++++++++++++ l10n_br_sale_commission/__init__.py | 5 ++ l10n_br_sale_commission/__openerp__.py | 26 ++++++++ .../demo/commission_demo.xml | 12 ++++ l10n_br_sale_commission/models/__init__.py | 7 +++ .../models/account_invoice.py | 26 ++++++++ .../models/sale_commission.py | 12 ++++ l10n_br_sale_commission/models/sale_order.py | 26 ++++++++ .../view/account_invoice_view.xml | 27 ++++++++ 12 files changed, 204 insertions(+) mode change 100644 => 100755 .gitignore mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md create mode 100644 l10n_br_sale_commission/README.rst create mode 100644 l10n_br_sale_commission/__init__.py create mode 100644 l10n_br_sale_commission/__openerp__.py create mode 100644 l10n_br_sale_commission/demo/commission_demo.xml create mode 100644 l10n_br_sale_commission/models/__init__.py create mode 100644 l10n_br_sale_commission/models/account_invoice.py create mode 100644 l10n_br_sale_commission/models/sale_commission.py create mode 100644 l10n_br_sale_commission/models/sale_order.py create mode 100755 l10n_br_sale_commission/view/account_invoice_view.xml diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/l10n_br_sale_commission/README.rst b/l10n_br_sale_commission/README.rst new file mode 100644 index 0000000..581ab1b --- /dev/null +++ b/l10n_br_sale_commission/README.rst @@ -0,0 +1,63 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +========================== +L10n BR Sales Commission +========================== + +This module extends sale_commission to adapt invoice form and add the option of +use amount_gross in commission calc. + +Usage +===== + +To use this module, you need to: + +* Go to Sales, Commission Types and create a commission with base "Valor venda s/ impostos" + +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/165/8.0 + +Known issues / Roadmap +====================== +* Tests + +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 smashing it by providing a detailed and welcomed `feedback +`_. + +Images +------ + +* Odoo Community Association: `Icon `_. + +Credits +======= + +Contributors +------------ +* Luis Felipe Mileo + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +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. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/l10n_br_sale_commission/__init__.py b/l10n_br_sale_commission/__init__.py new file mode 100644 index 0000000..8db1d78 --- /dev/null +++ b/l10n_br_sale_commission/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA (https://www.kmee.com.br) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import models diff --git a/l10n_br_sale_commission/__openerp__.py b/l10n_br_sale_commission/__openerp__.py new file mode 100644 index 0000000..7949eb3 --- /dev/null +++ b/l10n_br_sale_commission/__openerp__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA (https://www.kmee.com.br) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +{ + 'name': 'L10n BR Sale Commission', + 'version': '8.0.0.0.0', + 'category': 'Sale', + 'license': 'AGPL-3', + 'summary': 'Sale commissions computed without tax', + 'author': "KMEE," + "Odoo Community Association (OCA)", + 'website': 'http://www.kmee.com.br', + 'depends': [ + 'l10n_br_sale_product', + 'sale_commission' + ], + 'data': [ + 'view/account_invoice_view.xml' + ], + 'demo': [ + 'demo/commission_demo.xml' + ], + 'installable': True, + 'active': False, +} diff --git a/l10n_br_sale_commission/demo/commission_demo.xml b/l10n_br_sale_commission/demo/commission_demo.xml new file mode 100644 index 0000000..2fdd3c1 --- /dev/null +++ b/l10n_br_sale_commission/demo/commission_demo.xml @@ -0,0 +1,12 @@ + + + + + 10% s/ IPI + fixed + True + 10.0 + notax + + + diff --git a/l10n_br_sale_commission/models/__init__.py b/l10n_br_sale_commission/models/__init__.py new file mode 100644 index 0000000..372effd --- /dev/null +++ b/l10n_br_sale_commission/models/__init__.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA (https://www.kmee.com.br) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from . import account_invoice +from . import sale_commission +from . import sale_order diff --git a/l10n_br_sale_commission/models/account_invoice.py b/l10n_br_sale_commission/models/account_invoice.py new file mode 100644 index 0000000..033078c --- /dev/null +++ b/l10n_br_sale_commission/models/account_invoice.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA (https://www.kmee.com.br) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, api +from openerp.tools.safe_eval import safe_eval + + +class AccountInvoiceLineAgent(models.Model): + _inherit = 'account.invoice.line.agent' + + @api.depends('commission.commission_type', 'invoice_line.price_subtotal', + 'commission.amount_base_type') + def _compute_amount(self): + for line in self: + line.amount = 0.0 + if (line.commission.amount_base_type == 'notax' and + not line.invoice_line.product_id.commission_free and + line.commission): + subtotal = line.invoice_line.price_gross + if line.commission.commission_type == 'fixed': + line.amount = subtotal * (line.commission.fix_qty / 100.0) + else: + line.amount = line.commission.calculate_section(subtotal) + else: + return super(AccountInvoiceLineAgent, line)._compute_amount() diff --git a/l10n_br_sale_commission/models/sale_commission.py b/l10n_br_sale_commission/models/sale_commission.py new file mode 100644 index 0000000..16fe0b6 --- /dev/null +++ b/l10n_br_sale_commission/models/sale_commission.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA (https://www.kmee.com.br) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, fields + + +class Commission(models.Model): + _inherit = 'sale.commission' + + amount_base_type = fields.Selection(selection_add=[("notax", + "Valor venda s/ impostos")]) \ No newline at end of file diff --git a/l10n_br_sale_commission/models/sale_order.py b/l10n_br_sale_commission/models/sale_order.py new file mode 100644 index 0000000..9e95f31 --- /dev/null +++ b/l10n_br_sale_commission/models/sale_order.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# © 2016 KMEE INFORMATICA LTDA (https://www.kmee.com.br) +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from openerp import models, api +from openerp.tools.safe_eval import safe_eval + + +class SaleOrderLineAgent(models.Model): + _inherit = 'sale.order.line.agent' + + @api.depends('commission.commission_type', 'sale_line.price_subtotal', + 'commission.amount_base_type') + def _compute_amount(self): + for line in self: + line.amount = 0.0 + if (line.commission.amount_base_type == 'notax' and + not line.sale_line.product_id.commission_free and + line.commission): + subtotal = line.sale_line.price_gross + if line.commission.commission_type == 'fixed': + line.amount = subtotal * (line.commission.fix_qty / 100.0) + else: + line.amount = line.commission.calculate_section(subtotal) + else: + return super(SaleOrderLineAgent, line)._compute_amount() diff --git a/l10n_br_sale_commission/view/account_invoice_view.xml b/l10n_br_sale_commission/view/account_invoice_view.xml new file mode 100755 index 0000000..0a6679f --- /dev/null +++ b/l10n_br_sale_commission/view/account_invoice_view.xml @@ -0,0 +1,27 @@ + + + + + False + + + l10n_br_account.invoice.line.form + account.invoice.line + + 36 + + + + + + + + + + + + + + +