From 150cfa22290de19be62453e76f98db1529ed4cb2 Mon Sep 17 00:00:00 2001 From: Marcel Savegnago Date: Sat, 12 Sep 2020 14:26:58 -0300 Subject: [PATCH] [MIG] contract_commission: Migration to 12.0 --- contract_commission/README.rst | 89 ++-- contract_commission/__init__.py | 1 - .../{__openerp__.py => __manifest__.py} | 12 +- .../i18n/contract_commission.pot | 4 +- contract_commission/models/__init__.py | 3 +- contract_commission/models/analytic.py | 19 - contract_commission/models/contract_line.py | 19 + contract_commission/readme/CONFIGURE.rst | 2 + contract_commission/readme/CONTRIBUTORS.rst | 3 + contract_commission/readme/DESCRIPTION.rst | 2 + contract_commission/readme/USAGE.rst | 2 + .../static/description/banner.png | Bin 0 -> 6733 bytes .../static/description/index.html | 434 ++++++++++++++++++ contract_commission/tests/__init__.py | 1 - .../tests/test_contract_commission.py | 80 +++- oca_dependencies.txt | 1 + 16 files changed, 586 insertions(+), 86 deletions(-) rename contract_commission/{__openerp__.py => __manifest__.py} (62%) delete mode 100644 contract_commission/models/analytic.py create mode 100644 contract_commission/models/contract_line.py create mode 100644 contract_commission/readme/CONFIGURE.rst create mode 100644 contract_commission/readme/CONTRIBUTORS.rst create mode 100644 contract_commission/readme/DESCRIPTION.rst create mode 100644 contract_commission/readme/USAGE.rst create mode 100644 contract_commission/static/description/banner.png create mode 100644 contract_commission/static/description/index.html create mode 100644 oca_dependencies.txt diff --git a/contract_commission/README.rst b/contract_commission/README.rst index beaa5a99f..4b1642ac5 100644 --- a/contract_commission/README.rst +++ b/contract_commission/README.rst @@ -1,16 +1,40 @@ -.. 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 - -======================= -Commission in contracts -======================= +================================ +Commissions in contract invoices +================================ + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! 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/12.0/contract_commission + :alt: OCA/commission +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/commission-12-0/commission-12-0-contract_commission + :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/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| This module allows to get default commissions for partner in the recurring invoices generated from contracts. -Installation -============ +**Table of contents** + +.. contents:: + :local: + +Configuration +============= This module is auto-installed when you have *contract* and *sale_commission* modules installed. @@ -21,55 +45,44 @@ Usage When invoicing contracts, the agents assigned to the partner of the contract will now be assigned to the generated invoices. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/110/9.0 - -Known issues / Roadmap -====================== - -* Allow to set specific commissions for each contract instead of taking the - ones set at partner level. - 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 smash it by providing detailed and welcomed feedback. +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 `_. + +Do not contact contributors directly about support or help with technical issues. Credits ======= -Images ------- +Authors +~~~~~~~ -* Odoo Community Association: `Icon `_. +* Tecnativa Contributors ------------- +~~~~~~~~~~~~ + * Pedro M. Baeza * Vicent Cubells +* Marcel Savegnago -Icon ----- -* http://commons.wikimedia.org/wiki/File:Percent_18e.svg -* https://openclipart.org/detail/43969/pile-of-golden-coins-by-j_alves -* Subicon made by `Freepik from www.flaticon.com - `_ +Maintainers +~~~~~~~~~~~ -Maintainer ----------- +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://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 https://odoo-community.org. +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/contract_commission/__init__.py b/contract_commission/__init__.py index 6af6a0423..0aaf667fa 100644 --- a/contract_commission/__init__.py +++ b/contract_commission/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html diff --git a/contract_commission/__openerp__.py b/contract_commission/__manifest__.py similarity index 62% rename from contract_commission/__openerp__.py rename to contract_commission/__manifest__.py index 520439d5f..c34510320 100644 --- a/contract_commission/__openerp__.py +++ b/contract_commission/__manifest__.py @@ -1,20 +1,20 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Tecnativa - Pedro M. Baeza # Copyright 2017 Tecnativa - Vicent Cubells # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html { 'name': 'Commissions in contract invoices', - 'version': '9.0.1.0.0', + 'version': '12.0.1.0.0', 'author': 'Tecnativa, ' 'Odoo Community Association (OCA)', - "website": "https://www.tecnativa.com/", - "category": "Generic Modules/Sales & Purchases", + 'website': 'https://www.tecnativa.com/', + 'category': 'Generic Modules/Sales & Purchases', + 'images': ['static/description/banner.png'], 'license': 'AGPL-3', 'depends': [ 'contract', 'sale_commission', ], - "installable": True, - "auto_install": True, + 'installable': True, + 'auto_install': True, } diff --git a/contract_commission/i18n/contract_commission.pot b/contract_commission/i18n/contract_commission.pot index 28a0519a8..76a73448e 100644 --- a/contract_commission/i18n/contract_commission.pot +++ b/contract_commission/i18n/contract_commission.pot @@ -4,8 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 9.0c\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-09-12 17:23+0000\n" +"PO-Revision-Date: 2020-09-12 17:23+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" diff --git a/contract_commission/models/__init__.py b/contract_commission/models/__init__.py index 0cc7c9f27..6cc51c365 100644 --- a/contract_commission/models/__init__.py +++ b/contract_commission/models/__init__.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -from . import analytic +from . import contract_line diff --git a/contract_commission/models/analytic.py b/contract_commission/models/analytic.py deleted file mode 100644 index 1a6104f90..000000000 --- a/contract_commission/models/analytic.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- -# Copyright 2015 Tecnativa - Pedro M. Baeza -# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html - -from openerp import api, models - - -class AccountAnalyticAccount(models.Model): - _inherit = 'account.analytic.account' - - @api.model - def _prepare_invoice_line(self, line, fiscal_position): - res = super(AccountAnalyticAccount, self)._prepare_invoice_line( - line, fiscal_position) - invoice_line_model = self.env['account.invoice.line'].with_context( - partner_id=line.analytic_account_id.partner_id.id) - res = {} if res is None else res - res['agents'] = invoice_line_model._default_agents() - return res diff --git a/contract_commission/models/contract_line.py b/contract_commission/models/contract_line.py new file mode 100644 index 000000000..f140d5e01 --- /dev/null +++ b/contract_commission/models/contract_line.py @@ -0,0 +1,19 @@ +# Copyright 2015 Tecnativa - Pedro M. Baeza +# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html + +from odoo import api, models + + +class ContractLine(models.Model): + _inherit = 'contract.line' + + @api.model + def _prepare_invoice_line(self, invoice_id=False, invoice_values=False): + vals = super(ContractLine, self)._prepare_invoice_line( + invoice_id=invoice_id, invoice_values=invoice_values) + invoice_line_model = self.env['account.invoice.line'].with_context({ + 'partner_id': self.contract_id.partner_id.id + }) + vals = {} if vals is None else vals + vals['agents'] = invoice_line_model._default_agents() + return vals diff --git a/contract_commission/readme/CONFIGURE.rst b/contract_commission/readme/CONFIGURE.rst new file mode 100644 index 000000000..5d29e16c8 --- /dev/null +++ b/contract_commission/readme/CONFIGURE.rst @@ -0,0 +1,2 @@ +This module is auto-installed when you have *contract* and *sale_commission* +modules installed. diff --git a/contract_commission/readme/CONTRIBUTORS.rst b/contract_commission/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..7fbe6f791 --- /dev/null +++ b/contract_commission/readme/CONTRIBUTORS.rst @@ -0,0 +1,3 @@ +* Pedro M. Baeza +* Vicent Cubells +* Marcel Savegnago diff --git a/contract_commission/readme/DESCRIPTION.rst b/contract_commission/readme/DESCRIPTION.rst new file mode 100644 index 000000000..0b74191ca --- /dev/null +++ b/contract_commission/readme/DESCRIPTION.rst @@ -0,0 +1,2 @@ +This module allows to get default commissions for partner in the recurring +invoices generated from contracts. diff --git a/contract_commission/readme/USAGE.rst b/contract_commission/readme/USAGE.rst new file mode 100644 index 000000000..c5341d4e3 --- /dev/null +++ b/contract_commission/readme/USAGE.rst @@ -0,0 +1,2 @@ +When invoicing contracts, the agents assigned to the partner of the contract +will now be assigned to the generated invoices. diff --git a/contract_commission/static/description/banner.png b/contract_commission/static/description/banner.png new file mode 100644 index 0000000000000000000000000000000000000000..da4f6de2a24707c5658d507c81cdd7625d9bf9e4 GIT binary patch literal 6733 zcmb7pWmHt%8}Au%q`Rf08)igM+M&}yy1VNIqyz>fh6bg(5tU9629OdMVn_iAK^jE5 z<<7m|{~zvI>zsYoIcx2;_p_h<{9?!I>8O$tF%ba(K&q|=gJauC?EN2@0Q=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xG{HV*LUfCcCWdR)9*jg$I(Xg&oT)#yrII{yDi$Nu#Q{P0MY;Zl z&m#0K>in6d9(L~%#7-h!hB^7q5S6X%|It~R%G^&HTp#~Z6QYO}P(PU&v25QndgYZg zVyVJK1pPzU^(No#;o!Uitm~DKnDT|?+ywJt?ng4qt)x#D_1^cAGGa-pkpNLGIA4Eig8Fp?cN!^-?Ze-@`M zmmEO}sec5(D16ufa15}yZw8_(>Go(}v6l^kSg47jJPGusl!?6|2wC*44jX-FHAP86 z_S~16XOFN(z(iq~bgVhgVtKbtShmi@{_mz&9K<$(Y^H`}R_vukcc-%G%X?tDh9 zk-EuSYs$QkRd!!$OdWmeg*pu9eUF@c5Ys!VguG`jiK>EV%D=T?SRoYa@yW~1_wPY& z4=N!?Fjp?2?hFIwj;IBnJoWtF0V0$Z4h#bUsc%PBu}LXQX)%WG+S!-&jdCz~_IgF0 zSwWMJCb-`xj~W|)xW*M8qA@-`zAMLzbC{Wf5`zcGT1?&GqVV z>nt^^fV;#+30YpVH#UMReub4*zUgqRGCqM1XM*;z)x5(zW8~KlPDUm04DsPRe^xXa zKKw?}>0y3KT|WKi$!{?=OgiLpi9x zs9z<;X~(#6uRqx^IDw>;HLia2?A(TJ+BF@B<<9-qj6d~tL=E}miHr}rI6L!sTU@k} z==^1Zbn%pT2&;KuX>u(5V-nJH&y`Nt|Bi^W9pk@Ld)h?&s&3>vx^=NdR>t3RS2U8s zh?T`WAR4|a%+VKQ(OJ3I&Wpo<_5L!1+!x&#RFutd8N-)b4mc)QSd}ESeQ7E05|Fdf zNxs!sh=E9cQ77AOlFg(}%lr)zH+mdzhx2Y4bAL#u($=WR`nOPfIJDtWp}_ mR^|FXLGpi|xpWTQ<5ZnR1hy6##bA$#0Ci;@SdEhPoBsoPjN1qR literal 0 HcmV?d00001 diff --git a/contract_commission/static/description/index.html b/contract_commission/static/description/index.html new file mode 100644 index 000000000..4b63fc096 --- /dev/null +++ b/contract_commission/static/description/index.html @@ -0,0 +1,434 @@ + + + + + + +Commissions in contract invoices + + + +
+

Commissions in contract invoices

+ + +

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

+

This module allows to get default commissions for partner in the recurring +invoices generated from contracts.

+

Table of contents

+ +
+

Configuration

+

This module is auto-installed when you have contract and sale_commission +modules installed.

+
+
+

Usage

+

When invoicing contracts, the agents assigned to the partner of the contract +will now be assigned to the generated invoices.

+
+
+

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.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Tecnativa
  • +
+
+
+

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.

+

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/contract_commission/tests/__init__.py b/contract_commission/tests/__init__.py index 538d9778c..3f0828dba 100644 --- a/contract_commission/tests/__init__.py +++ b/contract_commission/tests/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html diff --git a/contract_commission/tests/test_contract_commission.py b/contract_commission/tests/test_contract_commission.py index 2a6eae7c8..c64f44918 100644 --- a/contract_commission/tests/test_contract_commission.py +++ b/contract_commission/tests/test_contract_commission.py @@ -1,8 +1,7 @@ -# -*- coding: utf-8 -*- # Copyright 2015 Tecnativa - Pedro M. Baeza # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html -import openerp.tests.common as common +import odoo.tests.common as common class TestContractCommission(common.SavepointCase): @@ -22,26 +21,61 @@ def setUpClass(cls): 'name': 'Test partner', 'agents': [(6, 0, cls.agent.ids)], }) - cls.contract = cls.env['account.analytic.account'].create( - {'partner_id': cls.partner.id, - 'name': 'Test contract', - 'recurring_invoices': True, - 'state': 'draft', - 'type': 'normal', - 'recurring_invoice_line_ids': [ - (0, 0, { - 'product_id': cls.product.id, - 'name': cls.product.name, - 'quantity': 1.0, - 'uom_id': cls.product.uom_id.id, - 'price_unit': 1.0, - })]} + cls.contract = cls.env['contract.contract'].create( + { + 'name': 'Test contract', + 'partner_id': cls.partner.id, + 'contract_type': 'sale', + } ) + cls.contract_line = cls.env['contract.line'].create( + { + 'contract_id': cls.contract.id, + 'product_id': cls.product.id, + 'name': cls.product.name, + 'quantity': 1.0, + 'uom_id': cls.product.uom_id.id, + 'price_unit': 10.0, + 'recurring_rule_type': 'monthly', + 'recurring_interval': 1, + 'date_start': '2018-01-01', + 'recurring_next_date': '2018-01-15', + 'is_auto_renew': False, + } + ) + + cls.account_type = cls.env['account.account.type'].create({ + 'name': 'Test account type', + 'type': 'other', + }) + cls.account = cls.env['account.account'].create({ + 'name': 'Test account', + 'code': 'TEST', + 'user_type_id': cls.account_type.id + }) + cls.invoice = cls.env['account.invoice'].create({ + 'partner_id': cls.partner.id, + 'type': 'out_invoice', + }) + + cls.invoice_line = cls.env['account.invoice.line'].create({ + 'invoice_id': cls.invoice.id, + 'product_id': cls.product.id, + 'name': cls.product.name, + 'account_id': cls.account.id, + 'quantity': 1.0, + 'uom_id': cls.product.uom_id.id, + 'price_unit': 10.0, + }) + def test_invoice_commissions(self): + contracts = self.contract self.contract.recurring_create_invoice() invoice_lines = self.env['account.invoice.line'].search( - [('account_analytic_id', '=', self.contract.id)]) + [('contract_line_id', 'in', + contracts.mapped('contract_line_ids').ids)] + ) self.assertEqual(len(invoice_lines), 1) self.assertEqual(len(invoice_lines.agents), 1) self.assertEqual(invoice_lines.agents.agent, self.agent) @@ -50,10 +84,20 @@ def test_invoice_commissions(self): def test_invoice_wo_commissions(self): """Test correct creation when there's no agents""" + contracts = self.contract self.partner.agents = False self.contract.recurring_create_invoice() invoice_lines = self.env['account.invoice.line'].search( - [('account_analytic_id', '=', self.contract.id)] + [('contract_line_id', 'in', + contracts.mapped('contract_line_ids').ids)] ) self.assertEqual(len(invoice_lines), 1) self.assertFalse(invoice_lines.agents) + + def test_prepare_invoice_line(self): + invoice_id = self.invoice + invoice_values = self.invoice + result = self.contract_line._prepare_invoice_line( + invoice_id=invoice_id, + invoice_values=invoice_values) + self.assertEqual(result['agents'][0][2]['agent'], self.agent.id) diff --git a/oca_dependencies.txt b/oca_dependencies.txt new file mode 100644 index 000000000..8bba64a4a --- /dev/null +++ b/oca_dependencies.txt @@ -0,0 +1 @@ +contract \ No newline at end of file