Browse Source
[REM] contract_discount/contrac_journal/contract_show_recurring_invoice
[REM] contract_discount/contrac_journal/contract_show_recurring_invoice
These modules have been integrated in the new contract module, which is itself an extraction of the recurring invoicing feature from Odoo's v8 account_analytic_analysis module. As in v9 a similar option has been included in enterprise, but not in community version, this migration to v9 will serve as base for the suscription functionality.pull/32/head
Pedro M. Baeza
9 years ago
32 changed files with 0 additions and 1043 deletions
-
60contract_discount/README.rst
-
3contract_discount/__init__.py
-
38contract_discount/__openerp__.py
-
38contract_discount/i18n/contract_discount.pot
-
41contract_discount/i18n/en.po
-
41contract_discount/i18n/es.po
-
42contract_discount/i18n/pt_BR.po
-
42contract_discount/i18n/sl.po
-
2contract_discount/models/__init__.py
-
52contract_discount/models/contract.py
-
49contract_discount/test/contract_discount.yml
-
3contract_discount/tests/__init__.py
-
59contract_discount/tests/test_contract_discount.py
-
19contract_discount/views/contract_view.xml
-
52contract_journal/README.rst
-
2contract_journal/__init__.py
-
38contract_journal/__openerp__.py
-
28contract_journal/i18n/es.po
-
2contract_journal/models/__init__.py
-
30contract_journal/models/contract.py
-
84contract_journal/test/contract_journal.yml
-
42contract_journal/views/contract_view.xml
-
57contract_show_recurring_invoice/README.rst
-
10contract_show_recurring_invoice/__init__.py
-
40contract_show_recurring_invoice/__openerp__.py
-
37contract_show_recurring_invoice/i18n/contract_show_recurring_invoice.pot
-
37contract_show_recurring_invoice/i18n/es.po
-
3contract_show_recurring_invoice/models/__init__.py
-
14contract_show_recurring_invoice/models/contract.py
-
11contract_show_recurring_invoice/models/invoice.py
-
35contract_show_recurring_invoice/test/contract_show_recurring_invoice_test.yml
-
32contract_show_recurring_invoice/views/contract_view.xml
@ -1,60 +0,0 @@ |
|||||
.. 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 |
|
||||
|
|
||||
================= |
|
||||
Contract Discount |
|
||||
================= |
|
||||
|
|
||||
This module was written to extend the functionality of contracts to support to |
|
||||
set a discount on contract invoice lines. |
|
||||
|
|
||||
Configuration |
|
||||
============= |
|
||||
|
|
||||
To configure this module, you need to go to settings -> Configuration -> |
|
||||
Sales and activate "Allow setting a discount on the sales order lines" to see |
|
||||
discount in contracts. |
|
||||
|
|
||||
Usage |
|
||||
===== |
|
||||
|
|
||||
.. 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 |
|
||||
|
|
||||
For further information, please visit: |
|
||||
|
|
||||
* https://www.odoo.com/forum/help-1 |
|
||||
|
|
||||
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:%20contract_discount%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|
||||
|
|
||||
Credits |
|
||||
======= |
|
||||
|
|
||||
Contributors |
|
||||
------------ |
|
||||
|
|
||||
* Ángel Moya <angel.moya@domatix.com> |
|
||||
|
|
||||
|
|
||||
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. |
|
@ -1,3 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from . import models |
|
||||
from . import tests |
|
@ -1,38 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
############################################################################### |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# Copyright (C) 2015 Domatix (<www.domatix.com>). |
|
||||
# |
|
||||
# This program is free software: you can redistribute it and/or modify |
|
||||
# it under the terms of the GNU Affero General Public License as |
|
||||
# published by the Free Software Foundation, either version 3 of the |
|
||||
# License, or (at your option) any later version. |
|
||||
# |
|
||||
# This program is distributed in the hope that it will be useful, |
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
# GNU Affero General Public License for more details. |
|
||||
# |
|
||||
# You should have received a copy of the GNU Affero General Public License |
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
############################################################################### |
|
||||
|
|
||||
{ |
|
||||
'name': 'Contract Discount', |
|
||||
'summary': 'Discounts for contracts and their invoices', |
|
||||
'version': '8.0.1.0.0', |
|
||||
'author': 'Domatix, Odoo Community Association (OCA)', |
|
||||
'website': 'http://www.domatix.com', |
|
||||
'depends': ['account_analytic_analysis'], |
|
||||
'category': 'Sales Management', |
|
||||
'license': 'AGPL-3', |
|
||||
'data': [ |
|
||||
'views/contract_view.xml', |
|
||||
], |
|
||||
'test': ['test/contract_discount.yml'], |
|
||||
'installable': False, |
|
||||
'auto_install': False, |
|
||||
} |
|
@ -1,38 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_discount |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: Odoo Server 8.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-16 15:14+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-16 15:14+0000\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: \n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Plural-Forms: \n" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: model:ir.model,name:contract_discount.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: field:account.analytic.invoice.line,discount:0 |
|
||||
msgid "Discount (%)" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: code:addons/contract_discount/models/contract.py:40 |
|
||||
#, python-format |
|
||||
msgid "Discount should be less or equal to 100" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: help:account.analytic.invoice.line,discount:0 |
|
||||
msgid "Discount that is applied in generated invoices. It should be less or equal to 100" |
|
||||
msgstr "" |
|
||||
|
|
@ -1,41 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_discount |
|
||||
# |
|
||||
# Translators: |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: contract (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-18 10:33+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 10:33+0000\n" |
|
||||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" |
|
||||
"Language-Team: English (http://www.transifex.com/oca/OCA-contract-8-0/language/en/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: en\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: model:ir.model,name:contract_discount.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "Analytic Account" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: field:account.analytic.invoice.line,discount:0 |
|
||||
msgid "Discount (%)" |
|
||||
msgstr "Discount (%)" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: code:addons/contract_discount/models/contract.py:41 |
|
||||
#, python-format |
|
||||
msgid "Discount should be less or equal to 100" |
|
||||
msgstr "Discount should be less or equal to 100" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: help:account.analytic.invoice.line,discount:0 |
|
||||
msgid "" |
|
||||
"Discount that is applied in generated invoices. It should be less or equal " |
|
||||
"to 100" |
|
||||
msgstr "Discount that is applied in generated invoices. It should be less or equal to 100" |
|
@ -1,41 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_discount |
|
||||
# |
|
||||
# Translators: |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: contract (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-18 10:33+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 10:34+0000\n" |
|
||||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>\n" |
|
||||
"Language-Team: Spanish (http://www.transifex.com/oca/OCA-contract-8-0/language/es/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: es\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: model:ir.model,name:contract_discount.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "Cuenta analítica" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: field:account.analytic.invoice.line,discount:0 |
|
||||
msgid "Discount (%)" |
|
||||
msgstr "Descuento (%)" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: code:addons/contract_discount/models/contract.py:41 |
|
||||
#, python-format |
|
||||
msgid "Discount should be less or equal to 100" |
|
||||
msgstr "El descuento debe ser menor o igual que 100" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: help:account.analytic.invoice.line,discount:0 |
|
||||
msgid "" |
|
||||
"Discount that is applied in generated invoices. It should be less or equal " |
|
||||
"to 100" |
|
||||
msgstr "El descuento se aplica en las facturas generadas. Debe ser menor o igual que 100" |
|
@ -1,42 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_discount |
|
||||
# |
|
||||
# Translators: |
|
||||
# Armando Vulcano Junior <vulcano@uol.com.br>, 2015 |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: contract (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-18 10:33+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-18 20:02+0000\n" |
|
||||
"Last-Translator: Armando Vulcano Junior <vulcano@uol.com.br>\n" |
|
||||
"Language-Team: Portuguese (Brazil) (http://www.transifex.com/oca/OCA-contract-8-0/language/pt_BR/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Language: pt_BR\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: model:ir.model,name:contract_discount.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "Conta Analítica" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: field:account.analytic.invoice.line,discount:0 |
|
||||
msgid "Discount (%)" |
|
||||
msgstr "Desconto (%)" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: code:addons/contract_discount/models/contract.py:41 |
|
||||
#, python-format |
|
||||
msgid "Discount should be less or equal to 100" |
|
||||
msgstr "Desconto deve ser inferior ou igual a 100" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: help:account.analytic.invoice.line,discount:0 |
|
||||
msgid "" |
|
||||
"Discount that is applied in generated invoices. It should be less or equal " |
|
||||
"to 100" |
|
||||
msgstr "Desconto que é aplicado em faturas geradas. Ele deve ser inferior ou igual a 100" |
|
@ -1,42 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_discount |
|
||||
# |
|
||||
# Translators: |
|
||||
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015 |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: contract (8.0)\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-09-23 16:26+0000\n" |
|
||||
"PO-Revision-Date: 2015-09-26 07:11+0000\n" |
|
||||
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n" |
|
||||
"Language-Team: Slovenian (http://www.transifex.com/oca/OCA-contract-8-0/language/sl/)\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"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_discount |
|
||||
#: model:ir.model,name:contract_discount.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "Analitični konto" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: field:account.analytic.invoice.line,discount:0 |
|
||||
msgid "Discount (%)" |
|
||||
msgstr "Popust (%)" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: code:addons/contract_discount/models/contract.py:41 |
|
||||
#, python-format |
|
||||
msgid "Discount should be less or equal to 100" |
|
||||
msgstr "Popust mora biti enak ali manjši od 100" |
|
||||
|
|
||||
#. module: contract_discount |
|
||||
#: help:account.analytic.invoice.line,discount:0 |
|
||||
msgid "" |
|
||||
"Discount that is applied in generated invoices. It should be less or equal " |
|
||||
"to 100" |
|
||||
msgstr "Popust, ki se aplicira na ustvarjene račune. Biti mora enak ali manjši od 100" |
|
@ -1,2 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from . import contract |
|
@ -1,52 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from openerp import models, fields, api |
|
||||
from openerp.addons.decimal_precision import decimal_precision as dp |
|
||||
from openerp.exceptions import ValidationError |
|
||||
|
|
||||
from openerp.tools.translate import _ |
|
||||
|
|
||||
from openerp.osv import fields as old_fields |
|
||||
|
|
||||
|
|
||||
class AccountAnalyticInvoiceLine(models.Model): |
|
||||
_inherit = "account.analytic.invoice.line" |
|
||||
|
|
||||
def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict, |
|
||||
context=None): |
|
||||
res = super(AccountAnalyticInvoiceLine, self)._amount_line( |
|
||||
cr, uid, ids, prop, unknow_none, unknow_dict, context=context) |
|
||||
for line in self.browse(cr, uid, ids, context=context): |
|
||||
discount = (line.discount or 0) / 100 |
|
||||
res[line.id] = res[line.id] * (1 - discount) |
|
||||
return res |
|
||||
|
|
||||
discount = fields.Float( |
|
||||
string='Discount (%)', |
|
||||
digits=dp.get_precision('Discount'), |
|
||||
copy=True, |
|
||||
help='Discount that is applied in generated invoices.' |
|
||||
' It should be less or equal to 100') |
|
||||
|
|
||||
_columns = { |
|
||||
'price_subtotal': old_fields.function( |
|
||||
_amount_line, string='Sub Total', |
|
||||
type="float", |
|
||||
digits_compute=dp.get_precision('Account')), |
|
||||
} |
|
||||
|
|
||||
@api.one |
|
||||
@api.constrains('discount') |
|
||||
def _check_discount(self): |
|
||||
if self.discount > 100: |
|
||||
raise ValidationError(_("Discount should be less or equal to 100")) |
|
||||
|
|
||||
|
|
||||
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) |
|
||||
res['discount'] = line.discount or 0 |
|
||||
return res |
|
@ -1,49 +0,0 @@ |
|||||
- |
|
||||
In order to test Contract Recurrent Invoice I create a new Contract with 25% discount |
|
||||
- |
|
||||
!record {model: account.analytic.account, id: contract_main_25}: |
|
||||
name: Maintenance of Servers |
|
||||
company_id: base.main_company |
|
||||
partner_id: base.main_partner |
|
||||
type: contract |
|
||||
recurring_invoices : 1 |
|
||||
recurring_interval : 1 |
|
||||
recurring_invoice_line_ids: |
|
||||
- quantity: 2.0 |
|
||||
price_unit: 100.0 |
|
||||
discount: 25.0 |
|
||||
name: Database Administration 25 |
|
||||
product_id: product.product_product_consultant |
|
||||
uom_id: product.product_uom_hour |
|
||||
- quantity: 2.0 |
|
||||
price_unit: 100.0 |
|
||||
discount: 50.0 |
|
||||
name: Database Administration 50 |
|
||||
product_id: product.product_product_consultant |
|
||||
uom_id: product.product_uom_hour |
|
||||
- |
|
||||
I test the contract |
|
||||
- |
|
||||
!python {model: account.analytic.account}: | |
|
||||
aid = ref('contract_discount.contract_main_25') |
|
||||
contract = self.browse(cr, uid, aid,context=context) |
|
||||
assert contract.recurring_invoice_line_ids[0].discount == 25, "The line discount (%s)is different than 25!"%(contract.recurring_invoice_line_ids[0].discount,) |
|
||||
assert contract.recurring_invoice_line_ids[0].price_subtotal == 150.0, "The price subtotal (%s)is different than 150!"%(contract.recurring_invoice_line_ids[0].price_subtotal,) |
|
||||
assert contract.recurring_invoice_line_ids[1].discount == 50, "The line discount (%s)is different than 50!"%(contract.recurring_invoice_line_ids[1].discount,) |
|
||||
assert contract.recurring_invoice_line_ids[1].price_subtotal == 100, "The price subtotal (%s)is different than 100!"%(contract.recurring_invoice_line_ids[1].price_subtotal,) |
|
||||
- |
|
||||
I generate all invoices from contracts having recurring invoicing |
|
||||
- |
|
||||
!python {model: account.analytic.account}: | |
|
||||
self.recurring_create_invoice(cr, uid, []) |
|
||||
- |
|
||||
I test the generated invoice |
|
||||
- |
|
||||
!python {model: account.invoice}: | |
|
||||
aid = ref('contract_discount.contract_main_25') |
|
||||
ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context) |
|
||||
assert len(ids)>=1, 'No invoice created for the contract' |
|
||||
for invoice in self.browse(cr, uid, ids,context=context): |
|
||||
assert invoice.invoice_line[0].discount == 25, "The invoice discount (%s)is different than 25!"%(invoice.invoice_line[0].discount,) |
|
||||
assert invoice.invoice_line[1].discount == 50, "The invoice discount (%s)is different than 50!"%(invoice.invoice_line[1].discount,) |
|
||||
assert invoice.amount_untaxed == 250.0, "The invoice total (%s)is different than 250!"%(invoice.amount_untaxed,) |
|
@ -1,3 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
from . import test_contract_discount |
|
@ -1,59 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
import openerp.tests.common as common |
|
||||
from openerp.exceptions import ValidationError |
|
||||
|
|
||||
|
|
||||
def create_simple_contract(self, discount=0): |
|
||||
|
|
||||
partner_id = self.ref('base.res_partner_2') |
|
||||
product_id = self.ref('product.product_product_consultant') |
|
||||
uom_id = self.ref('product.product_uom_hour') |
|
||||
|
|
||||
line_values = [(0, 0, {'quantity': 2.0, |
|
||||
'price_unit': 100.0, |
|
||||
'discount': discount, |
|
||||
'name': 'Database Administration 25', |
|
||||
'product_id': product_id, |
|
||||
'uom_id': uom_id, |
|
||||
})] |
|
||||
values = { |
|
||||
'name': 'Maintenance of Servers', |
|
||||
'partner_id': partner_id, |
|
||||
'type': 'contract', |
|
||||
'recurring_invoices': 1, |
|
||||
'recurring_interval': 1, |
|
||||
'recurring_invoice_line_ids': line_values, |
|
||||
} |
|
||||
|
|
||||
return self.env['account.analytic.account']\ |
|
||||
.create(values) |
|
||||
|
|
||||
|
|
||||
class TestContractDiscount(common.TransactionCase): |
|
||||
|
|
||||
def setUp(self): |
|
||||
super(TestContractDiscount, self).setUp() |
|
||||
|
|
||||
def test_create_simple_contract_without_discount(self): |
|
||||
"""Create contract without discount""" |
|
||||
create_simple_contract(self) |
|
||||
|
|
||||
def test_create_simple_contract_with_discount(self): |
|
||||
"""Create contract with discount""" |
|
||||
create_simple_contract(self, 50) |
|
||||
create_simple_contract(self, 100) |
|
||||
|
|
||||
def test_create_simple_contract_with_negative_discount(self): |
|
||||
"""Create contract with negative discount""" |
|
||||
create_simple_contract(self, -10) |
|
||||
|
|
||||
def test_discount_greater_than_100_error(self): |
|
||||
"""Create or write contract with greater than 100 discount""" |
|
||||
contract = create_simple_contract(self) |
|
||||
lines = contract.recurring_invoice_line_ids |
|
||||
with self.assertRaises(ValidationError): |
|
||||
lines.write({'discount': 110}) |
|
||||
|
|
||||
with self.assertRaises(ValidationError): |
|
||||
create_simple_contract(self, 150) |
|
@ -1,19 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<openerp> |
|
||||
<data> |
|
||||
|
|
||||
<record id="account_analytic_account_form_extension_form" model="ir.ui.view"> |
|
||||
<field name="name">account.analytic.account.invoice.form.extension.form |
|
||||
</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"> |
|
||||
<xpath expr="//field[@name='price_unit']" position="after"> |
|
||||
<field name="discount" groups="sale.group_discount_per_so_line" /> |
|
||||
</xpath> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
</data> |
|
||||
</openerp> |
|
@ -1,52 +0,0 @@ |
|||||
.. 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 |
|
||||
|
|
||||
======================== |
|
||||
Contract Invoice Journal |
|
||||
======================== |
|
||||
|
|
||||
This module allows to set a sales account journal for creating the invoices on it. |
|
||||
|
|
||||
Usage |
|
||||
===== |
|
||||
|
|
||||
.. 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 |
|
||||
|
|
||||
For further information, please visit: |
|
||||
|
|
||||
* https://www.odoo.com/forum/help-1 |
|
||||
|
|
||||
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:%20contract_journal%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|
||||
|
|
||||
Credits |
|
||||
======= |
|
||||
|
|
||||
Contributors |
|
||||
------------ |
|
||||
|
|
||||
* Ángel Moya <angel.moya@domatix.com> |
|
||||
|
|
||||
|
|
||||
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. |
|
@ -1,2 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from . import models |
|
@ -1,38 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
############################################################################### |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# Copyright (C) 2015 Domatix (<www.domatix.com>). |
|
||||
# |
|
||||
# This program is free software: you can redistribute it and/or modify |
|
||||
# it under the terms of the GNU Affero General Public License as |
|
||||
# published by the Free Software Foundation, either version 3 of the |
|
||||
# License, or (at your option) any later version. |
|
||||
# |
|
||||
# This program is distributed in the hope that it will be useful, |
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
# GNU Affero General Public License for more details. |
|
||||
# |
|
||||
# You should have received a copy of the GNU Affero General Public License |
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
############################################################################### |
|
||||
|
|
||||
{ |
|
||||
'name': 'Contract Invoice Journal', |
|
||||
'summary': 'Invoice Journal in contracts and their invoices', |
|
||||
'version': '8.0.1.0.0', |
|
||||
'author': 'Domatix, Odoo Community Association (OCA)', |
|
||||
'website': 'http://www.domatix.com', |
|
||||
'depends': ['account_analytic_analysis'], |
|
||||
'category': 'Sales Management', |
|
||||
'license': 'AGPL-3', |
|
||||
'data': [ |
|
||||
'views/contract_view.xml', |
|
||||
], |
|
||||
'test': ['test/contract_journal.yml'], |
|
||||
'installable': False, |
|
||||
'auto_install': False, |
|
||||
} |
|
@ -1,28 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_journal |
|
||||
# angel <angel.moya@domatix.com>, 2015. |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: Odoo Server 8.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-06-12 12:20+0000\n" |
|
||||
"PO-Revision-Date: 2015-06-22 11:43+0100\n" |
|
||||
"Last-Translator: angel <angel.moya@domatix.com>\n" |
|
||||
"Language-Team: Domatix\n" |
|
||||
"Language: es\n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: 8bit\n" |
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|
||||
"X-Generator: Poedit 1.5.4\n" |
|
||||
|
|
||||
#. module: contract_journal |
|
||||
#: model:ir.model,name:contract_journal.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "Cuenta analítica" |
|
||||
|
|
||||
#. module: contract_journal |
|
||||
#: field:account.analytic.account,journal_id:0 |
|
||||
msgid "Journal" |
|
||||
msgstr "Diario" |
|
@ -1,2 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from . import contract |
|
@ -1,30 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from openerp import models, fields, api |
|
||||
|
|
||||
|
|
||||
class AccountAnalyticAccount(models.Model): |
|
||||
_inherit = 'account.analytic.account' |
|
||||
|
|
||||
@api.model |
|
||||
def _default_journal(self): |
|
||||
company_id = self.env.context.get( |
|
||||
'company_id', self.env.user.company_id.id) |
|
||||
domain = [ |
|
||||
('type', '=', 'sale'), |
|
||||
('company_id', '=', company_id)] |
|
||||
return self.env['account.journal'].search(domain, limit=1) |
|
||||
|
|
||||
journal_id = fields.Many2one( |
|
||||
'account.journal', |
|
||||
string='Journal', |
|
||||
default=_default_journal, |
|
||||
domain="[('type', '=', 'sale'),('company_id', '=', company_id)]") |
|
||||
|
|
||||
@api.model |
|
||||
def _prepare_invoice_data(self, contract): |
|
||||
invoice_vals = super(AccountAnalyticAccount, self).\ |
|
||||
_prepare_invoice_data( |
|
||||
contract) |
|
||||
if contract.journal_id: |
|
||||
invoice_vals['journal_id'] = contract.journal_id.id |
|
||||
return invoice_vals |
|
@ -1,84 +0,0 @@ |
|||||
- |
|
||||
In order to test contract invoice journal create a contract with sale invoice journal |
|
||||
- |
|
||||
!record {model: account.analytic.account, id: contract_sale_journal}: |
|
||||
name: Maintenance of Servers |
|
||||
company_id: base.main_company |
|
||||
partner_id: base.main_partner |
|
||||
journal_id: account.sales_journal |
|
||||
type: contract |
|
||||
recurring_invoices : 1 |
|
||||
recurring_interval : 1 |
|
||||
recurring_invoice_line_ids: |
|
||||
- quantity: 2.0 |
|
||||
price_unit: 100.0 |
|
||||
name: Database Administration 25 |
|
||||
product_id: product.product_product_consultant |
|
||||
uom_id: product.product_uom_hour |
|
||||
- |
|
||||
I create a new custom journal |
|
||||
- |
|
||||
!record {model: account.journal, id: custom_journal}: |
|
||||
name: Custom Sales Journal |
|
||||
code: CSAJ |
|
||||
type: sale |
|
||||
sequence_id: account.sequence_sale_journal |
|
||||
default_credit_account_id: account.a_sale |
|
||||
default_debit_account_id: account.a_sale |
|
||||
analytic_journal_id: account.analytic_journal_sale |
|
||||
user_id: base.user_root |
|
||||
- |
|
||||
Create a contract with custom invoice journal |
|
||||
- |
|
||||
!record {model: account.analytic.account, id: contract_custom_journal}: |
|
||||
name: Maintenance of Servers |
|
||||
company_id: base.main_company |
|
||||
partner_id: base.main_partner |
|
||||
journal_id: contract_journal.custom_journal |
|
||||
type: contract |
|
||||
recurring_invoices : 1 |
|
||||
recurring_interval : 1 |
|
||||
recurring_invoice_line_ids: |
|
||||
- quantity: 2.0 |
|
||||
price_unit: 100.0 |
|
||||
name: Database Administration 25 |
|
||||
product_id: product.product_product_consultant |
|
||||
uom_id: product.product_uom_hour |
|
||||
- |
|
||||
I test the sale contract |
|
||||
- |
|
||||
!python {model: account.analytic.account}: | |
|
||||
aid = ref('contract_journal.contract_sale_journal') |
|
||||
contract = self.browse(cr, uid, aid,context=context) |
|
||||
assert contract.journal_id.id == ref('account.sales_journal'), "Sale Invoice Journal is not correct in contract" |
|
||||
- |
|
||||
I test the custom contract |
|
||||
- |
|
||||
!python {model: account.analytic.account}: | |
|
||||
aid = ref('contract_journal.contract_custom_journal') |
|
||||
contract = self.browse(cr, uid, aid,context=context) |
|
||||
assert contract.journal_id.id == ref('contract_journal.custom_journal'), "Custom Invoice Journal is not correct in contract" |
|
||||
- |
|
||||
I generate all invoices from contracts having recurring invoicing |
|
||||
- |
|
||||
!python {model: account.analytic.account}: | |
|
||||
self.recurring_create_invoice(cr, uid, []) |
|
||||
- |
|
||||
I test the generated invoice for sale journal contract |
|
||||
- |
|
||||
!python {model: account.invoice}: | |
|
||||
aid = ref('contract_journal.contract_sale_journal') |
|
||||
ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context) |
|
||||
assert len(ids)>=1, 'No invoice created for the sale journal contract' |
|
||||
for invoice in self.browse(cr, uid, ids,context=context): |
|
||||
assert invoice.journal_id.id == ref('account.sales_journal'), "Sale Invoice Journal is not correct in invoice" |
|
||||
- |
|
||||
I test the generated invoice for custom journal contract |
|
||||
- |
|
||||
!python {model: account.invoice}: | |
|
||||
aid = ref('contract_journal.contract_custom_journal') |
|
||||
ids = self.search(cr, uid, [('invoice_line.account_analytic_id','=',aid)], context=context) |
|
||||
assert len(ids)>=1, 'No invoice created for the custom journal contract' |
|
||||
for invoice in self.browse(cr, uid, ids,context=context): |
|
||||
assert invoice.journal_id.id == ref('contract_journal.custom_journal'), "Custom Invoice Journal is not correct in invoice" |
|
||||
|
|
@ -1,42 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<openerp> |
|
||||
<data> |
|
||||
|
|
||||
<record id="account_analytic_account_journal_form" model="ir.ui.view"> |
|
||||
<field name="name">account.analytic.account.journal.form</field> |
|
||||
<field name="model">account.analytic.account</field> |
|
||||
<field name="inherit_id" ref="analytic.view_account_analytic_account_form" /> |
|
||||
<field name="arch" type="xml"> |
|
||||
<xpath expr="//field[@name='template_id']" position="before"> |
|
||||
<field name="journal_id" /> |
|
||||
</xpath> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
<!-- Inherited Analytic Account list for contracts --> |
|
||||
<record id="view_account_analytic_account_journal_tree" model="ir.ui.view"> |
|
||||
<field name="name">account.analytic.account.journal.list</field> |
|
||||
<field name="model">account.analytic.account</field> |
|
||||
<field name="inherit_id" ref="account.view_account_analytic_account_list" /> |
|
||||
<field name="arch" type="xml"> |
|
||||
<field name="partner_id" position="before"> |
|
||||
<field name="journal_id" groups="account.group_account_user" /> |
|
||||
</field> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
<!-- Analytic Account search view for contract --> |
|
||||
<record id="view_account_analytic_account_journal_search" model="ir.ui.view"> |
|
||||
<field name="name">account.analytic.account.journal.search</field> |
|
||||
<field name="model">account.analytic.account</field> |
|
||||
<field name="inherit_id" |
|
||||
ref="account_analytic_analysis.view_account_analytic_account_overdue_search" /> |
|
||||
<field name="arch" type="xml"> |
|
||||
<field name="name" position="before"> |
|
||||
<field name="journal_id" /> |
|
||||
</field> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
</data> |
|
||||
</openerp> |
|
@ -1,57 +0,0 @@ |
|||||
.. 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 |
|
||||
|
|
||||
=============================== |
|
||||
Contract Show Recurring Invoice |
|
||||
=============================== |
|
||||
|
|
||||
This module adds a button in contracts to show their recurring invoices. |
|
||||
|
|
||||
Usage |
|
||||
===== |
|
||||
|
|
||||
.. 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 |
|
||||
|
|
||||
For further information, please visit: |
|
||||
|
|
||||
* https://www.odoo.com/forum/help-1 |
|
||||
|
|
||||
Known issues / Roadmap |
|
||||
====================== |
|
||||
|
|
||||
* Add smart button with field that computes the total amount invoiced. |
|
||||
|
|
||||
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:%20contract_show_recurring_invoice%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. |
|
||||
|
|
||||
Credits |
|
||||
======= |
|
||||
|
|
||||
Contributors |
|
||||
------------ |
|
||||
|
|
||||
* Ángel Moya <angel.moya@domatix.com> |
|
||||
|
|
||||
|
|
||||
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. |
|
@ -1,10 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from . import models |
|
||||
|
|
||||
|
|
||||
def copy_recurring_invoice(cr, registry): |
|
||||
"""Copy recurring invoice on contract.""" |
|
||||
cr.execute("UPDATE account_invoice " |
|
||||
"SET contract_id=aaa.id " |
|
||||
"FROM account_analytic_account aaa " |
|
||||
"WHERE aaa.code = account_invoice.origin") |
|
@ -1,40 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
############################################################################### |
|
||||
# |
|
||||
# OpenERP, Open Source Management Solution |
|
||||
# Copyright (C) 2015 Domatix (<www.domatix.com>). |
|
||||
# |
|
||||
# This program is free software: you can redistribute it and/or modify |
|
||||
# it under the terms of the GNU Affero General Public License as |
|
||||
# published by the Free Software Foundation, either version 3 of the |
|
||||
# License, or (at your option) any later version. |
|
||||
# |
|
||||
# This program is distributed in the hope that it will be useful, |
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
# GNU Affero General Public License for more details. |
|
||||
# |
|
||||
# You should have received a copy of the GNU Affero General Public License |
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
||||
# |
|
||||
############################################################################### |
|
||||
{ |
|
||||
'name': 'Contract Show Recurring Invoice', |
|
||||
'summary': 'Button in contracts to show their recurring invoices', |
|
||||
'version': '8.0.1.0.0', |
|
||||
'author': 'Domatix, Odoo Community Association (OCA)', |
|
||||
'website': 'http://www.domatix.com', |
|
||||
'depends': ['account_analytic_analysis'], |
|
||||
'category': 'Sales Management', |
|
||||
'license': 'AGPL-3', |
|
||||
'data': [ |
|
||||
'views/contract_view.xml', |
|
||||
], |
|
||||
'test': [ |
|
||||
'test/contract_show_recurring_invoice_test.yml' |
|
||||
], |
|
||||
"post_init_hook": "copy_recurring_invoice", |
|
||||
'installable': False, |
|
||||
'auto_install': False, |
|
||||
} |
|
@ -1,37 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_show_recurring_invoice |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: Odoo Server 8.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-10-10 16:58+0000\n" |
|
||||
"PO-Revision-Date: 2015-10-10 16:58+0000\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: \n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: \n" |
|
||||
"Plural-Forms: \n" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: model:ir.model,name:contract_show_recurring_invoice.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: model:ir.model,name:contract_show_recurring_invoice.model_account_invoice |
|
||||
msgid "Invoice" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: model:ir.actions.act_window,name:contract_show_recurring_invoice.act_recurring_invoices |
|
||||
msgid "Invoices" |
|
||||
msgstr "" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: view:account.analytic.account:contract_show_recurring_invoice.account_analytic_account_button_recurring_invoice |
|
||||
msgid "⇒ show invoices" |
|
||||
msgstr "" |
|
||||
|
|
@ -1,37 +0,0 @@ |
|||||
# Translation of Odoo Server. |
|
||||
# This file contains the translation of the following modules: |
|
||||
# * contract_show_recurring_invoice |
|
||||
# |
|
||||
msgid "" |
|
||||
msgstr "" |
|
||||
"Project-Id-Version: Odoo Server 8.0\n" |
|
||||
"Report-Msgid-Bugs-To: \n" |
|
||||
"POT-Creation-Date: 2015-10-10 16:58+0000\n" |
|
||||
"PO-Revision-Date: 2015-10-10 19:01+0100\n" |
|
||||
"Last-Translator: <>\n" |
|
||||
"Language-Team: \n" |
|
||||
"MIME-Version: 1.0\n" |
|
||||
"Content-Type: text/plain; charset=UTF-8\n" |
|
||||
"Content-Transfer-Encoding: 8bit\n" |
|
||||
"Plural-Forms: \n" |
|
||||
"X-Generator: Poedit 1.7.5\n" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: model:ir.model,name:contract_show_recurring_invoice.model_account_analytic_account |
|
||||
msgid "Analytic Account" |
|
||||
msgstr "Cuenta analítica" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: model:ir.model,name:contract_show_recurring_invoice.model_account_invoice |
|
||||
msgid "Invoice" |
|
||||
msgstr "Factura" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: model:ir.actions.act_window,name:contract_show_recurring_invoice.act_recurring_invoices |
|
||||
msgid "Invoices" |
|
||||
msgstr "Facturas" |
|
||||
|
|
||||
#. module: contract_show_recurring_invoice |
|
||||
#: view:account.analytic.account:contract_show_recurring_invoice.account_analytic_account_button_recurring_invoice |
|
||||
msgid "⇒ show invoices" |
|
||||
msgstr "⇒ ver facturas" |
|
@ -1,3 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from . import contract |
|
||||
from . import invoice |
|
@ -1,14 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
from openerp import models, api |
|
||||
|
|
||||
|
|
||||
class AccountAnalyticAccount(models.Model): |
|
||||
_inherit = 'account.analytic.account' |
|
||||
|
|
||||
@api.model |
|
||||
def _prepare_invoice_data(self, contract): |
|
||||
invoice_vals = super(AccountAnalyticAccount, self).\ |
|
||||
_prepare_invoice_data( |
|
||||
contract) |
|
||||
invoice_vals['contract_id'] = contract.id |
|
||||
return invoice_vals |
|
@ -1,11 +0,0 @@ |
|||||
# -*- coding: utf-8 -*- |
|
||||
|
|
||||
from openerp import models, fields |
|
||||
|
|
||||
|
|
||||
class AccountInvoice(models.Model): |
|
||||
_inherit = 'account.invoice' |
|
||||
|
|
||||
contract_id = fields.Many2one( |
|
||||
'account.analytic.account', |
|
||||
string='Contract') |
|
@ -1,35 +0,0 @@ |
|||||
- |
|
||||
In order to test Contract Invoices Button I create a new Contract |
|
||||
- |
|
||||
!record {model: account.analytic.account, id: contract_main}: |
|
||||
name: Maintenance of Servers |
|
||||
company_id: base.main_company |
|
||||
partner_id: base.main_partner |
|
||||
type: contract |
|
||||
recurring_invoices : 1 |
|
||||
recurring_interval : 1 |
|
||||
recurring_invoice_line_ids: |
|
||||
- quantity: 2.0 |
|
||||
price_unit: 100.0 |
|
||||
name: Database Administration 25 |
|
||||
product_id: product.product_product_consultant |
|
||||
uom_id: product.product_uom_hour |
|
||||
- |
|
||||
I test the invoices button |
|
||||
- |
|
||||
!python {model: account.invoice}: | |
|
||||
contract_id = ref('contract_show_recurring_invoice.contract_main') |
|
||||
invoices = self.search(cr, uid,[('contract_id','=',contract_id)],context=context) |
|
||||
assert len(invoices) == 0, "No invoices related this contract, but get (%s)"%(invoices,) |
|
||||
- |
|
||||
I generate all invoices from contracts having recurring invoicing |
|
||||
- |
|
||||
!python {model: account.analytic.account}: | |
|
||||
self.recurring_create_invoice(cr, uid, []) |
|
||||
- |
|
||||
I test the invoices button |
|
||||
- |
|
||||
!python {model: account.invoice}: | |
|
||||
contract_id = ref('contract_show_recurring_invoice.contract_main') |
|
||||
invoices = self.search(cr, uid,[('contract_id','=',contract_id)],context=context) |
|
||||
assert len(invoices) == 1, "Must have one invoice related this contract, but get (%s)"%(invoices,) |
|
@ -1,32 +0,0 @@ |
|||||
<?xml version="1.0"?> |
|
||||
<openerp> |
|
||||
<data> |
|
||||
|
|
||||
<record id="act_recurring_invoices" model="ir.actions.act_window"> |
|
||||
<field name="context">{'search_default_contract_id': |
|
||||
[active_id], |
|
||||
'default_contract_id': active_id} |
|
||||
</field> |
|
||||
<field name="name">Invoices</field> |
|
||||
<field name="res_model">account.invoice</field> |
|
||||
<field name="view_id" ref="account.invoice_tree" /> |
|
||||
<field name="search_view_id" ref="account.view_account_invoice_filter" /> |
|
||||
</record> |
|
||||
|
|
||||
<record id="account_analytic_account_button_recurring_invoice" |
|
||||
model="ir.ui.view"> |
|
||||
<field name="name">account.analytic.account.button.invoice |
|
||||
</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"> |
|
||||
<button name="recurring_create_invoice" position="after"> |
|
||||
<button attrs="{'invisible': [('recurring_invoices','!=',True)]}" |
|
||||
name="%(contract_show_recurring_invoice.act_recurring_invoices)d" |
|
||||
string="⇒ show invoices" class="oe_link" type="action"/> |
|
||||
</button> |
|
||||
</field> |
|
||||
</record> |
|
||||
|
|
||||
</data> |
|
||||
</openerp> |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue