[FIX] snailmail: instable behaviour on print
Since commit b6a981405e we require a
certain key in the context to apply the custom snailmail report layout.
This was badly managed and would eventually confilt inside the modal
that links snailmail and the mail composer.
This fix stabilises the biehaviour by properly propagating the context
key.
This commit is contained in:
@@ -6,14 +6,6 @@ from odoo import models, fields, api, _
|
||||
class IrActionsReport(models.Model):
|
||||
_inherit = 'ir.actions.report'
|
||||
|
||||
@api.model
|
||||
def _get_rendering_context(self, docids, data):
|
||||
res = super(IrActionsReport, self)._get_rendering_context(docids, data)
|
||||
# Add snailmail_layout if specified in the context
|
||||
if self.env.context.get('snailmail_layout'):
|
||||
res.update({'snailmail_layout': True})
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def get_paperformat(self):
|
||||
# force the right format (euro/A4) when sending letters, only if we are not using the l10n_DE layout
|
||||
|
||||
@@ -8,6 +8,12 @@ class Contact(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def value_to_html(self, value, options):
|
||||
snailmail_layout = options['template_options'].get('snailmail_layout')
|
||||
value = value.with_context(snailmail_layout=snailmail_layout)
|
||||
if self.env.context.get('snailmail_layout'):
|
||||
value = value.with_context(snailmail_layout=self.env.context['snailmail_layout'])
|
||||
return super(Contact, self).value_to_html(value, options)
|
||||
|
||||
@api.model
|
||||
def record_to_html(self, record, field_name, options):
|
||||
if self.env.context.get('snailmail_layout'):
|
||||
record = record.with_context(snailmail_layout=self.env.context['snailmail_layout'])
|
||||
return super(Contact, self).record_to_html(record, field_name, options)
|
||||
|
||||
Reference in New Issue
Block a user