Browse Source

[MIG][9.0] contract_recurring_plans module

pull/63/head
cubells 8 years ago
committed by Pedro M. Baeza
parent
commit
ef113db033
  1. 24
      contract_recurring_analytic_distribution/README.rst
  2. 2
      contract_recurring_analytic_distribution/__init__.py
  3. 14
      contract_recurring_analytic_distribution/__openerp__.py
  4. 8
      contract_recurring_analytic_distribution/i18n/ca.po
  5. 8
      contract_recurring_analytic_distribution/i18n/de.po
  6. 8
      contract_recurring_analytic_distribution/i18n/el_GR.po
  7. 8
      contract_recurring_analytic_distribution/i18n/es.po
  8. 8
      contract_recurring_analytic_distribution/i18n/es_MX.po
  9. 8
      contract_recurring_analytic_distribution/i18n/fi.po
  10. 8
      contract_recurring_analytic_distribution/i18n/fr.po
  11. 8
      contract_recurring_analytic_distribution/i18n/pt_BR.po
  12. 8
      contract_recurring_analytic_distribution/i18n/sk_SK.po
  13. 8
      contract_recurring_analytic_distribution/i18n/sl.po
  14. 5
      contract_recurring_analytic_distribution/models/__init__.py
  15. 18
      contract_recurring_analytic_distribution/models/account_analytic_invoice_line.py
  16. 0
      contract_recurring_analytic_distribution/static/description/icon.png
  17. 0
      contract_recurring_analytic_distribution/static/description/icon.svg
  18. 2
      contract_recurring_analytic_distribution/tests/__init__.py
  19. 69
      contract_recurring_analytic_distribution/tests/test_contract_recurring_distribution.py
  20. 15
      contract_recurring_analytic_distribution/views/account_analytic_invoice_line_view.xml
  21. 5
      contract_recurring_plans/tests/__init__.py
  22. 47
      contract_recurring_plans/tests/test_contract_recurring_plans.py
  23. 17
      contract_recurring_plans/views/account_analytic_invoice_line_view.xml
  24. 1
      oca_dependencies.txt

24
contract_recurring_plans/README.rst → contract_recurring_analytic_distribution/README.rst

