Browse Source

[IMP] contract_recurring_invoicing_marker: Better inherability

pull/38/head
Pedro M. Baeza 9 years ago
parent
commit
7ae3a5e6aa
  1. 13
      contract_recurring_invoicing_marker/models/account_analytic_account.py
  2. 2
      contract_recurring_invoicing_marker/views/account_analytic_account_view.xml

13
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

2
contract_recurring_invoicing_marker/views/account_analytic_account_view.xml

@ -8,7 +8,7 @@
<field name="inherit_id" ref="account_analytic_analysis.account_analytic_account_form_form"/>
<field name="arch" type="xml">
<field name="recurring_invoice_line_ids" position="after">
<group string="Legend (for the markers inside invoice lines description)">
<group string="Legend (for the markers inside invoice lines description)" name="group_legend">
<p colspan="2"> <strong>#START#</strong>: Start date of the invoiced period</p>
<p colspan="2"> <strong>#END#</strong>: End date of the invoiced period</p>
</group>

Loading…
Cancel
Save