Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
133 Vues

Hello all, i use odoo 16.

I want to manipulate some fields in res.partner and therefore i create my own module. The manipulation of fields of res.partners works fine, but if i want to manipulate fields with relations to other modules i get the error message field does not exists.

For Example:

In the contacts under the page sale/purchase are the field user_id and i want to add the attribute options. In the debug mode i can see the relation to res. users but i can´t find the view of it. If i call edit view and try to find the correct view in the inheritances views i do not find it. How i can find the correct view? Is it possible to manipulate it from my own module? I never know when i have to import some modules in the manifest or init files too. Or when i need a class file. Can anyone explain me this with simple examples with full code? In the developer documentation i never find full examples piece of code examples only...

Avatar
Ignorer
Meilleure réponse

Hi,

Inherit a view in Odoo:

1. Activate Developer Mode.

2. Open the form you want to modify.

3. Click Debug → Edit Form View.

The external ID of the view. For the res.partner, the field user_id is defined in the contact form view.


Sample code:



<?xml version="1.0" encoding="UTF-8"?>

<odoo>

    <record id="view_partner_form_inherit_salesperson_options" model="ir.ui.view">

        <field name="name">res.partner.form.inherit.salesperson.options</field>

        <field name="model">res.partner</field>

        <field name="inherit_id" ref="base.view_partner_form"/> <!-- inherit the correct form -->

        <field name="arch" type="xml">

            <!-- locate the field you want to modify -->

            <field name="user_id" position="attributes">

                <attribute name="options">{'no_create': True}</attribute>

            </field>

        </field>

    </record>

</odoo>



Create a new module in Odoo:

1. https://www.cybrosys.com/blog/how-to-create-a-module-in-odoo-16

2. https://www.youtube.com/watch?v=pFRL8XXV77o


Hope it helps.



Avatar
Ignorer