Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
8038 มุมมอง

Hello,


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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

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

¿Could you explain me this? new to odoo

คำตอบที่ดีที่สุด

try with store=True, like:

Address = fields.Char(related='partner_id.contact_address', store=True)
อวตาร
ละทิ้ง
ผู้เขียน

It still modifies the res.partner field

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

ผู้เขียน

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 21
5000
1
ก.พ. 16
6637
2
มิ.ย. 17
18773
4
ก.พ. 25
2367
1
ส.ค. 24
1989