Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][FIX] assets_management view html report #3348

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions assets_management/report/asset_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError
from odoo.tools.misc import format_amount
from odoo.tools.safe_eval import safe_eval


def format_date(rec, field_name, fmt):
Expand Down Expand Up @@ -95,10 +94,8 @@ def print_report(self, report_type=None):
"""
self.ensure_one()
report_type = report_type or "qweb-pdf"
if report_type in ("qweb-pdf", "xlsx"):
if report_type in ("qweb-pdf", "xlsx", "qweb-html"):
res = self.do_print(report_type)
elif report_type == "qweb-html":
res = self.view_report()
elif report_type:
raise ValidationError(
_("No report has been defined for type `{}`.").format(report_type)
Expand All @@ -113,25 +110,13 @@ def do_print(self, report_type):
self.ensure_one()
if report_type == "qweb-pdf":
xml_id = "assets_management.report_asset_journal_pdf"
elif report_type == "qweb-html":
xml_id = "assets_management.report_asset_journal_html"
else:
xml_id = "assets_management.report_asset_journal_xlsx"
report = self.env.ref(xml_id)
return report.report_action(self)

def view_report(self):
"""Launches view for HTML report"""
self.ensure_one()
xmlid = "assets_management.act_client_asset_journal_report"
[act] = self.env.ref(xmlid).read()
ctx = act.get("context", {})
if isinstance(ctx, str):
ctx = safe_eval(ctx)
# Call update twice to force 'active_id(s)' values to be overridden
ctx.update(dict(self._context))
ctx.update(active_id=self.id, active_ids=self.ids)
act["context"] = ctx
return act

@api.model
def get_html(self, given_context=None):
"""Method needed from JavaScript widget to render HTML view"""
Expand Down
21 changes: 3 additions & 18 deletions assets_management/report/asset_previsional.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from odoo.exceptions import ValidationError
from odoo.tools.float_utils import float_is_zero
from odoo.tools.misc import format_amount
from odoo.tools.safe_eval import safe_eval


def format_date(rec, field_name, fmt):
Expand Down Expand Up @@ -100,10 +99,8 @@ def print_report(self, report_type=None):
"""
self.ensure_one()
report_type = report_type or "qweb-pdf"
if report_type in ("qweb-pdf", "xlsx"):
if report_type in ("qweb-pdf", "xlsx", "qweb-html"):
res = self.do_print(report_type)
elif report_type == "qweb-html":
res = self.view_report()
elif report_type:
raise ValidationError(
_("No report has been defined for type `{}`.").format(report_type)
Expand All @@ -118,25 +115,13 @@ def do_print(self, report_type):
self.ensure_one()
if report_type == "qweb-pdf":
xml_id = "assets_management.report_asset_previsional_pdf"
elif report_type == "qweb-html":
xml_id = "assets_management.report_asset_previsional_html"
else:
xml_id = "assets_management.report_asset_previsional_xlsx"
report = self.env.ref(xml_id)
return report.report_action(self)

def view_report(self):
"""Launches view for HTML report"""
self.ensure_one()
xmlid = "assets_management.act_client_asset_previsional_report"
[act] = self.env.ref(xmlid).read()
ctx = act.get("context", {})
if isinstance(ctx, str):
ctx = safe_eval(ctx)
# Call update twice to force 'active_id(s)' values to be overridden
ctx.update(dict(self._context))
ctx.update(active_id=self.id, active_ids=self.ids)
act["context"] = ctx
return act

@api.model
def get_html(self, given_context=None):
"""Method needed from JavaScript widget to render HTML view"""
Expand Down