diff --git a/contract_invoice_merge_by_partner/i18n/es.po b/contract_invoice_merge_by_partner/i18n/es.po index b8c2a890..0c2a8e7f 100644 --- a/contract_invoice_merge_by_partner/i18n/es.po +++ b/contract_invoice_merge_by_partner/i18n/es.po @@ -1,33 +1,37 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: -# * contract_invoice_merge_by_partner +# * contract_invoice_merge_by_partner # msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-06-14 13:16+0000\n" -"PO-Revision-Date: 2016-06-14 15:19+0100\n" -"Last-Translator: Carlos Dauden \n" -"Language-Team: Tecnativa \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: 8bit\n" -"X-Generator: Poedit 1.5.4\n" -"Language: es_ES\n" -"X-Poedit-SourceCharset: 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 "Contract invoice merge" -msgstr "Fusionar facturas de contratos" +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" + diff --git a/contract_invoice_merge_by_partner/models/account_analytic_analysis.py b/contract_invoice_merge_by_partner/models/account_analytic_analysis.py index 8d300c5b..0fcb6dfb 100644 --- a/contract_invoice_merge_by_partner/models/account_analytic_analysis.py +++ b/contract_invoice_merge_by_partner/models/account_analytic_analysis.py @@ -1,30 +1,29 @@ # -*- coding: utf-8 -*- # © 2016 Carlos Dauden +# © 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp import api, models -class PurchaseOrderLine(models.Model): +class AccountAnalyticAccount(models.Model): _inherit = 'account.analytic.account' @api.multi def _recurring_create_invoice(self, automatic=False): - invoice_obj = self.env['account.invoice'] - invoices = invoice_obj.browse( - super(PurchaseOrderLine, self)._recurring_create_invoice( - automatic)) + invoice_ids = super( + AccountAnalyticAccount, self)._recurring_create_invoice(automatic) + invoices = self.env['account.invoice'].browse(invoice_ids) res = [] - unlink_list = [] + invoices2unlink = self.env['account.invoice'] for partner in invoices.mapped('partner_id'): - inv_to_merge = invoices.filtered( - lambda x: x.partner_id.id == partner) - if partner.contract_invoice_merge and len(inv_to_merge) > 1: - invoices_merged = inv_to_merge.do_merge() - res.extend(invoices_merged) - unlink_list.extend(inv_to_merge) + 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.extend(inv_to_merge) - if unlink_list: - invoice_obj.browse(unlink_list).unlink() + res += invoices2merge.ids + invoices2unlink.unlink() return res diff --git a/contract_invoice_merge_by_partner/models/res_partner.py b/contract_invoice_merge_by_partner/models/res_partner.py index 34cc712e..2f50523f 100644 --- a/contract_invoice_merge_by_partner/models/res_partner.py +++ b/contract_invoice_merge_by_partner/models/res_partner.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- # © 2016 Carlos Dauden +# © 2016 Pedro M. Baeza # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from openerp import fields, models @@ -8,4 +9,7 @@ from openerp import fields, models class ResPartner(models.Model): _inherit = 'res.partner' - contract_invoice_merge = fields.Boolean() + 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.") 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 index 225a8041..b45150d6 100644 --- 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 @@ -9,11 +9,11 @@ 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.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({