@ -6,9 +6,9 @@
Analytic plans for contract recurring invoices
==============================================
This module allows to include an analytic plan on each recurring invoice line,
so if you set it, this will be taken to be transferred to the invoice instead
of the analytic account of the contract.
This module allows to include an analytic distribution on each recurring
invoice line, so if you set it, this will be taken to be transferred to the
invoice instead of the analytic account of the contract.
Usage
=====
@ -18,18 +18,15 @@ invoice recurring lines that you want.
.. 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
Bug Tracker
===========
Bugs are tracked on `GitHub Issues <https://github.com/OCA/
contract/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/
contract/issues/new?body=module:%20
contract_recurring_plans%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/contract/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
=======
@ -37,7 +34,8 @@ Credits
Contributors
------------
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
Icon
----
@ -59,4 +57,4 @@ 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.
To contribute to this module, please visit https://odoo-community.org.

2
contract_recurring_plans/__init__.py → contract_recurring_analytic_distribution/__init__.py

@ -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

14
contract_recurring_plans/__openerp__.py → contract_recurring_analytic_distribution/__openerp__.py

@ -1,17 +1,19 @@
# -*- 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': 'Analytic plans on contracts recurring invoices',
'version': '8.0.1.0.0',
'version': '9.0.1.0.0',
'category': 'Contract Management',
'author': 'Serv. Tecnol. Avanzados - Pedro M. Baeza, '
'author': 'Tecnativa, '
'Odoo Community Association (OCA)',
'website': 'http://www.serviciosbaeza.com',
'website': 'http://www.tecnativa.com',
'license': 'AGPL-3',
'depends': [
'account_analytic_plans',
'account_analytic_analysis',
'account_analytic_distribution',
'contract',
],
'data': [
'views/account_analytic_invoice_line_view.xml',

8
contract_recurring_plans/i18n/ca.po → contract_recurring_analytic_distribution/i18n/ca.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
msgid ""
@ -17,12 +17,12 @@ msgstr ""
"Language: ca\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Compte analític"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr ""

8
contract_recurring_plans/i18n/de.po → contract_recurring_analytic_distribution/i18n/de.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
# Rudolf Schnapka <rs@techno-flex.de>, 2016
@ -18,12 +18,12 @@ msgstr ""
"Language: de\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Kostenstelle"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr "Kostenumlage"

8
contract_recurring_plans/i18n/el_GR.po → contract_recurring_analytic_distribution/i18n/el_GR.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
msgid ""
@ -17,12 +17,12 @@ msgstr ""
"Language: el_GR\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Αναλυτικός Λογαριασμός"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr ""

8
contract_recurring_plans/i18n/es.po → contract_recurring_analytic_distribution/i18n/es.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
msgid ""
@ -17,12 +17,12 @@ msgstr ""
"Language: es\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Cuenta analítica"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr "Distribución analítica"

8
contract_recurring_plans/i18n/es_MX.po → contract_recurring_analytic_distribution/i18n/es_MX.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
msgid ""
@ -17,12 +17,12 @@ msgstr ""
"Language: es_MX\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Cuenta analítica"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr ""

8
contract_recurring_plans/i18n/fi.po → contract_recurring_analytic_distribution/i18n/fi.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
# Jarmo Kortetjärvi <jarmo.kortetjarvi@gmail.com>, 2016
@ -18,12 +18,12 @@ msgstr ""
"Language: fi\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Analyyttinen tili"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr "Analyyttinen jakelu"

8
contract_recurring_plans/i18n/fr.po → contract_recurring_analytic_distribution/i18n/fr.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
# Christophe CHAUVET <christophe.chauvet@gmail.com>, 2016
@ -18,12 +18,12 @@ msgstr ""
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Compte analytique"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr "Distribution analytique"

8
contract_recurring_plans/i18n/pt_BR.po → contract_recurring_analytic_distribution/i18n/pt_BR.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
# danimaribeiro <danimaribeiro@gmail.com>, 2016
@ -18,12 +18,12 @@ msgstr ""
"Language: pt_BR\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Conta analítica"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr "Distribuição analítica"

8
contract_recurring_plans/i18n/sk_SK.po → contract_recurring_analytic_distribution/i18n/sk_SK.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
msgid ""
@ -17,12 +17,12 @@ msgstr ""
"Language: sk_SK\n"
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Analytický účet"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr ""

8
contract_recurring_plans/i18n/sl.po → contract_recurring_analytic_distribution/i18n/sl.po

@ -1,6 +1,6 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * contract_recurring_plans
# * contract_recurring_analytic_distribution
#
# Translators:
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015
@ -18,12 +18,12 @@ msgstr ""
"Language: sl\n"
"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3);\n"
#. module: contract_recurring_plans
#: model:ir.model,name:contract_recurring_plans.model_account_analytic_account
#. module: contract_recurring_analytic_distribution
#: model:ir.model,name:contract_recurring_analytic_distribution.model_account_analytic_account
msgid "Analytic Account"
msgstr "Analitični konto"
#. module: contract_recurring_plans
#. module: contract_recurring_analytic_distribution
#: field:account.analytic.invoice.line,analytics_id:0
msgid "Analytic Distribution"
msgstr "Analitična distribucija"

5
contract_recurring_analytic_distribution/models/__init__.py

@ -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

18
contract_recurring_plans/models/account_analytic_invoice_line.py → contract_recurring_analytic_distribution/models/account_analytic_invoice_line.py

@ -1,5 +1,6 @@
# -*- 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
from openerp import models, fields, api
@ -12,15 +13,18 @@ class AccountAnalyticAccount(models.Model):
def _prepare_invoice_line(self, line, invoice_id):
res = super(AccountAnalyticAccount, self)._prepare_invoice_line(
line, invoice_id)
if line.analytics_id:
res.update({'account_analytic_id': False,
'analytics_id': line.analytics_id.id})
if line.analytic_distribution_id:
res.update({
'account_analytic_id': False,
'analytic_distribution_id': line.analytic_distribution_id.id,
})
return res
class AccountAnalyticInvoiceLine(models.Model):
_inherit = "account.analytic.invoice.line"
analytics_id = fields.Many2one(
comodel_name='account.analytic.plan.instance',
string='Analytic Distribution')
analytic_distribution_id = fields.Many2one(
comodel_name='account.analytic.distribution',
string='Analytic Distribution', oldname='analytics_id',
)

0
contract_recurring_plans/static/description/icon.png → contract_recurring_analytic_distribution/static/description/icon.png

Before

Width: 128  |  Height: 128  |  Size: 6.1 KiB

After

Width: 128  |  Height: 128  |  Size: 6.1 KiB

0
contract_recurring_plans/static/description/icon.svg → contract_recurring_analytic_distribution/static/description/icon.svg

2
contract_recurring_plans/models/__init__.py → contract_recurring_analytic_distribution/tests/__init__.py

@ -2,4 +2,4 @@
# (c) 2015 Serv. Tecnol. Avanzados - Pedro M. Baeza
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html
from . import account_analytic_invoice_line
from . import test_contract_recurring_distribution

69
contract_recurring_analytic_distribution/tests/test_contract_recurring_distribution.py

@ -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)

15
contract_recurring_analytic_distribution/views/account_analytic_invoice_line_view.xml

@ -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>

5
contract_recurring_plans/tests/__init__.py

@ -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

47
contract_recurring_plans/tests/test_contract_recurring_plans.py

@ -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)

17
contract_recurring_plans/views/account_analytic_invoice_line_view.xml

@ -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>

1
oca_dependencies.txt

@ -14,5 +14,6 @@
# To provide both the URL and a branch, use:
# sale-workflow https://github.com/OCA/sale-workflow branchname
account-analytic
account-invoicing
bank-payment
Loading…
Cancel
Save