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
6450 Widoki


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>


Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

Thanks Niyas!

Najlepsza odpowiedź

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?




Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
2
mar 22
5264
1
lip 25
252
2
lis 19
2739
1
lip 25
2511
1
sie 24
995