Odoo Help


How to properly update one column value to be showed in another with fields.related?

Tomas Parnarauskas
on 6/4/13, 6:20 AM 2,805 views

Hello, I'm trying to create module, that would add new field in res.partner object and that same field would be related with res.company. To be specific it is company_registry field. So it should work like this: if company_registry field is entered in res.company, it updates that field in res.partner too (to res.partner resource that is the same as res.company resource). I wanted to make it the same as res.partner.vat field is behaving. You enter vat code in company and it automatically appears at res.partner.

Tomas Parnarauskas
On 6/4/13, 6:23 AM

It could be done like this:


import res_partner
import res_company


    'name': 'Company code',
    'version': '1.0',
    'depends': ['base_vat'],
    'author': 'Oerp',
    'description': """
Address Book

Adds new field code in partners object. 

    'website': '',
    'category': 'base',
    'demo': [],
    'test': [],
    'data': ['res_partner_view.xml'
    'auto_install': False,
    'installable': True,


from openerp.osv import osv, fields

class res_partner(osv.osv):
    _name = 'res.partner'
    _inherit = 'res.partner'
    _columns = {
        'company_registry': fields.char('Company Registry', help="Registry code of company", size=64)


from openerp.osv import osv, fields

class res_company(osv.osv):
    _name = 'res.company'
    _inherit = 'res.company'
    _columns = {
        'company_registry': fields.related('partner_id', 'company_registry', string="Company Registry", type="char", size=64)


<?xml version="1.0" encoding="utf-8"?>
    <record id="view_partner_form1" model="ir.ui.view">
        <field name="name">re.partner.vat.inherit1</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base_vat.view_partner_form"/>
        <field name="arch" type="xml">
            <label for="vat" position="before"> 
                <field name="company_registry" placeholder="e.g. 300341211" class="oe_inline"/>

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 6/4/13, 6:20 AM
Seen: 2805 times
Last updated: 10/29/15, 1:34 AM