[FIX] *: reports: check required values for 'render_html'
Some reports require additional information to render. When accessed in Odoo, the user has to fill a wizard to provide those information. However, when these reports were opened in Studio, it crashed as those information were missing (we don't pass through the configuration wizard in this case). This fix checks if all the required information are given before trying to render those reports, and it displays a warning in the logs in they are missing, which is better than a traceback. backported in v10 for opw-753036
This commit is contained in:
committed by
Jeremy Kersten
parent
11270336fa
commit
7a1d2d1c4c
@@ -2,6 +2,7 @@
|
||||
|
||||
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
|
||||
@@ -196,6 +197,9 @@ class ReportAgedPartnerBalance(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model') or not self.env.context.get('active_id'):
|
||||
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,6 +2,7 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportTrialBalance(models.AbstractModel):
|
||||
@@ -59,6 +60,9 @@ 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,6 +2,7 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportGeneralLedger(models.AbstractModel):
|
||||
@@ -109,6 +110,9 @@ 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,6 +2,7 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportJournal(models.AbstractModel):
|
||||
@@ -95,6 +96,9 @@ 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,6 +3,7 @@
|
||||
from datetime import datetime
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
|
||||
|
||||
@@ -69,6 +70,9 @@ 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,6 +2,7 @@
|
||||
|
||||
import time
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportFinancial(models.AbstractModel):
|
||||
@@ -144,6 +145,9 @@ class ReportFinancial(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model') or not self.env.context.get('active_id'):
|
||||
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,6 +4,7 @@
|
||||
from datetime import timedelta
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class HrHolidaySummaryReport(models.AbstractModel):
|
||||
@@ -102,6 +103,9 @@ 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,6 +6,7 @@ from datetime import datetime
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
from odoo import api, fields, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ContributionRegisterReport(models.AbstractModel):
|
||||
@@ -29,6 +30,9 @@ 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,6 +4,7 @@
|
||||
from datetime import date
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class ReportHrSalaryEmployeeBymonth(models.AbstractModel):
|
||||
@@ -93,6 +94,9 @@ class ReportHrSalaryEmployeeBymonth(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not data.get('form') or not self.env.context.get('active_model') or not self.env.context.get('active_id'):
|
||||
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,6 +4,7 @@
|
||||
from datetime import date
|
||||
|
||||
from odoo import api, models
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class EmployeesYearlySalaryReport(models.AbstractModel):
|
||||
@@ -127,6 +128,9 @@ class EmployeesYearlySalaryReport(models.AbstractModel):
|
||||
|
||||
@api.model
|
||||
def render_html(self, docids, data=None):
|
||||
if not self.env.context.get('active_model') or not self.env.context.get('active_id'):
|
||||
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 = {
|
||||
|
||||
Reference in New Issue
Block a user