Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
6138 Tampilan

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
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Mei 24
1929
3
Apr 23
11332
1
Apr 23
14271
9
Des 23
23660
1
Mei 19
2689