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

I just installed the hr_holidays module. In the list view of the dashboard, everyone can see the buttons "Approve/validate" and "Refuse". In the code, it is specifically told that you need a hr_holidays group to see them. This part doesn't work, and I can't get to bring that back again.

< button string="Approuver" name="action_approve" type="object" icon="fa-thumbs-up" states="confirm" invisible="1" modifiers="{'invisible':[['state','not in',['confirm']]],'column_invisible':true}" options="{}"/>
< button string="Valider" name="action_validate" type="object" icon="fa-check" states="validate1" invisible="1" modifiers="{'invisible':[['state','not in',['validate1']]],'column_invisible':true}" options="{}"/>
< button string="Refuser" name="action_refuse" type="object" icon="fa-times" states="confirm,validate1" invisible="1" modifiers="{'invisible':[['state','not in',['confirm','validate1']]],'column_invisible':true}" options="{}"/>

Here are the buttons rendered in fields view get. They all have "invisible='1'", but they all are visible.

Code-side, we have a groups attribute bound to the buttons, which trigger the "invisible" appearance, but doesn't change much.


Edit : Neither of these code change anything to the problem :

< record id="hr_holidays_view_tree_user" model="ir.ui.view">
< field
name="name">hr.holidays.view.tree.user< /field>
< field
name="model">hr.leave< /field>
< field
name="inherit_id" ref="hr_holidays.hr_leave_view_tree" />
< field
name="groups_id" eval="[(5, 0, [ref('hr_holidays.group_hr_holidays_manager'), ref('hr_holidays.group_hr_holidays_user')])]" />
< field
name="arch" type="xml">
< xpath
expr="//button[@name='action_approve']" position="attributes">
< attribute
name="modifiers">{'invisible': 1}< /attribute>
< /xpath>
< /field>
< /record>
< record id="hr_holidays_view_tree_user" model="ir.ui.view">
< field
name="name">hr.holidays.view.tree.user< /field>
< field
name="model">hr.leave< /field>
< field
name="inherit_id" ref="hr_holidays.hr_leave_view_tree" />
< field
name="groups_id" eval="[(5, 0, [ref('hr_holidays.group_hr_holidays_manager'), ref('hr_holidays.group_hr_holidays_user')])]" />
< field
name="arch" type="xml">
< xpath
expr="//button[@name='action_approve']" position="attributes">
< attribute
name="invisible">1< /attribute>
< /xpath>
< /field>
< /record>
< record id="hr_holidays_view_tree_user" model="ir.ui.view">
< field
name="name">hr.holidays.view.tree.user< /field>
< field
name="model">hr.leave< /field>
< field
name="inherit_id" ref="hr_holidays.hr_leave_view_tree" />
< field
name="groups_id" eval="[(5, 0, [ref('hr_holidays.group_hr_holidays_manager'), ref('hr_holidays.group_hr_holidays_user')])]" />
< field
name="arch" type="xml">
< xpath
expr="//button[@name='action_approve']" position="attributes">
< attribute name="groups">hr_holidays.group_hr_holidays_user,hr_holidays.group_hr_holidays_manager< /attribute>
< /xpath>
< /field>
< /record>


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Based on the code snippet you shared, you have defined the invisible attribute multiple times like in the second line your code snippet:  invisible=1, modifiers="{'invisible... , 'column_invisible':true....

Try invisible=1 only for each button.

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

Thanks for your answer.
Unfortunately, this doesn't solve my problem, check my edit

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

Hello Anthony MIEGGE, 

Please find Code in comment.

I Hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari 

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

You can add group in button for example.

.XML Data file
<record id="group_1" model="res.groups">
<field name="name">Button Hide</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>

<button name="my_button" string="My Button" type="object" groups="module_name.group_1"/>

Tác giả

Thanks for your answer.
Unfortunately, this doesn't solve my problem, check my edit

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

Hi Anthony MIEGGE,


To Make the button 'invisible' try ,


<button string="Validate" name="action_validate" states="validate1" type="object" invisible="1" class="oe_highlight"/>


or to make the field 'invisible' based on the values of other fields try,


<button string="Validate" name="action_validate" states="validate1" type="object" attrs="{'invisible':[('state', 'not in', ('validate'))]}" class="oe_highlight"/>


Hope it helps,
Kiran K


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

I'll state again what I might have said the wrong way.
My problem is that, even with "invisible='1'" or with "groups=base.blahblahblah", my buttons stay visible.
That's why your answer doesn't work.

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 12 23
1292
2
thg 11 22
4003
4
thg 5 22
4212
1
thg 3 22
2298
1
thg 12 20
2273