mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[9.0][FIX] contract_payment_mode: Payment mode unknow. Improve tests
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# Copyright 2017 Vicent Cubells <vicent.cubells@tecnativa.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import api, fields, models
|
||||
from openerp import api, models
|
||||
|
||||
|
||||
class AccountAnalyticAccount(models.Model):
|
||||
@@ -12,23 +12,16 @@ class AccountAnalyticAccount(models.Model):
|
||||
|
||||
@api.multi
|
||||
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']
|
||||
invoices = super(
|
||||
AccountAnalyticAccount, self).recurring_create_invoice()
|
||||
invoices_info = {}
|
||||
invoices2unlink = AccountInvoice = 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:
|
||||
invoices2merge.do_merge()
|
||||
invoices_info.update(invoices2merge.do_merge())
|
||||
invoices2unlink += invoices2merge
|
||||
invoices -= invoices2unlink
|
||||
invoices2unlink.unlink()
|
||||
return True
|
||||
return invoices | AccountInvoice.browse(invoices_info.keys())
|
||||
|
||||
Reference in New Issue
Block a user