콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
6871 화면


Hi,


I've tried many different approaches, but I just can't find a way to xpath to these buttons on res.partner.form :



I've used the browsers HTML inspector (F12) to find the name of the buttons, but maybe thats not the correct way


How can I make those buttons visible only to administrators?

My code:

<record id="edit_partner_form" model="ir.ui.view"> 
<field name="name">edit.partner.form</field> 
    <field name="model">res.partner</field> 
    <field name="inherit_id" ref="base.view_partner_form" /> 
    <field name="arch" type="xml"> 

        <xpath expr="//button[@name='action_view_partner_invoices']" position="attributes"> 
            <attribute name="groups">base.group_system</attribute> 
        </xpath>
          <xpath expr="//button[@name='302']" position="attributes">              <attribute name="groups">base.group_system</attribute>          </xpath>      </field> </record>


Edit: Just found out the solution! To anyone who has the same issue in the future, there are 2 external IDs, one for each button:

<record id="edit_sales_hide_invoice_button" model="ir.ui.view">
<field name="name">edit.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="account.partner_view_buttons" />
<field name="arch" type="xml">

<xpath expr="//button[@name='action_view_partner_invoices']" position="attributes">
<attribute name="groups">base.group_system</attribute>
</xpath>

</field>
</record>
<record id="edit_sales_hide_sale_button" model="ir.ui.view">
<field name="name">edit.partner.form</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="sale.res_partner_view_buttons" />
<field name="arch" type="xml">

<xpath expr="//button[@name='302']" position="attributes">
<attribute name="groups">base.group_system</attribute>
</xpath>

</field>
</record>


아바타
취소
베스트 답변

Hi,

If the original button is of the type action, in the user interface it will the id of the corresponding action.

Original Button in the code,

<button class="oe_stat_button" type="action" name="%(sale.act_res_partner_2_sale_order)d" 
groups="sales_team.group_sale_salesman"
icon="fa-usd">
<field string="Sales" name="sale_order_count" widget="statinfo"/>
</button>

And if you check the same from the UI, it will be show like this,

<button class="oe_stat_button" type="action" name="354" groups="sales_team.group_sale_salesman" icon="fa-usd">
<field string="Sales" name="sale_order_count" widget="statinfo"/>
</button>

So to inherit this, do like this,

<xpath expr="//button[@name='%(sale.act_res_partner_2_sale_order)d']" position="after">
</xpath>

Thanks

아바타
취소
작성자

Thanks Niyas!

베스트 답변

Hello, my code is:

><data>
<recordid="account_view_bank_statement_form_inherit"model="ir.ui.view"><fieldname="name">account.view.bank.statement.form.inheritfield><fieldname="model">account.bank.statementfield><fieldname="inherit_id"ref="account.view_bank_statement_form"/><fieldname="arch"type="xml"><xpathexpr="//button[@name='button_post']"position="attributes"><attributename="groups">restrictions_for_bank_statements_and_reconciliation.group_publicar_extractos_bancariosattribute>xpath><xpathexpr="//button[@name='button_validate_or_action']"position="attributes"><attributename="groups">restrictions_for_bank_statements_and_reconciliation.group_validar_extractos_bancariosattribute>xpath>field>record>
data>odoo>


By it not hide that button, Why?




아바타
취소
관련 게시물 답글 화면 활동
2
3월 22
5751
1
7월 25
773
2
11월 19
3108
1
7월 25
2903
1
8월 24
1378