diff --git a/contract_invoice_merge_by_partner/README.rst b/contract_invoice_merge_by_partner/README.rst new file mode 100644 index 00000000..2371ab5d --- /dev/null +++ b/contract_invoice_merge_by_partner/README.rst @@ -0,0 +1,63 @@ +.. 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 `_. + +Usage +===== + +#. Go to ... + +.. 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 + +Known issues / Roadmap +====================== + +* If product supplier info min quantity is greater than procurement qty and we + have sale orders with distinct analytic account which contains this product, + each purchase order line takes seller min quantity. + +Bug Tracker +=========== + +Bugs are tracked on `GitHub 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 +* Pedro M. Baeza + +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. diff --git a/contract_invoice_merge_by_partner/__init__.py b/contract_invoice_merge_by_partner/__init__.py new file mode 100644 index 00000000..cfa84f54 --- /dev/null +++ b/contract_invoice_merge_by_partner/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import models diff --git a/contract_invoice_merge_by_partner/__openerp__.py b/contract_invoice_merge_by_partner/__openerp__.py new file mode 100644 index 00000000..f6f67f5f --- /dev/null +++ b/contract_invoice_merge_by_partner/__openerp__.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# 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'], + 'installable': True, +} diff --git a/contract_invoice_merge_by_partner/models/__init__.py b/contract_invoice_merge_by_partner/models/__init__.py new file mode 100644 index 00000000..fc5ce8e9 --- /dev/null +++ b/contract_invoice_merge_by_partner/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import account_analytic_analysis diff --git a/contract_invoice_merge_by_partner/models/account_analytic_analysis.py b/contract_invoice_merge_by_partner/models/account_analytic_analysis.py new file mode 100644 index 00000000..23c46dcf --- /dev/null +++ b/contract_invoice_merge_by_partner/models/account_analytic_analysis.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from openerp import api, models + + +class PurchaseOrderLine(models.Model): + _inherit = 'account.analytic.account' + + @api.multi + def _recurring_create_invoice(self, automatic=False): + invoices = self.env['account.invoice'].browse( + super(PurchaseOrderLine, self)._recurring_create_invoice(automatic) + ) + res = [] + unlink_list = [] + for partner in invoices.mapped('partner_id'): + inv_to_merge = invoices.filtered(lambda x: x.partner_id == partner) + if len(inv_to_merge) > 1: + invoices_info = inv_to_merge.do_merge( + keep_references=True, date_invoice=False) + res.extend(invoices_info.keys()) + for inv_ids_list in invoices_info.values(): + unlink_list.append(inv_ids_list) + else: + res.append(inv_to_merge.id) + return res diff --git a/contract_invoice_merge_by_partner/static/description/icon.png b/contract_invoice_merge_by_partner/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/contract_invoice_merge_by_partner/static/description/icon.png differ diff --git a/contract_invoice_merge_by_partner/tests/__init__.py b/contract_invoice_merge_by_partner/tests/__init__.py new file mode 100644 index 00000000..181cf9bd --- /dev/null +++ b/contract_invoice_merge_by_partner/tests/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_contract_invoice_merge_by_partner diff --git a/contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py b/contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py new file mode 100644 index 00000000..147689c9 --- /dev/null +++ b/contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +# © 2016 Carlos Dauden +# 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()