Skip to Content
Menú
This question has been flagged
1 Respondre
5972 Vistes

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
Best Answer

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

Avatar
Descartar
Related Posts Respostes Vistes Activitat
2
de maig 24
1719
3
d’abr. 23
11126
1
d’abr. 23
13984
9
de des. 23
23449
1
de maig 19
2578