Revert "[FIX] *: reports: check required values for 'render_html'"
This is not how you check that a dict contains keys.
This also break the contract of method `get_html` that may now return
`None`, which `get_pdf` does not handle.
This reverts commit 0d2fb541e8.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models, _
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import float_is_zero
|
||||
from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
@@ -197,9 +196,6 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or ('active_model', 'active_id') not in self.env.context.keys():
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
total = []
|
||||
model = self.env.context.get('active_model')
|
||||
docs = self.env[model].browse(self.env.context.get('active_id'))
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportTrialBalance(models.AbstractModel):
|
||||
@@ -58,9 +57,6 @@ class ReportTrialBalance(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model'):
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
self.model = self.env.context.get('active_model')
|
||||
docs = self.env[self.model].browse(self.env.context.get('active_ids', []))
|
||||
display_account = data['form'].get('display_account')
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportGeneralLedger(models.AbstractModel):
|
||||
@@ -110,9 +109,6 @@ class ReportGeneralLedger(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model'):
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
self.model = self.env.context.get('active_model')
|
||||
docs = self.env[self.model].browse(self.env.context.get('active_ids', []))
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportJournal(models.AbstractModel):
|
||||
@@ -96,9 +95,6 @@ class ReportJournal(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form'):
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
target_move = data['form'].get('target_move', 'all')
|
||||
sort_selection = data['form'].get('sort_selection', 'date')
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from datetime import datetime
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
|
||||
|
||||
@@ -70,9 +69,6 @@ class ReportPartnerLedger(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form'):
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
data['computed'] = {}
|
||||
|
||||
obj_partner = self.env['res.partner']
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportFinancial(models.AbstractModel):
|
||||
@@ -145,9 +144,6 @@ class ReportFinancial(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or ('active_model', 'active_id') not in self.env.context.keys():
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
self.model = self.env.context.get('active_model')
|
||||
docs = self.env[self.model].browse(self.env.context.get('active_id'))
|
||||
report_lines = self.get_account_lines(data.get('form'))
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
from datetime import timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class HrHolidaySummaryReport(models.AbstractModel):
|
||||
@@ -103,9 +102,6 @@ class HrHolidaySummaryReport(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form'):
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
Report = self.env['report']
|
||||
holidays_report = Report._get_report_from_name('hr_holidays.report_holidayssummary')
|
||||
holidays = self.env['hr.holidays'].browse(self.ids)
|
||||
|
||||
@@ -6,7 +6,6 @@ from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ContributionRegisterReport(models.AbstractModel):
|
||||
@@ -30,9 +29,6 @@ class ContributionRegisterReport(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form'):
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
register_ids = self.env.context.get('active_ids', [])
|
||||
contrib_registers = self.env['hr.contribution.register'].browse(register_ids)
|
||||
date_from = data['form'].get('date_from', fields.Date.today())
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
from datetime import date
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportHrSalaryEmployeeBymonth(models.AbstractModel):
|
||||
@@ -94,9 +93,6 @@ class ReportHrSalaryEmployeeBymonth(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or ('active_model', 'active_id') not in self.env.context.keys():
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
model = self.env.context.get('active_model')
|
||||
docs = self.env[model].browse(self.env.context.get('active_id'))
|
||||
get_periods, months, total_mnths = self.get_periods(data['form'])
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
from datetime import date
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class EmployeesYearlySalaryReport(models.AbstractModel):
|
||||
@@ -128,9 +127,6 @@ class EmployeesYearlySalaryReport(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if ('active_model', 'active_id') not in self.env.context.keys():
|
||||
raise UserError(_("Some data are missing, this report cannot be printed."))
|
||||
|
||||
model = self.env.context.get('active_model')
|
||||
docs = self.env[model].browse(self.env.context.get('active_id'))
|
||||
docargs = {
|
||||
|
||||
@@ -132,10 +132,7 @@ class Report(models.Model):
|
||||
report_model = self.env.get(report_model_name)
|
||||
|
||||
if report_model is not None:
|
||||
try:
|
||||
return report_model.render_html(docids, data=data)
|
||||
except UserError as e:
|
||||
_logger.warning("%s: %s", report_name, e.name)
|
||||
return report_model.render_html(docids, data=data)
|
||||
else:
|
||||
report = self._get_report_from_name(report_name)
|
||||
docs = self.env[report.model].browse(docids)
|
||||
|
||||
Reference in New Issue
Block a user