Search code examples
odooodoo-website

odoo res.partner address fields access error on website


I am trying to show address fields on website but it gives access error. For some reason I can't use the contact widget on website.

When I visit the page as public user it shows 500 Internal Server error. But if I am admin, everything works.

In my xml template I wrote following:

<span t-field="event.address_id.city" groups="base.group_public"/>,
<span t-field="event.address_id.country_id.name" groups="base.group_public"/>

In ir.model.access.csv file I wrote following:

access_res_partner,res.partner,base.model_res_partner,base.group_public,1,0,0,0

also tried

access_res_partner,res.partner,base.model_res_partner,,1,0,0,0

But it shows following error:

AccessError: (u'The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: res.partner, Operation: read)', None)

Error to render compiling AST AccessError: (u'The requested operation cannot be completed due to security restrictions. Please contact your system administrator.\n\n(Document type: res.partner, Operation: read)', None) Template: website_event.index Path: /templates/t/t/div/div[2]/div[2]/div[1]/ul/li/div/div/div[3]/div/div[3]/span[1] Node: ,

I also tried this in xml without groups, but result is same:

<span t-field="event.address_id.city"/>,
<span t-field="event.address_id.country_id.name"/>

How can I resolve this.


Solution

  • Try this code.

    <span t-field="event.address_id.sudo().city"/>,
    <span t-field="event.address_id.sudo().country_id.name"/>
    

    Please make sure you understand the security section in the odoo documentation. In my opinion, it is no good idea to give the base.group_public group generally read access to your customer data.