Permalink
Browse files

[9.0][MIG] contract_commission module

  • Loading branch information...
cubells authored and pedrobaeza committed Apr 5, 2017
1 parent 23ac9c2 commit c77ce9beb2d40fd7bd4cab591fa3d4ec402c979a
@@ -12,8 +12,8 @@ invoices generated from contracts.
Installation
============
This module is auto-installed when you have *account_analytic_analysis* and
*sale_commission* modules installed.
This module is auto-installed when you have *contract* and *sale_commission*
modules installed.
Usage
=====
@@ -23,7 +23,7 @@ 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/8.0
:target: https://runbot.odoo-community.org/runbot/110/9.0
Known issues / Roadmap
======================
@@ -34,27 +34,30 @@ Known issues / Roadmap
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
`here <https://github.com/OCA/commission/issues/new?body=module:%20
contract_commission%0Aversion:%20
8.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
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 smash it by providing detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
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 <http://www.flaticon.com/authors/freepik>_ from
www.flaticon.com
www.flaticon.com`
Maintainer
----------
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# Copyright 2015 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import models
@@ -1,21 +1,20 @@
# -*- coding: utf-8 -*-
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# 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': '8.0.1.0.0',
'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, '
'version': '9.0.1.0.0',
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
"website": "https://www.tecnativa.com/",
"category": "Generic Modules/Sales & Purchases",
'license': 'AGPL-3',
'depends': [
'account_analytic_analysis',
'contract',
'sale_commission',
],
'contributors': [
"Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>",
],
"installable": True,
"auto_install": True,
}
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# Copyright 2015 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import account_analytic_account
from . import analytic
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# Copyright 2015 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from openerp import api, models
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# Copyright 2015 Tecnativa - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import test_contract_commission
@@ -1,40 +1,42 @@
# -*- coding: utf-8 -*-
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# 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
class TestContractCommission(common.TransactionCase):
def setUp(self):
super(TestContractCommission, self).setUp()
self.product = self.env.ref('product.product_product_5')
self.commission = self.env['sale.commission'].create(
class TestContractCommission(common.SavepointCase):
@classmethod
def setUpClass(cls):
super(TestContractCommission, cls).setUpClass()
cls.product = cls.env.ref('product.product_product_5')
cls.commission = cls.env['sale.commission'].create(
{'name': 'Test',
'commission_type': 'fixed',
'fix_qty': 3.0})
self.agent = self.env['res.partner'].create(
cls.agent = cls.env['res.partner'].create(
{'name': 'Agent',
'agent': True,
'commission': self.commission.id})
self.partner = self.env.ref('base.res_partner_1')
self.contract = self.env['account.analytic.account'].create(
{'partner_id': self.partner.id,
'commission': cls.commission.id})
cls.partner = cls.env['res.partner'].create({
'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': self.product.id,
'name': self.product.name,
'product_id': cls.product.id,
'name': cls.product.name,
'quantity': 1.0,
'uom_id': self.product.uom_id.id,
'uom_id': cls.product.uom_id.id,
'price_unit': 1.0,
})]}
)
self.partner.agents = [(6, 0, self.agent.ids)]
def test_invoice_commissions(self):
self.contract.recurring_create_invoice()
@@ -45,3 +47,13 @@ def test_invoice_commissions(self):
self.assertEqual(invoice_lines.agents.agent, self.agent)
self.assertEqual(
invoice_lines.agents.commission, self.commission)
def test_invoice_wo_commissions(self):
"""Test correct creation when there's no agents"""
self.partner.agents = False
self.contract.recurring_create_invoice()
invoice_lines = self.env['account.invoice.line'].search(
[('account_analytic_id', '=', self.contract.id)]
)
self.assertEqual(len(invoice_lines), 1)
self.assertFalse(invoice_lines.agents)
View
@@ -0,0 +1 @@
contract

0 comments on commit c77ce9b

Please sign in to comment.