Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
5122 Visninger

As you can see in the code bellow, I use "inherits" statement to have the print_comment field available in product.template model. I must use inherits because I want a set of fields available in multiple model. The problem is when I want to show it on a view. When I do it and access a record in the product listing, I get the following error:

The requested operation cannot be completed due to security restrictions. Please contact your system administrator.
(Document type: product.template, Operation: read)

What's wrong? We can find what access or record rules to set if that's the culprit... we also use the admin account to test so there shouldn't be any rules applied right???

Please help!!!


product.py

from openerp import api, fields, models

class 

ProductTemplate(models.Model):
_inherit = 'product.template'
_inherits = {'print.specs': 'print_specs_id'}

print_specs_id = fields.Many2one('print.specs', string='Print Spectification', ondelete="cascade", required=True)


print_specs.py

# -*- encoding: utf-8 -*-
from openerp import api, fields, models, _

 # bag of print specs
class PrintSpecs(models.Model):
 
_name = 'print.specs'

print_comment = fields.Char(string='Comment sur impression', help='Comment sur impression seulement')


product.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="product_template_devis_form_view" model="ir.ui.view">
            <field name="name">product.template.devis.form.view</field>
            <field name="model">product.template</field>
            <field name="inherit_id" ref="product.product_template_form_view"/>
            <field name="arch" type="xml">
                <field name="type" position="after">
                    <field name="print_comment" />
                </field>
            </field>
        </record>
    </data>
</openerp>


Manifest:

{    
    'name' : "Product Devis TEST",
    'description': "Fro test",
    'author' : "ML",
    'category' : 'Technical Settings',
    'version' : '0.1',
    'depends' : ['product','sale'],
    'data' : ['views/product.xml'],
}


 



Avatar
Kassér
Bedste svar

you have to create a access right for the product template model.

create ir.model.access.csv file inside the security folder. and include this in manifest

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_product_template,access.product.template,product.model_product_template,base.group_user,1,1,1,1
Avatar
Kassér

but he is logged as admin... shouldn't admin not be restricted? So any new fields added to existing model using inherits will cause the model to be blocked for all users, unless we add an access rule?

Related Posts Besvarelser Visninger Aktivitet
2
jan. 24
2614
2
sep. 25
3476
2
aug. 23
2999
3
aug. 23
6507
1
dec. 20
7649