Hammad Qureshi
Hammad Qureshi

Reputation: 1136

Caught UndefinedError: 'openerp.tools.misc.frozendict object' has no attribute 'button_access' while email template rendering in odoo

I had accidentally deleted Notification Email template but luckily I have it backup to restore. Actually I wanted to make some changes in the Email Template body. But after this I am getting exception on email send as well as in email template preview in short while template rendering. I have also tried to remove all the email template body changes to see whether the change are causing issue or not, but still the error is. As exception is saying template can't find button_access attribute, on further researching on it, I found that it is just simple dict value included in the context of template by script see here.

2016-10-29 19:33:41,391 3804 INFO wtm_ent_imp openerp.addons.mail.models.mail_template: Failed to render template <Template memory:7f89923cc090> using values {'format_tz': <function <lambda> at 0x7f8979e8f9b0>, 'ctx': {u'lang': u'en_US', u'tz': u'Asia/Karachi', u'uid': 1, u'active_model': u'mail.template', 'safe': False, u'params': {u'action': 100}, u'search_disable_custom_filters': True, u'active_ids': [1], u'template_id': 1, u'active_id': 1}, 'user': res.users(1,), 'object': mail.message(8832,)}
Traceback (most recent call last):
  File "/home/odoo/odoo-server/addons/mail/models/mail_template.py", line 364, in render_template
    render_result = template.render(variables)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/local/lib/python2.7/dist-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "<template>", line 1, in top-level template code
  File "/usr/local/lib/python2.7/dist-packages/jinja2/sandbox.py", line 307, in getitem
    return obj[argument]
UndefinedError: 'openerp.tools.misc.frozendict object' has no attribute 'button_access'

Upvotes: 1

Views: 779

Answers (1)

Hammad Qureshi
Hammad Qureshi

Reputation: 1136

Ok here is how I solved this problem.

Actually It seems that Notification Email Template (which is default template generated by base classes) depends on some reference variables most probably stored in ir_model_data, so when accidentally I deleted it and recreated from csv backup, its id changed and hence the references variables in data model i.e ir_model_data are also no longer workable. To recreate these reference variables I first tried to just restart the server but sadly no success then I reinstalled the base modules in order to recreate reference variables. To do so I ran the odoo server as:

$ odoo.py -c odoo.conf -u all

What this does is instruct the server to update all modules. Note: I have fresh odoo instance without any customization, this command may cause some inconvenience for other cases. So you have been warned.

Upvotes: 1

Related Questions