cubells
8 years ago
committed by
Pedro M. Baeza
24 changed files with 162 additions and 137 deletions
-
24contract_recurring_analytic_distribution/README.rst
-
2contract_recurring_analytic_distribution/__init__.py
-
14contract_recurring_analytic_distribution/__openerp__.py
-
8contract_recurring_analytic_distribution/i18n/ca.po
-
8contract_recurring_analytic_distribution/i18n/de.po
-
8contract_recurring_analytic_distribution/i18n/el_GR.po
-
8contract_recurring_analytic_distribution/i18n/es.po
-
8contract_recurring_analytic_distribution/i18n/es_MX.po
-
8contract_recurring_analytic_distribution/i18n/fi.po
-
8contract_recurring_analytic_distribution/i18n/fr.po
-
8contract_recurring_analytic_distribution/i18n/pt_BR.po
-
8contract_recurring_analytic_distribution/i18n/sk_SK.po
-
8contract_recurring_analytic_distribution/i18n/sl.po
-
5contract_recurring_analytic_distribution/models/__init__.py
-
18contract_recurring_analytic_distribution/models/account_analytic_invoice_line.py
-
0contract_recurring_analytic_distribution/static/description/icon.png
-
0contract_recurring_analytic_distribution/static/description/icon.svg
-
2contract_recurring_analytic_distribution/tests/__init__.py
-
69contract_recurring_analytic_distribution/tests/test_contract_recurring_distribution.py
-
15contract_recurring_analytic_distribution/views/account_analytic_invoice_line_view.xml
-
5contract_recurring_plans/tests/__init__.py
-
47contract_recurring_plans/tests/test_contract_recurring_plans.py
-
17contract_recurring_plans/views/account_analytic_invoice_line_view.xml
-
1oca_dependencies.txt
@ -1,5 +1,5 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- 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 |
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
||||
|
|
||||
from . import models |
from . import models |
@ -1,17 +1,19 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- 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 |
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
||||
|
|
||||
{ |
{ |
||||
'name': 'Analytic plans on contracts recurring invoices', |
'name': 'Analytic plans on contracts recurring invoices', |
||||
'version': '8.0.1.0.0', |
|
||||
|
'version': '9.0.1.0.0', |
||||
'category': 'Contract Management', |
'category': 'Contract Management', |
||||
'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, ' |
|
||||
|
'author': 'Tecnativa, ' |
||||
'Odoo Community Association (OCA)', |
'Odoo Community Association (OCA)', |
||||
'website': 'http://www.serviciosbaeza.com', |
|
||||
|
'website': 'http://www.tecnativa.com', |
||||
|
'license': 'AGPL-3', |
||||
'depends': [ |
'depends': [ |
||||
'account_analytic_plans', |
|
||||
'account_analytic_analysis', |
|
||||
|
'account_analytic_distribution', |
||||
|
'contract', |
||||
], |
], |
||||
'data': [ |
'data': [ |
||||
'views/account_analytic_invoice_line_view.xml', |
'views/account_analytic_invoice_line_view.xml', |
@ -0,0 +1,5 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Copyright 2015 Tecnativa - Pedro M. Baeza |
||||
|
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
||||
|
|
||||
|
from . import account_analytic_invoice_line |
Before Width: 128 | Height: 128 | Size: 6.1 KiB After Width: 128 | Height: 128 | Size: 6.1 KiB |
@ -0,0 +1,69 @@ |
|||||
|
# -*- 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 |
||||
|
|
||||
|
import openerp.tests.common as common |
||||
|
|
||||
|
|
||||
|
class TestContractRecurringDistribution(common.SavepointCase): |
||||
|
@classmethod |
||||
|
def setUpClass(cls): |
||||
|
super(TestContractRecurringDistribution, cls).setUpClass() |
||||
|
cls.partner = cls.env['res.partner'].create({'name': 'Test'}) |
||||
|
cls.product = cls.env['product.product'].create({ |
||||
|
'name': 'Test product', |
||||
|
}) |
||||
|
cls.account1 = cls.env['account.analytic.account'].create({ |
||||
|
'name': 'Test account #1', |
||||
|
}) |
||||
|
cls.account2 = cls.env['account.analytic.account'].create({ |
||||
|
'name': 'Test account #2', |
||||
|
}) |
||||
|
cls.uom = cls.env.ref('product.product_uom_hour') |
||||
|
cls.contract = cls.env['account.analytic.account'].create({ |
||||
|
'name': 'Test contract', |
||||
|
'partner_id': cls.partner.id, |
||||
|
'type': 'contract', |
||||
|
'recurring_invoices': 1, |
||||
|
'recurring_interval': 1, |
||||
|
'recurring_invoice_line_ids': [ |
||||
|
(0, 0, {'quantity': 2.0, |
||||
|
'price_unit': 100.0, |
||||
|
'name': 'Test', |
||||
|
'product_id': cls.product.id, |
||||
|
'uom_id': cls.uom.id})], |
||||
|
}) |
||||
|
cls.distribution = cls.env['account.analytic.distribution'].create({ |
||||
|
'name': 'Test distribution', |
||||
|
'rule_ids': [ |
||||
|
(0, 0, { |
||||
|
'sequence': 10, |
||||
|
'percent': 75.00, |
||||
|
'analytic_account_id': cls.account1.id, |
||||
|
}), |
||||
|
(0, 0, { |
||||
|
'sequence': 20, |
||||
|
'percent': 25.00, |
||||
|
'analytic_account_id': cls.account2.id, |
||||
|
}), |
||||
|
] |
||||
|
}) |
||||
|
|
||||
|
def test_invoice_without_distribution(self): |
||||
|
self.contract.recurring_create_invoice() |
||||
|
invoice = self.env['account.invoice'].search( |
||||
|
[('partner_id', '=', self.partner.id)]) |
||||
|
self.assertEqual( |
||||
|
invoice.invoice_line_ids[0].account_analytic_id, self.contract) |
||||
|
|
||||
|
def test_invoice_with_distribution(self): |
||||
|
self.contract.recurring_invoice_line_ids.analytic_distribution_id = ( |
||||
|
self.distribution.id) |
||||
|
self.contract.recurring_create_invoice() |
||||
|
invoice = self.env['account.invoice'].search( |
||||
|
[('partner_id', '=', self.partner.id)]) |
||||
|
self.assertFalse(invoice.invoice_line_ids[0].account_analytic_id) |
||||
|
self.assertEqual( |
||||
|
invoice.invoice_line_ids[0].analytic_distribution_id, |
||||
|
self.distribution) |
@ -0,0 +1,15 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
|
||||
|
<record id="account_analytic_account_form_form" model="ir.ui.view"> |
||||
|
<field name="name">Contract form (with plans)</field> |
||||
|
<field name="model">account.analytic.account</field> |
||||
|
<field name="inherit_id" ref="contract.account_analytic_account_recurring_form_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<field name="quantity" position="before"> |
||||
|
<field name="analytic_distribution_id"/> |
||||
|
</field> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -1,5 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza |
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|
||||
|
|
||||
from . import test_contract_recurring_plans |
|
@ -1,47 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza |
|
||||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html |
|
||||
|
|
||||
import openerp.tests.common as common |
|
||||
|
|
||||
|
|
||||
class TestContractRecurringPlans(common.TransactionCase): |
|
||||
|
|
||||
def setUp(self): |
|
||||
super(TestContractRecurringPlans, self).setUp() |
|
||||
self.partner = self.env['res.partner'].create({'name': 'Test'}) |
|
||||
self.product = self.env.ref('product.product_product_consultant') |
|
||||
self.uom = self.env.ref('product.product_uom_hour') |
|
||||
self.contract = self.env['account.analytic.account'].create({ |
|
||||
'name': 'Test contract', |
|
||||
'partner_id': self.partner.id, |
|
||||
'type': 'contract', |
|
||||
'recurring_invoices': 1, |
|
||||
'recurring_interval': 1, |
|
||||
'recurring_invoice_line_ids': [ |
|
||||
(0, 0, {'quantity': 2.0, |
|
||||
'price_unit': 100.0, |
|
||||
'name': 'Test', |
|
||||
'product_id': self.product.id, |
|
||||
'uom_id': self.uom.id})], |
|
||||
}) |
|
||||
plan = self.env['account.analytic.plan'].create({'name': 'Test'}) |
|
||||
self.analytics = self.env['account.analytic.plan.instance'].create( |
|
||||
{'plan_id': plan.id}) |
|
||||
|
|
||||
def test_invoice_without_plans(self): |
|
||||
self.contract.recurring_create_invoice() |
|
||||
invoice = self.env['account.invoice'].search( |
|
||||
[('partner_id', '=', self.partner.id)]) |
|
||||
self.assertEqual( |
|
||||
invoice.invoice_line[0].account_analytic_id, self.contract) |
|
||||
|
|
||||
def test_invoice_with_plans(self): |
|
||||
self.contract.recurring_invoice_line_ids.analytics_id = ( |
|
||||
self.analytics.id) |
|
||||
self.contract.recurring_create_invoice() |
|
||||
invoice = self.env['account.invoice'].search( |
|
||||
[('partner_id', '=', self.partner.id)]) |
|
||||
self.assertFalse(invoice.invoice_line[0].account_analytic_id) |
|
||||
self.assertEqual( |
|
||||
invoice.invoice_line[0].analytics_id, self.analytics) |
|
@ -1,17 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<openerp> |
|
||||
<data> |
|
||||
|
|
||||
<record id="account_analytic_account_form_form" model="ir.ui.view"> |
|
||||
<field name="name">Contract form (with plans)</field> |
|
||||
<field name="model">account.analytic.account</field> |
|
||||
<field name="inherit_id" ref="account_analytic_analysis.account_analytic_account_form_form"/> |
|
||||
<field name="arch" type="xml"> |
|
||||
<field name="quantity" position="before"> |
|
||||
<field name="analytics_id"/> |
|
||||
</field> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
</data> |
|
||||
</openerp> |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue