Skip to Content
Menu
This question has been flagged
3 Replies
2801 Views
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




Avatar
Discard

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

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

Avatar
Discard


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']

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

Avatar
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
5
Aug 23
4093
0
Jul 15
6187
0
Apr 24
313
0
Jan 24
422
0
Sep 22
1999