cubells
8 years ago
10 changed files with 80 additions and 52 deletions
-
11contract_invoice_merge_by_partner/README.rst
-
2contract_invoice_merge_by_partner/__init__.py
-
10contract_invoice_merge_by_partner/__openerp__.py
-
2contract_invoice_merge_by_partner/models/__init__.py
-
31contract_invoice_merge_by_partner/models/account_analytic_analysis.py
-
4contract_invoice_merge_by_partner/models/res_partner.py
-
2contract_invoice_merge_by_partner/tests/__init__.py
-
43contract_invoice_merge_by_partner/tests/test_contract_invoice_merge_by_partner.py
-
11contract_invoice_merge_by_partner/views/res_partner_view.xml
-
2oca_dependencies.txt
@ -1,5 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# Copyright 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import models |
@ -1,5 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# Copyright 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from . import account_analytic_analysis |
|||
|
@ -1,29 +1,34 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# © 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# Copyright 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# Copyright 2016 Pedro M. Baeza <pedro.baeza@tecnativa.com> |
|||
# Copyright 2017 Vicent Cubells <vicent.cubells@tecnativa.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
|||
|
|||
from openerp import api, models |
|||
from openerp import api, fields, 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 = [] |
|||
def recurring_create_invoice(self): |
|||
contracts = self.search( |
|||
[('recurring_next_date', '<=', fields.Date.today()), |
|||
('account_type', '=', 'normal'), |
|||
('recurring_invoices', '=', True)] |
|||
) |
|||
res = super(AccountAnalyticAccount, self).recurring_create_invoice() |
|||
if not contracts: |
|||
return res |
|||
invoices = self.env['account.invoice'].search([ |
|||
('contract_id', 'in', contracts.ids) |
|||
]) |
|||
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() |
|||
invoices2merge.do_merge() |
|||
invoices2unlink += invoices2merge |
|||
else: |
|||
res += invoices2merge.ids |
|||
invoices2unlink.unlink() |
|||
return res |
|||
return True |
@ -1,5 +1,5 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# © 2016 Carlos Dauden <carlos.dauden@tecnativa.com> |
|||
# Copyright 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 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue