Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
9268 Lượt xem

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?


Ảnh đại diện
Huỷ bỏ

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
4739
1
thg 12 22
6531
2
thg 5 21
21000
2
thg 10 20
4705
1
thg 4 24
13163