Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5959 Vistas

hello guys, i'm using odoo11 and have a problem to add my new groups to an existing field where it already has a group for it (defined in python).


for example 

this is the original field from account invoice

outstanding_credits_debits_widget = fields.Text(compute='_get_outstanding_info_JSON', groups="account.group_account_invoice")
payments_widget = fields.Text(compute='_get_payment_info_JSON', groups="account.group_account_invoice")

i have done like this (override the original python code) and it works:

outstanding_credits_debits_widget = fields.Text(compute='_get_outstanding_info_JSON', groups="account.group_account_invoice,wpd_invoice.group_finance_site_admin,wpd_invoice.group_finance_finance_admin,wpd_invoice.group_finance_finance_team,wpd_invoice.group_finance_finance_and_accounting_manager,wpd_invoice.group_finance_head_fat")
payments_widget = fields.Text(compute='_get_payment_info_JSON', groups="account.group_account_invoice,wpd_invoice.group_finance_site_admin,wpd_invoice.group_finance_finance_admin,wpd_invoice.group_finance_finance_team,wpd_invoice.group_finance_finance_and_accounting_manager,wpd_invoice.group_finance_head_fat")

but can i do it from XML instead of override the python code? i've tried 2 ways to do it but didn't works:

1. replace the xml like this but not works
<xpath expr="//field[@name='payments_widget']" position="replace">
<field name="payments_widget" colspan="2" nolabel="1" widget="payment" groups="wpd_invoice.group_finance_finance_and_accounting_manager"/>
</xpath>

2. replace it, make it invisible and make it visible to the specific groups
<xpath expr="//field[@name='payments_widget']" position="replace">
<field name="payments_widget" colspan="2" nolabel="1" widget="payment" invisible="1"/>
/>
</xpath>

<record id="group_wpd_finance_customer_invoice_form_view_inherit" model="ir.ui.view">
        <field name="name">group.wpd.finance.customer.invoice.form.view.inherit</field>
        <field name="model">account.invoice</field>
        <field name="inherit_id" ref="account.invoice_form"/>
        <field name="groups_id" eval="[(6,0,[ref('group_finance_finance_and_accounting_manager')])]"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='payments_widget']" position="attributes">
                <attribute name="invisible">0</attribute>
            </xpath>
        </field>
</record>

can someone help me for this issue? thanks for further answer

Avatar
Descartar
Mejor respuesta

NO, you can't when the groups attribute is defined for the field in python it can only be modified with python.

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
may 24
1718
3
abr 23
11114
1
abr 23
13972
9
dic 23
23440
1
may 19
2574