تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
3 الردود
14379 أدوات العرض

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>


الصورة الرمزية
إهمال
أفضل إجابة

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.

الصورة الرمزية
إهمال
الكاتب

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

أفضل إجابة

Hello Anthony MIEGGE, 

Please find Code in comment.

I Hope this will help you. 

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

الصورة الرمزية
إهمال

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"/>

الكاتب

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

أفضل إجابة

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


الصورة الرمزية
إهمال
الكاتب

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.

المنشورات ذات الصلة الردود أدوات العرض النشاط
0
ديسمبر 23
1285
2
نوفمبر 22
3992
4
مايو 22
4207
1
مارس 22
2283
1
ديسمبر 20
2265