تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5890 أدوات العرض

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

الصورة الرمزية
إهمال
أفضل إجابة

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

الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
2
مايو 24
1649
3
أبريل 23
11063
1
أبريل 23
13861
9
ديسمبر 23
23347
1
مايو 19
2522