Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
9169 Widoki

I have created a new model and defined a tree, calendar and form view. When I select multiple records in treeview, I can't see a 'delete' button (I am unable to post screenshot due to insufficient rights)

Here is the model:

class GearManufacturing(models.Model):

 _name = 'gear.manufacturing'
product_id = fields.Many2one("product.product", string='Product',required=True)
product_model = fields.Char("Product Model", related='product_id.x_product_model')
product_to_dispatch = fields.Integer('Products to Dispatch',required=True)
dispatch_date = fields.Date('Dispatch Date', copy=False, default=fields.Date.today(), index=True, required=True)
dispatch_date_month = fields.Char(string='Dispatch Date Month',compute='_get_date_month',store=True,readonly=True)
dispatch_date_year = fields.Char(string='Dispatch Date Year',compute='_get_date_year',store=True,readonly=True)

Here is the view:

<odoo>
<data>
<record id="gear_manufacturing_tree" model="ir.ui.view">
<field name="name">gear.manufacturing.tree</field>
<field name="model">gear.manufacturing</field>
<field name="arch" type="xml">
<tree>
<field name="product_id"/>
<field name="product_to_dispatch"/>
<field name="product_model"/>
<field name="dispatch_date"/>
</tree>
</field>
</record>

<record model="ir.ui.view" id="dispatch_plan_calendar">
<field name="name">Dispatch Plan</field>
<field name="model">gear.manufacturing</field>
<field name="priority" eval="2"/>
<field name="arch" type="xml">
<calendar string="Calendar View" date_start="dispatch_date">
<field name="product_id"/>
<field name="product_model"/>
<field name="product_to_dispatch"/>
</calendar>
</field>
</record>

<record model="ir.actions.act_window" id="gear_manufacturing_action">
<field name="name">Dispatch Plan</field>
<field name="res_model">gear.manufacturing</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">calendar,tree,form</field>
</record>
</odoo>

Where am I going wrong?


Awatar
Odrzuć

Add Access Rights: https://goo.gl/4jAhtH

Najlepsza odpowiedź

Hi,

Check whether the delete permission is granted for the logged in user group for the corresponding model. If the logged in user have no delete permission the button won't be visible, to ensure that the issue is with the access rights, you can switch to the super user mode and check whether the delete button is visible in superuser mode.

If the delete button is visible in super user mode, you can confirm it is the access rights issue. Either it can be done from the user interface or from the code, from the user interface activate the developer mode and navigate to Settings -> Technical -> Security -> Access Rights.

For activating the Super User Mode: How to Switch Super User Mode

For Settings Access rights from code: How To Set Access Rights For Models

For Activating the developer mode: Activate Developer Mode


The delete button can also invisible if delete="0" is given with tree, but here in your code, it is not used.

Thanks

Awatar
Odrzuć
Autor

Yes, I have modified ir.model.access.csv file and it's showing delete button now.

Najlepsza odpowiedź

Hi, the user you are using doesn't have delete access to your model so you have to create the model access control list.

see the below link for how to add model access for your custom module:

https://kanakinfosystems.com/blog/create-access-right-in-custom-module

Awatar
Odrzuć
Autor

Yes, I have modified ir.model.access.csv file and it's showing delete button now.

Powiązane posty Odpowiedzi Widoki Czynność
1
kwi 23
4680
1
gru 22
6464
2
maj 21
20839
2
paź 20
4638
1
kwi 24
13050