I already managed to get the wizard window up, but when I make this call:
return self.env.ref('flota.action_resumen_report').report_action(self)
it give External ID flota.action_resumen_report
my xml report now is
<report
id="action_resumen_report"
string="Resumen de viajes"
model="flota.resumen.viajes"
report_type="qweb-pdf"
name="flota.print_resumen_report"
file="flota.print_resumen_report"
menu="False"/>
<template id="print_resumen_report">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="resumen_viajes">
<t t-call="web.external_layout">
<div class="page">
<div class="col-sm-6">
<table border="0" align="center" style="font-size:16pt;">
<tr >
<td align="center" valign="center" colspan="6">
RESUMEN DE LOS VIAJES
</td>
</tr>
<tr><td colspan="6" style="height:10pt;"></td></tr>
<tr >
<td align="left" colspan="2">
<label><strong>Año:</strong></label>
<t t-esc="resumen_viajes.anno"/>
<label>---</label>
<label><strong>Mes:</strong></label>
<t t-esc="resumen_viajes.mes"/>
</td>
<td colspan="4"></td>
</tr>
<tr>
<td valign="right" colspan="6">
<table class="table table-bordered mb32" style="table-layout:auto;font-size:14pt;">
<tr>
<td><strong>Centro de Costo</strong></td>
<td colspan="3" align="center"><strong>Viajes Planificados</strong>
</td>
<td colspan="3" align="center"><strong>Viajes Imprevistos</strong>
</td>
<td ><strong>Viajes de Servicios </strong></td>
<td ><strong>% Cumpl Transp. </strong></td>
</tr>
<tr > <td style="border-top:0;"></td>
<td><strong>Solicitados </strong></td>
<td><strong>Susp/Transp </strong></td>
<td><strong>Susp/Área </strong></td>
<td><strong>Solicitados </strong></td>
<td><strong>Susp/Transp </strong></td>
<td><strong>Susp/Área </strong></td>
<td style="border-top:0;"></td>
<td></td>
</tr>
<t t-foreach="resumen_viajes._get_Solicitudes()" t-as="centro_name">
<tr colspan="2"><td > <div style="font-size:14pt;margin-bottom:5pt;" ><t t-esc="centro_name"/></div></td>
<td ><div style="font-size:14pt;" ><t t-esc="resumen_viajes._get_Total_SolicitudesP(centro_name)"/></div></td>
<td ><div style="font-size:14pt;" ><t t-esc="resumen_viajes._get_Total_Transporte_Plan(centro_name)"/></div></td>
<td > <div style="font-size:14pt;" ><t t-esc="resumen_viajes._get_Total_Area_Plan(centro_name)"/></div></td>
<td ><div style="font-size:14pt;" ><t t-esc="resumen_viajes._get_Total_SolicitudesI(centro_name)"/></div></td>
<td ><div style="font-size:14pt;" ><t t-esc="resumen_viajes._getTotal_Suspendidos_Transporte_Im(centro_name)"/></div></td>
<td ><div style="font-size:14pt;" ><t t-esc="resumen_viajes._getTotal_Suspendidos_Area_Im(centro_name)"/></div></td>
<td > <div style="font-size:14pt;" ><t t-esc="resumen_viajes._get_Total_Solici_Serv(centro_name)"/></div></td>
<td ><div style="font-size:14pt;" ><t t-esc="resumen_viajes._get_porciento(centro_name)"/></div></td>
</tr>
<tr>
</tr>
</t>
<tr>
<td><strong>Total</strong></td>
<td><strong><t t-esc="resumen_viajes._get_Total_Final_SolicitudesP()" /></strong></td>
<td><strong><t t-esc="resumen_viajes._get_Total_Final_Transporte_Plan()"/></strong></td>
<td><strong><t t-esc="resumen_viajes._get_TotalFinal_Area_Plan()" /></strong></td>
<td><strong><t t-esc="resumen_viajes._get_Total_Final_SolicitudesI()"/></strong></td>
<td><strong><t t-esc="resumen_viajes._getTotal_Final_Suspendidos_Transporte_Im()"/></strong></td>
<td><strong><t t-esc="resumen_viajes._getTotal_Final_Suspendidos_Area_Im()"/></strong></td>
<td ><strong><t t-esc="resumen_viajes._get_Total_Final_Solici_Serv()"/> </strong></td>
<td ><strong><t t-esc="resumen_viajes._get_Total_porciento()"/></strong></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo>
my class py
class FlotaSolicitudResumenViajes(models.TransientModel):
_name = 'flota.resumen.viajes'
anno = fields.Char(string="Año", default=datetime.now().year, size=4)
mes = fields.Selection([
('1', 'Enero'),
('2', 'Febrero'),
('3', 'Marzo'),
('4', 'Abril'),
('5', 'Mayo'),
('6', 'Junio'),
('7', 'Julio'),
('8', 'Agosto'),
('9', 'Septiembre'),
('10', 'Octubre'),
('11', 'Noviembre'),
('12', 'Diciembre')
], string='Mes', default=str(datetime.now().month))
def print_report(self):
return self.env.ref('flota.action_resumen_report').report_action(self)
# RESUMEN DE VIAJES
@api.depends('anno', 'mes')
def _get_Solicitudes(self):
centros_costo = []
for record in self:
sql_query = """Select centro_name from flota_solicitud where mes = """ + repr(
record.mes) + " and anno = " + repr(record.anno) + " group by centro_name "
self.env.cr.execute(sql_query, (record.id,))
for c in self.env.cr.dictfetchall():
centros_costo.append(c.get('centro_name'),
)
return centros_costo
def _get_Total_Final_SolicitudesP(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'planificado')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_SolicitudesP(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'planificado')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_Area_Plan(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'planificado'),
('causa', '=', 'area')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_TotalFinal_Area_Plan(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'planificado'),
('causa', '=', 'area')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_Transporte_Plan(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'planificado'),
('causa', '=', 'transporte')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_Final_Transporte_Plan(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'planificado'),
('causa', '=', 'transporte')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_Solici_Serv(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'servicios'),
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_Final_Solici_Serv(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'servicios'),
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_SolicitudesI(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'imprevisto')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_Total_Final_SolicitudesI(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'imprevisto')
])
for a in flota_solicitudes:
total = total + 1
return total
def _getTotal_Suspendidos_Area_Im(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'imprevisto'),
('causa', '=', 'area')
])
for a in flota_solicitudes:
total = total + 1
return total
def _getTotal_Final_Suspendidos_Area_Im(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'imprevisto'),
('causa', '=', 'area')
])
for a in flota_solicitudes:
total = total + 1
return total
def _getTotal_Suspendidos_Transporte_Im(self, centro_name):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('centro_name', '=', centro_name),
('tipo_viaje', '=', 'imprevisto'),
('causa', '=', 'transporte')
])
for a in flota_solicitudes:
total = total + 1
return total
def _getTotal_Final_Suspendidos_Transporte_Im(self):
total = 0
flota_solicitudes = self.env['flota.solicitud']
for record in self:
flota_solicitudes = flota_solicitudes | self.env['flota.solicitud'].search([
('anno', '=', record.anno),
('mes', '=', record.mes),
('tipo_viaje', '=', 'imprevisto'),
('causa', '=', 'transporte')
])
for a in flota_solicitudes:
total = total + 1
return total
def _get_porciento(self, centro_name):
total = 0
total_transporte = 0
causa = 'transporte'
porciento_cumplimiento = 100
for record in self:
self._cr.execute("""Select * from flota_solicitud where mes = """ +
repr(record.mes) + " and anno = " + repr(record.anno) +
" and centro_name = " + repr(centro_name))
data_total = self._cr.dictfetchall()
for a in data_total:
total += 1
self._cr.execute("""Select * from flota_solicitud where mes = """ +
repr(record.mes) + " and anno = " + repr(record.anno) +
"and causa = " + repr(causa) +
" and centro_name = " + repr(centro_name))
data_total_t = self._cr.dictfetchall()
for a in data_total_t:
total_transporte += 1
if total_transporte != 0:
porciento_cumplimiento = (total - total_transporte) / total * 100
return round(porciento_cumplimiento, 2)
def _get_Total_porciento(self):
total = 0
total_transporte = 0
causa = 'transporte'
porciento_cumplimiento = 100
for record in self:
self._cr.execute("""Select * from flota_solicitud where mes = """ +
repr(record.mes) + " and anno = " + repr(record.anno))
data_total = self._cr.dictfetchall()
for a in data_total:
total += 1
self._cr.execute("""Select * from flota_solicitud where mes = """ +
repr(record.mes) + " and anno = " + repr(record.anno) +
"and causa = " + repr(causa))
data_total_t = self._cr.dictfetchall()
for a in data_total_t:
total_transporte += 1
if total_transporte != 0:
porciento_cumplimiento = (total - total_transporte) / total * 100
return round(porciento_cumplimiento, 2)
My views
<!--REPORTE PDF-->
<record model="ir.ui.view" id="solicitud_resumen_form">
<field name="name">flota.resumen.viajes.wizard</field>
<field name="model">flota.resumen.viajes</field>
<field name="arch" type="xml">
<form string="Resumen de viajes" >
<group >
<field name="anno" />
<field name="mes" />
</group>
<footer>
<button name="print_report" string="Generar" type="object" default_focus="1" class="oe_highlight"/>
or
<button string="Cancel" class="btn btn-secondary" special="cancel" />
</footer>
</form>
</field>
</record>
<act_window id="action_flota_resumen_viaje"
name="Resumen de viajes PDF"
res_model="flota.resumen.viajes"
binding_model="flota.solicitud"
binding_type="report"
view_mode="form" target="new" />
thanks a lot for your cooperation!!!
It would be more helpful if you post the error/traceback as well.
This is Error/traceback
Odoo Server Error
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\cache.py", line 85, in lookup
r = d[key]
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\func.py", line 69, in wrapper
return func(self, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\lru.py", line 44, in __getitem__
a = self.d[obj].me
KeyError: ('ir.model.data', <function IrModelData.xmlid_lookup at 0x05944588>, 'flota.resumen_viaje_report')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 713, in parse
self._tag_root(de)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 675, in _tag_root
f(rec)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 564, in _tag_record
f_val = _eval_xml(self, field, env)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 143, in _eval_xml
+_process("".join(etree.tostring(n, encoding='unicode') for n in node))
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 132, in _process
self.idref[id] = self.id_get(id)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 658, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 664, in model_id_get
return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_model.py", line 1659, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-24>", line 2, in xmlid_lookup
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_model.py", line 1648, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: flota.resumen_viaje_report
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 619, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 309, in _handle_exception
raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\pycompat.py", line 14, in reraise
raise value
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 664, in dispatch
result = self._call_function(**self.params)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 345, in _call_function
return checked_call(self.db, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\service\model.py", line 93, in wrapper
return f(dbname, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 338, in checked_call
result = self.endpoint(*a, **kw)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 910, in __call__
return self.method(*args, **kw)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\http.py", line 510, in response_wrap
response = f(*args, **kw)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1324, in call_button
action = self._call_kw(model, method, args, kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\web\controllers\main.py", line 1312, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 395, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\api.py", line 382, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "<decorator-gen-58>", line 2, in button_immediate_install
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 72, in check_and_log
return method(self, *args, **kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 463, in button_immediate_install
return self._button_immediate_function(type(self).button_install)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_module.py", line 573, in _button_immediate_function
modules.registry.Registry.new(self._cr.dbname, update_module=True)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\modules\registry.py", line 86, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\modules\loading.py", line 420, in load_modules
loaded_modules, update_module, models_to_check)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\modules\loading.py", line 312, in load_marked_modules
perform_checks=perform_checks, models_to_check=models_to_check
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\modules\loading.py", line 222, in load_module_graph
load_data(cr, idref, mode, kind='data', package=package, report=report)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\modules\loading.py", line 68, in load_data
tools.convert_file(cr, package.name, filename, idref, mode, noupdate, kind, report)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 737, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 804, in convert_xml_import
obj.parse(doc.getroot())
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 722, in parse
exc_info[2]
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\pycompat.py", line 13, in reraise
raise value.with_traceback(tb)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 713, in parse
self._tag_root(de)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 675, in _tag_root
f(rec)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 564, in _tag_record
f_val = _eval_xml(self, field, env)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 143, in _eval_xml
+_process("".join(etree.tostring(n, encoding='unicode') for n in node))
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 132, in _process
self.idref[id] = self.id_get(id)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 658, in id_get
res = self.model_id_get(id_str, raise_if_not_found)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\convert.py", line 664, in model_id_get
return self.env['ir.model.data'].xmlid_to_res_model_res_id(id_str, raise_if_not_found=raise_if_not_found)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_model.py", line 1659, in xmlid_to_res_model_res_id
return self.xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-24>", line 2, in xmlid_lookup
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\tools\cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "C:\Program Files (x86)\Odoo 13.0\server\odoo\addons\base\models\ir_model.py", line 1648, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
odoo.tools.convert.ParseError: "External ID not found in the system: flota.resumen_viaje_report" while parsing file:/c:/program files (x86)/odoo 13.0/server/odoo/addons/flota/views/flota_vehiculo_views.xml:2, near
<odoo>
"resumen_viaje_report" does not exist anywhere in your post except the error message. Have you shared all of your XML files?