Odoo Help


How to copy and modify the value of an inherited field

Carlos DuAl
on 7/21/16, 3:44 AM 884 views


I'm inherinting some fields from module A that I want to be able to change in custom module B, but I don't want those changes to affect module A

This is my custom module B, that inherits from crm.claim

 from openerp import models, fields, api

from datetime import datetime

class CrmClaim(models.Model):

    _inherit = "crm.claim"

    partner_id = fields.Many2one('res.partner', 'PartnerID')

    Address = fields.Char(related='partner_id.contact_address')

    mobile_phone = fields.Char(related='partner_id.mobile')

I want to be able to change the value of the Address and mobile_phone associated with the claim, without this change affecting res.partner

I've tried using the parameter copy=True, but when I change the phone in claims, it changes the phone in Customers too

Thank you

On 7/21/16, 5:09 AM


You have to define the `address` field as a normal field, then use the onchange function on `partner_id` field to get the contact_address from res.partner.

Make sure that in onchange function you can do anything you want (just add your conditions)

Thanks! This worked

Carlos DuAl
on 7/21/16, 5:30 AM

Axel Mendoza

--Axel Mendoza--
| 7 8 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full-time employee trying to understand what to do and how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/21/16, 4:04 AM

try with store=True, like:

Address = fields.Char(related='partner_id.contact_address', store=True)

It still modifies the res.partner field

Carlos DuAl
on 7/21/16, 5:29 AM

That needs an update of the module. Not just a server restart. It needs boths

Axel Mendoza
on 7/21/16, 5:37 AM

Sorry, I just saw this. it still modifies the res.partner field even with a module update

Carlos DuAl
on 7/26/16, 5:54 AM

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

1 follower(s)


Asked: 7/21/16, 3:44 AM
Seen: 884 times
Last updated: 7/21/16, 5:30 AM