Skip to content
Snippets Groups Projects

Enhance substitution handling in ir.actions.report with value_type support

Merged oury.balde requested to merge topic/18.0/RED-593-FSB into branch/18.0
Files
3
+ 18
25
@@ -36,7 +36,8 @@
file.
"""
_inherit = "ir.actions.report"
_inherit = ["ir.actions.report", "substitution.mixin"]
_name = "ir.actions.report"
@api.constrains("redner_filetype", "report_type")
def _check_redner_filetype(self):
@@ -111,30 +112,6 @@
filetype = rec.redner_filetype
rec.is_redner_native_format = fmt.get_format(filetype).native
def action_get_substitutions(self):
"""Call by: action button `Get Substitutions from Redner Report`"""
self.ensure_one()
if self.redner_tmpl_id:
keywords = self.redner_tmpl_id.get_keywords()
# Get current substitutions
subs = self.substitution_ids.mapped("keyword") or []
values = []
for key in keywords:
# check to avoid duplicate keys
if key not in subs:
values.append((0, 0, {"keyword": key}))
self.write({"substitution_ids": values})
# remove obsolete keywords in substitutions model
if len(self.substitution_ids) > len(keywords):
deprecated_keys = self.substitution_ids.filtered(
lambda s: s.keyword not in keywords
)
if len(deprecated_keys) > 0:
deprecated_keys.unlink()
def get_report_metadata(self):
self.ensure_one()
@@ -239,3 +216,19 @@
attachment_vals["name"],
)
return buffer
# -------------------------------------------------------------------------
# MIXIN METHODS
# -------------------------------------------------------------------------
def _get_substitution_field(self):
"""Return the substitution field name for ir.actions.report."""
return "substitution_ids"
def _get_template(self):
"""Get template for ir.actions.report."""
return self.redner_tmpl_id
def _get_substitutions(self):
"""Get substitutions for ir.actions.report."""
return self.substitution_ids
Loading