Hello I am using the Odoo Version 19.0 Community Edition. I want to print a 13x5 product label directly as a PDF like any other from the print labels. I went into Developer Mode to change things and I duplicated the default product label report and customized it for the 13x5 label format.
I’ve named the report Product Label 13x5 (PDF) and set the Model to product.template with the corresponding template (product.report_producttemplatelabel13x5). Even though the external ID exists in Settings → Technical → Database Structure → External Identifiers, Odoo is not recognizing it when I try to use it in the form view button.
Traceback (most recent call last):
File "/home/odoo/src/odoo/19.0/odoo/tools/safe_eval.py", line 397, in safe_eval
return unsafe_eval(c, globals_dict, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "ir.actions.server(331,)", line 2, in <module>
File "/home/odoo/src/odoo/19.0/odoo/orm/models.py", line 6159, in mapped
field = records._fields[field_name]
~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'product_tmpl_id'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/odoo/src/odoo/19.0/odoo/http.py", line 2266, in _serve_db
return service_model.retrying(serve_func, env=self.env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/service/model.py", line 184, in retrying
result = func()
^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/http.py", line 2313, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/http.py", line 2528, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_http.py", line 357, in _dispatch
result = endpoint(**request.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/http.py", line 788, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/addons/web/controllers/action.py", line 58, in run
result = action.run()
^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_actions.py", line 1177, in run
res = action._run(records, eval_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_actions.py", line 1190, in _run
res = runner(run_self, eval_context=eval_context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/odoo/src/odoo/19.0/odoo/addons/base/models/ir_actions.py", line 1014, in _run_action_code_multi
safe_eval(self.code.strip(), eval_context, mode="exec", filename=str(self))
File "/home/odoo/src/odoo/19.0/odoo/tools/safe_eval.py", line 403, in safe_eval
raise ValueError('%r while evaluating\n%r' % (e, expr))
ValueError: KeyError('product_tmpl_id') while evaluating
"if records:\r\n templates = records.mapped('product_tmpl_id') # map product variants to templates\r\n templates.env.ref('custom.report_product_label_13x5').report_action(templates)"
The above server error caused the following client error:
RPC_ERROR: Odoo Server Error
RPC_ERROR
How to properly link the button to the report in the form view?
Hello,
Can you tell me what you get in"records"? because error shows that records does not have a product_tmpl_id field.