|
@ -176,9 +176,7 @@ class AccountAnalyticAccount(models.Model): |
|
|
return { |
|
|
return { |
|
|
'reference': self.code, |
|
|
'reference': self.code, |
|
|
'type': invoice_type, |
|
|
'type': invoice_type, |
|
|
'partner_id': self.partner_id.address_get(['invoice'])[ |
|
|
|
|
|
'invoice' |
|
|
|
|
|
], |
|
|
|
|
|
|
|
|
'partner_id': self.partner_id.address_get(['invoice'])['invoice'], |
|
|
'currency_id': currency.id, |
|
|
'currency_id': currency.id, |
|
|
'date_invoice': date_invoice, |
|
|
'date_invoice': date_invoice, |
|
|
'journal_id': journal.id, |
|
|
'journal_id': journal.id, |
|
@ -236,11 +234,13 @@ class AccountAnalyticAccount(models.Model): |
|
|
price_unit = invoice_line.price_unit |
|
|
price_unit = invoice_line.price_unit |
|
|
invoice_line.invoice_id = new_invoice |
|
|
invoice_line.invoice_id = new_invoice |
|
|
invoice_line._onchange_product_id() |
|
|
invoice_line._onchange_product_id() |
|
|
invoice_line.update({ |
|
|
|
|
|
|
|
|
invoice_line.update( |
|
|
|
|
|
{ |
|
|
'name': name, |
|
|
'name': name, |
|
|
'account_analytic_id': account_analytic_id, |
|
|
'account_analytic_id': account_analytic_id, |
|
|
'price_unit': price_unit, |
|
|
'price_unit': price_unit, |
|
|
}) |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
return new_invoice._convert_to_write(new_invoice._cache) |
|
|
return new_invoice._convert_to_write(new_invoice._cache) |
|
|
|
|
|
|
|
|
@api.model |
|
|
@api.model |
|
@ -264,7 +264,8 @@ class AccountAnalyticAccount(models.Model): |
|
|
final_invoices_values = [] |
|
|
final_invoices_values = [] |
|
|
for invoice_values in invoices_values: |
|
|
for invoice_values in invoices_values: |
|
|
final_invoices_values.append( |
|
|
final_invoices_values.append( |
|
|
self._finalize_invoice_values(invoice_values)) |
|
|
|
|
|
|
|
|
self._finalize_invoice_values(invoice_values) |
|
|
|
|
|
) |
|
|
invoices = self.env['account.invoice'].create(final_invoices_values) |
|
|
invoices = self.env['account.invoice'].create(final_invoices_values) |
|
|
self._finalize_invoice_creation(invoices) |
|
|
self._finalize_invoice_creation(invoices) |
|
|
return invoices |
|
|
return invoices |
|
@ -297,11 +298,11 @@ class AccountAnalyticAccount(models.Model): |
|
|
:return: contract lines (account.analytic.invoice.line recordset) |
|
|
:return: contract lines (account.analytic.invoice.line recordset) |
|
|
""" |
|
|
""" |
|
|
self.ensure_one() |
|
|
self.ensure_one() |
|
|
if date_ref: |
|
|
|
|
|
return self.recurring_invoice_line_ids.filtered( |
|
|
return self.recurring_invoice_line_ids.filtered( |
|
|
lambda l: not l.is_canceled and l.recurring_next_date |
|
|
|
|
|
and l.recurring_next_date <= date_ref) |
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
lambda l: not l.is_canceled |
|
|
|
|
|
and l.recurring_next_date |
|
|
|
|
|
and l.recurring_next_date <= date_ref |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
@api.multi |
|
|
@api.multi |
|
|
def _prepare_recurring_invoices_values(self, date_ref=False): |
|
|
def _prepare_recurring_invoices_values(self, date_ref=False): |
|
@ -315,6 +316,10 @@ class AccountAnalyticAccount(models.Model): |
|
|
for contract in self: |
|
|
for contract in self: |
|
|
if not date_ref: |
|
|
if not date_ref: |
|
|
date_ref = contract.recurring_next_date |
|
|
date_ref = contract.recurring_next_date |
|
|
|
|
|
if not date_ref: |
|
|
|
|
|
# this use case is possible when recurring_create_invoice is |
|
|
|
|
|
# called for a finished contract |
|
|
|
|
|
continue |
|
|
contract_lines = contract._get_lines_to_invoice(date_ref) |
|
|
contract_lines = contract._get_lines_to_invoice(date_ref) |
|
|
if not contract_lines: |
|
|
if not contract_lines: |
|
|
continue |
|
|
continue |
|
|