Skip to content

Commit

Permalink
[FIX] Migrazione PR OCA#3348 per stampa report html
Browse files Browse the repository at this point in the history
  • Loading branch information
odooNextev committed Jul 7, 2023
1 parent f96e47f commit cd4db79
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 57 deletions.
1 change: 0 additions & 1 deletion l10n_it_asset_management/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"report/templates/asset_journal.xml",
"report/templates/asset_previsional.xml",
"report/reports.xml",
"views/action_client.xml",
"views/asset_menuitems.xml",
"views/account_move.xml",
"views/asset.xml",
Expand Down
23 changes: 3 additions & 20 deletions l10n_it_asset_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,11 @@ def do_print(self, report_type):
self.ensure_one()
if report_type == "qweb-pdf":
xml_id = "l10n_it_asset_management.report_asset_journal_pdf"
else:
xml_id = "l10n_it_asset_management.report_asset_journal_xlsx"
elif report_type == "qweb-html":
xml_id = "l10n_it_asset_management.report_asset_journal_html"
report = self.env.ref(xml_id)
return report.report_action(self)

def view_report(self):
"""Launches view for HTML report"""
self.ensure_one()
xmlid = "l10n_it_asset_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
23 changes: 3 additions & 20 deletions l10n_it_asset_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,11 @@ def do_print(self, report_type):
self.ensure_one()
if report_type == "qweb-pdf":
xml_id = "l10n_it_asset_management.report_asset_previsional_pdf"
else:
xml_id = "l10n_it_asset_management.report_asset_previsional_xlsx"
elif report_type == "qweb-html":
xml_id = "l10n_it_asset_management.report_asset_previsional_html"
report = self.env.ref(xml_id)
return report.report_action(self)

def view_report(self):
"""Launches view for HTML report"""
self.ensure_one()
xmlid = "l10n_it_asset_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
16 changes: 0 additions & 16 deletions l10n_it_asset_management/views/action_client.xml

This file was deleted.

0 comments on commit cd4db79

Please sign in to comment.