Pedro M. Baeza
8 years ago
12 changed files with 246 additions and 0 deletions
-
65contract_invoice_merge_by_partner/README.rst
-
5contract_invoice_merge_by_partner/__init__.py
-
20contract_invoice_merge_by_partner/__openerp__.py
-
37contract_invoice_merge_by_partner/i18n/es.po
-
6contract_invoice_merge_by_partner/models/__init__.py
-
29contract_invoice_merge_by_partner/models/account_analytic_analysis.py
-
15contract_invoice_merge_by_partner/models/res_partner.py
-
BINcontract_invoice_merge_by_partner/static/description/icon.png
-
5contract_invoice_merge_by_partner/tests/__init__.py
-
44contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py
-
19contract_invoice_merge_by_partner/views/res_partner_view.xml
-
1oca_dependencies.txt
@ -0,0 +1,65 @@ |
|||
.. 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 Merge By Partner |
|||
================================= |
|||
|
|||
This module merges same partner invoices generated by contracts. |
|||
|
|||
Installation |
|||
============ |
|||
|
|||
To install this module you need *account_invoice_merge*, available in: |
|||
|
|||
* Install repository `OCA/account-invoicing <https://github.com/OCA/account-invoicing>`_. |
|||
|
|||
Usage |
|||
===== |
|||
|
|||
#. Go to *Sales > Customer* choose a partner and in the tab "Sales & Purchases" |
|||
activate checkbox " Merge contracts invoices " |
|||
#. Go to *Sales > Contracts* and create some contracts with same partner you |
|||
activated checkbox " Merge contracts invoices " |
|||
#. Go to *Settings > Automation > Scheduled Actions* |
|||
#. Select *Generate Recurring Invoices from Contracts* |
|||
#. Set previous time that now in *Next Execution Date* |
|||
#. Go to *Invoicing > Customer Invoices* and show merged invoice |
|||
|
|||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas |
|||
:alt: Try me on Runbot |
|||
:target: https://runbot.odoo-community.org/runbot/95/8.0 |
|||
|
|||
|
|||
Bug Tracker |
|||
=========== |
|||
|
|||
Bugs are tracked on `GitHub Issues |
|||
<https://github.com/OCA/account-invoicing/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. |
|||
|
|||
Credits |
|||
======= |
|||
|
|||
Contributors |
|||
------------ |
|||
* Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
* Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
* Rafael Blasco <rafael.blasco@tecnativa.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. |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import models |
@ -0,0 +1,20 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
{ |
|||
'name': 'Contract Invoice Merge By Partner', |
|||
'summary': 'This module merges same partner invoices generated by ' |
|||
'contracts', |
|||
'version': '8.0.1.0.0', |
|||
'category': 'Account', |
|||
'license': 'AGPL-3', |
|||
'author': "Tecnativa, " |
|||
"Odoo Community Association (OCA)", |
|||
'website': 'http://www.tecnativa.com', |
|||
'depends': ['account_analytic_analysis', 'account_invoice_merge'], |
|||
'data': [ |
|||
'views/res_partner_view.xml', |
|||
], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,37 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * contract_invoice_merge_by_partner |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 8.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2016-07-21 23:35+0000\n" |
|||
"PO-Revision-Date: 2016-07-21 23:35+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_invoice_merge_by_partner |
|||
#: model:ir.model,name:contract_invoice_merge_by_partner.model_account_analytic_account |
|||
msgid "Analytic Account" |
|||
msgstr "Cuenta analítica" |
|||
|
|||
#. module: contract_invoice_merge_by_partner |
|||
#: help:res.partner,contract_invoice_merge:0 |
|||
msgid "If checked, all the recurring invoices generated by the contracts of this partner will be merged on each run." |
|||
msgstr "Si está marcado, todas las facturas recurrentes generadas por los contratos de esta empresa serán fusionados en cada generación." |
|||
|
|||
#. module: contract_invoice_merge_by_partner |
|||
#: field:res.partner,contract_invoice_merge:0 |
|||
msgid "Merge contracts invoices" |
|||
msgstr "Fusionar las facturas de los contratos" |
|||
|
|||
#. module: contract_invoice_merge_by_partner |
|||
#: model:ir.model,name:contract_invoice_merge_by_partner.model_res_partner |
|||
msgid "Partner" |
|||
msgstr "Empresa" |
|||
|
@ -0,0 +1,6 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import account_analytic_analysis |
|||
from . import res_partner |
@ -0,0 +1,29 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import api, models |
|||
|
|||
|
|||
class AccountAnalyticAccount(models.Model): |
|||
_inherit = 'account.analytic.account' |
|||
|
|||
@api.multi |
|||
def _recurring_create_invoice(self, automatic=False): |
|||
invoice_ids = super( |
|||
AccountAnalyticAccount, self)._recurring_create_invoice(automatic) |
|||
invoices = self.env['account.invoice'].browse(invoice_ids) |
|||
res = [] |
|||
invoices2unlink = self.env['account.invoice'] |
|||
for partner in invoices.mapped('partner_id'): |
|||
invoices2merge = invoices.filtered( |
|||
lambda x: x.partner_id == partner) |
|||
if partner.contract_invoice_merge and len(invoices2merge) > 1: |
|||
result = invoices2merge.do_merge() |
|||
res += result.keys() |
|||
invoices2unlink += invoices2merge |
|||
else: |
|||
res += invoices2merge.ids |
|||
invoices2unlink.unlink() |
|||
return res |
@ -0,0 +1,15 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import fields, models |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
_inherit = 'res.partner' |
|||
|
|||
contract_invoice_merge = fields.Boolean( |
|||
string="Merge contracts invoices", |
|||
help="If checked, all the recurring invoices generated by the " |
|||
"contracts of this partner will be merged on each run.") |
After Width: 128 | Height: 128 | Size: 9.2 KiB |
@ -0,0 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import test_contract_invoice_merge_by_partner |
@ -0,0 +1,44 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp.tests.common import TransactionCase |
|||
|
|||
|
|||
class TestContractInvoiceMergeByPartner(TransactionCase): |
|||
""" Use case : Prepare some data for current test case """ |
|||
def setUp(self): |
|||
super(TestContractInvoiceMergeByPartner, self).setUp() |
|||
self.partner = self.env['res.partner'].create({ |
|||
'customer': True, |
|||
'name': "Test Customer", |
|||
'contract_invoice_merge': True, |
|||
}) |
|||
self.product = self.env.ref('product.product_product_consultant') |
|||
self.uom = self.env.ref('product.product_uom_hour') |
|||
self.contract1 = self.env['account.analytic.account'].create({ |
|||
'name': 'Test contract', |
|||
'partner_id': self.partner.id, |
|||
'type': 'contract', |
|||
'recurring_invoices': True, |
|||
'recurring_rule_type': 'monthly', |
|||
'recurring_interval': 1, |
|||
'recurring_invoice_line_ids': [ |
|||
(0, 0, {'quantity': 2.0, |
|||
'price_unit': 100.0, |
|||
'name': self.product.name, |
|||
'product_id': self.product.id, |
|||
'uom_id': self.uom.id})], |
|||
}) |
|||
self.contract2 = self.contract1.copy() |
|||
self.contract3 = self.contract1.copy() |
|||
self.contract4 = self.contract1.copy() |
|||
|
|||
def test_invoices_merged(self): |
|||
self.env['account.analytic.account']._recurring_create_invoice() |
|||
invoices = self.env['account.invoice'].search( |
|||
[('partner_id', '=', self.partner.id)]) |
|||
inv_draft = invoices.filtered(lambda x: x.state == 'draft') |
|||
self.assertEqual(len(inv_draft), 1) |
|||
inv_cancel = invoices.filtered(lambda x: x.state == 'cancel') |
|||
self.assertFalse(inv_cancel) |
@ -0,0 +1,19 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<!-- © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). --> |
|||
<openerp> |
|||
<data> |
|||
|
|||
<record id="view_partner_form" model="ir.ui.view"> |
|||
<field name="name">Partner Form Contract Invoice Merge</field> |
|||
<field name="model">res.partner</field> |
|||
<field name="inherit_id" ref="base.view_partner_form"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="user_id" position="after"> |
|||
<field name="contract_invoice_merge"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
|
|||
</data> |
|||
</openerp> |
@ -1 +1,2 @@ |
|||
account-invoicing |
|||
bank-payment |
Write
Preview
Loading…
Cancel
Save
Reference in new issue