Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Odoo8 inheritance example for res.partner

By
Sebastian782
on 8/27/15, 4:56 AM 1,506 views

Hi,

I am looking for a working example of inheritance in res.partner.

I just want to add one field for example after the existing field phone.

I have errors like:

Error details:
Field `my_field` does not exist 


Here after the code i have inside the .py and .xml

from openerp import models, fields

class pb_it(models.Model):

	_inherit = 'res.partner'

        my_field = fields.Char(string='My Field', size=64)


<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
		<record model="ir.ui.view" id="view_res_partner_inherited">
			<field name="name">view.res.partner.inherited</field>
			<field name="model">res.partner</field>
			<field name="inherit_id" ref="base.view_partner_form" />
			<field name="arch" type="xml">
				<field name="phone" position="after">
					<field name="my_field" />
				</field>
			</field>
		</record>
</data> </openerp>

Thanks

--------------------------------------------------

Thank you Tarek Mohamed Ibrahim, at the end your answer was the correct one.

1

Tarek Mohamed Ibrahim

--Tarek Mohamed Ibrahim--
896
| 5 3 7
Gîza, Egypt
--Tarek Mohamed Ibrahim--

I am an old VFP developer on ERP

I have moved to 2p since Nov-2014 and started developing with Python on Odoo.

https://www.linkedin.com/profile/public-profile-settings?trk=prof-edit-edit-public_profile

tibrahim@2p.com.sa

Tarek Mohamed Ibrahim
On 8/27/15, 5:18 AM

This error normally happens if you changed the xml and the py file and didn't restart your server. Pls restart and try again

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 8/27/15, 5:20 AM

In New API, add Import api

from openerp import models, fields, api

class pb_it(models.Model):

_inherit = 'res.partner'
my_field = fields.Char(string='My Field', size=64)

0
Dairidi
On 8/27/15, 10:50 AM
class inherit_respartner(models.Model):
    _inherit = 'res.partner'
    myfield = fields.Char()


		<record model="ir.ui.view" id="add_respartner">
			<field name="name">add_respartner</field>
			<field name="model">res.partner</field>
			<field name="inherit_id" ref="base.view_partner_form" />
			<field name="arch" type="xml">
				<field name="email" position="after">
					<field name="myfield" />
				</field>
			</field>
		</record> 

I think it's the same, but it works in my module

0
Sebastian782
On 8/27/15, 5:34 AM

The error appear when i am installing the module.

Import api did not changed anything.

Restarting the server does not change anything as i get an error 500 because the module installation failled.

Here below the full error:

 ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition

Error details:
Field `my_field` does not exist

Error context:
View `view.res.partner.inherited`
[view_id: 1072, xml_id: n/a, model: res.partner, parent_id: 126]" while parsing file:///C:/Program Files (x86)/Odoo 8.0-20150826/server/openerp/addons/toto/views/menu.xml:4, near
<record model="ir.ui.view" id="view_res_partner_inherited">
			<field name="name">view.res.partner.inherited</field>
			<field name="model">res.partner</field>
			<field name="inherit_id" ref="base.view_partner_form"/>
			<field name="arch" type="xml">
				<field name="phone" position="after">
					<field name="my_field"/>
				</field>
			</field>
		</record>

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/27/15, 4:56 AM
Seen: 1506 times
Last updated: 8/28/15, 12:02 AM