diff --git a/contract_recurring_invoicing_marker/models/account_analytic_account.py b/contract_recurring_invoicing_marker/models/account_analytic_account.py index a134d75e..b4828584 100644 --- a/contract_recurring_invoicing_marker/models/account_analytic_account.py +++ b/contract_recurring_invoicing_marker/models/account_analytic_account.py @@ -24,6 +24,12 @@ class AccountAnalyticAccount(models.Model): obj = self.with_context(old_date=old_date, next_date=new_date) return super(AccountAnalyticAccount, obj)._prepare_invoice(contract) + @api.model + def _insert_markers(self, line, date_start, date_end, date_format): + line = line.replace('#START#', date_start.strftime(date_format)) + line = line.replace('#END#', date_end.strftime(date_format)) + return line + @api.model def _prepare_invoice_line(self, line, invoice_id): res = super(AccountAnalyticAccount, self)._prepare_invoice_line( @@ -34,8 +40,7 @@ class AccountAnalyticAccount(models.Model): lang = lang_obj.search( [('code', '=', contract.partner_id.lang)]) date_format = lang.date_format or '%d/%M/%Y' - res['name'] = res['name'].replace( - '#START#', self.env.context['old_date'].strftime(date_format)) - res['name'] = res['name'].replace( - '#END#', self.env.context['next_date'].strftime(date_format)) + res['name'] = self._insert_markers( + res['name'], self.env.context['old_date'], + self.env.context['next_date'], date_format) return res diff --git a/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml b/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml index 5bc87358..fbbd330b 100644 --- a/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml +++ b/contract_recurring_invoicing_marker/views/account_analytic_account_view.xml @@ -8,7 +8,7 @@ - + #START#: Start date of the invoiced period #END#: End date of the invoiced period
#START#: Start date of the invoiced period
#END#: End date of the invoiced period