Pedro M. Baeza
8 years ago
4 changed files with 39 additions and 32 deletions
-
26contract_invoice_merge_by_partner/i18n/es.po
-
29contract_invoice_merge_by_partner/models/account_analytic_analysis.py
-
6contract_invoice_merge_by_partner/models/res_partner.py
-
10contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py
@ -1,33 +1,37 @@ |
|||||
# Translation of Odoo Server. |
# Translation of Odoo Server. |
||||
# This file contains the translation of the following modules: |
# This file contains the translation of the following modules: |
||||
# * contract_invoice_merge_by_partner |
|
||||
|
# * contract_invoice_merge_by_partner |
||||
# |
# |
||||
msgid "" |
msgid "" |
||||
msgstr "" |
msgstr "" |
||||
"Project-Id-Version: Odoo Server 8.0\n" |
"Project-Id-Version: Odoo Server 8.0\n" |
||||
"Report-Msgid-Bugs-To: \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 <carlos.dauden@tecnativa.com>\n" |
|
||||
"Language-Team: Tecnativa <info@tecnativa.com>\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" |
"MIME-Version: 1.0\n" |
||||
"Content-Type: text/plain; charset=UTF-8\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 |
#. module: contract_invoice_merge_by_partner |
||||
#: model:ir.model,name:contract_invoice_merge_by_partner.model_account_analytic_account |
#: model:ir.model,name:contract_invoice_merge_by_partner.model_account_analytic_account |
||||
msgid "Analytic Account" |
msgid "Analytic Account" |
||||
msgstr "Cuenta analítica" |
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 |
#. module: contract_invoice_merge_by_partner |
||||
#: field:res.partner,contract_invoice_merge:0 |
#: 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 |
#. module: contract_invoice_merge_by_partner |
||||
#: model:ir.model,name:contract_invoice_merge_by_partner.model_res_partner |
#: model:ir.model,name:contract_invoice_merge_by_partner.model_res_partner |
||||
msgid "Partner" |
msgid "Partner" |
||||
msgstr "Empresa" |
msgstr "Empresa" |
||||
|
|
@ -1,30 +1,29 @@ |
|||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
# © 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). |
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
from openerp import api, models |
from openerp import api, models |
||||
|
|
||||
|
|
||||
class PurchaseOrderLine(models.Model): |
|
||||
|
class AccountAnalyticAccount(models.Model): |
||||
_inherit = 'account.analytic.account' |
_inherit = 'account.analytic.account' |
||||
|
|
||||
@api.multi |
@api.multi |
||||
def _recurring_create_invoice(self, automatic=False): |
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 = [] |
res = [] |
||||
unlink_list = [] |
|
||||
|
invoices2unlink = self.env['account.invoice'] |
||||
for partner in invoices.mapped('partner_id'): |
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: |
else: |
||||
res.extend(inv_to_merge) |
|
||||
if unlink_list: |
|
||||
invoice_obj.browse(unlink_list).unlink() |
|
||||
|
res += invoices2merge.ids |
||||
|
invoices2unlink.unlink() |
||||
return res |
return res |
Write
Preview
Loading…
Cancel
Save
Reference in new issue