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

I have inherit res.partner and added a field named: rel_zone = fields.Integer(compute="_getzone", string='Zone', readonly=False)

In _getzone there is a lookup regarding country, zipcode = postal zone.

In my custom module I'm referring to 

customer_id = fields.Many2one('res.partner', String="Customer")
zone = fields.Integer(string="Zone code", related='customer_id.rel_zone', store=True, readonly=True)

I'm getting the error:
 File "C:\Bitnami\odoo-12\apps\odoo\Lib\site-packages\odoo-12.0.post20200815-py3.7.egg\odoo\fields.py", line 547, in _setup_related_full
    field = target._fields[name]
KeyError: 'rel_zone'
Can anyone tell me why I'm getting this error
Thanks in advanced

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

Thanks for the response Baiju, I already have added 'base' in depends (manifest). 

country_code = fields.Char(string="Land code", related='customer_id.country_id.code', store=True, readonly=True)

Above works like a charm.  I'm puzzled

อวตาร
ละทิ้ง

rel_zone is a non stored computed field, and you are using it in a related field. that is causing the problem, add store=True with the field and try.

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

Make sure you have added 'base' in depends in the manifest file

'depends': ['base'],
อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
เม.ย. 23
6121
Chatter in models แก้ไขแล้ว
1
มี.ค. 22
2407
2
ม.ค. 21
4269
2
มิ.ย. 19
3450
3
เม.ย. 17
11437