Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
6153 Visualizzazioni

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
Abbandona
Risposta migliore

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

Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
mag 24
1951
3
apr 23
11354
1
apr 23
14344
9
dic 23
23683
1
mag 19
2701