Menu

Допомога

0

How To Inherit Customer and add New Fields To Existing Views

Avatar
Neelabh Singh
I have written Model class for Customer in custom_addon/medicine/models directory 
for add new field in customer view

buyer.py
from odoo import api, fields, models
class Buyer(models.Model):
_inherit = "res.partner"
buyer_name = fields.Char(string='Buyer Name', required=True)

And In __manifest__.py I want to add depends modules for customer however I am not able

to find what should I add in following attribute depends to inherit Customer View and add new fields.

'depends': [''],

I have tried following ref: https://www.youtube.com/watch?v=3iY3ea-wvjw




1Коментар
Аватар
Відмінити
Avatar
Sehrish
-

Inheritance in model and views: https://goo.gl/4Zyc9d

3Відповіді
0
Avatar
Jainesh Shah(Aktiv Software)
Best Answer

Hello Neelabh Singh,

Please find below code it may help you to resolve this issue

Please find code in comment.
I Hope this will help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

1Коментар
Аватар
Відмінити
Avatar
Jainesh Shah(Aktiv Software)
-


buyer.py file

from odoo import api, fields, models
class ResPartner(models.Model):
_inherit = "res.partner"

buyer_name = fields.Char(string='Buyer Name', required=True)

in buyre.xml file

<record id="view_inherit_contact_from_view" model="ir.ui.view">
<field name="name">res.partner.form.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="// field[@name='field_name(where you added)']" position="after">
<field name="buyer_name"/>
</xpath>
</field>
</record>

add following in your manifest

'depends': ['base']

0
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,

if you want see this in your default view then You can write this in your xml file.

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


        <field name="name">Purchase Limit</field>


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


        <field name="inherit_id"


               ref="base.view_partner_form"/>


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


            <xpath expr="// field[@name='barcode']"


                   position="after">


                <field name="buyer_name"/>


            </xpath>


        </field>


    </record>


add following in your manifest

depends': ['contacts']

Regards

Аватар
Відмінити
0
Avatar
Arian Shariat
Best Answer

find the module in which the res.partner model is created. In this case: 'depends': ['contacts']

Аватар
Відмінити