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


Hi,


I'm using a Brazilian localization app that creates the field and populates it with a list of brazilian cities according to chosen state, to make it easier for the user.


The app works fine, except that it doesn't display the city's name when I use .


I believe I have tracked the problem ->  calls the function to format the address anddoesn't know how to handle args likeor.


I think I have to overide, but I'm really not sure how. My code:

from odoo import models, fields, api, _



class Partner(models.Model):
_name = "res.partner"


def _display_address(self, without_company=False):

address_format = self._get_address_format()
args = {
'state_code': self.state_id.code or '',
'state_name': self.state_id.name or '',
'country_code': self.country_id.code or '',
'country_name': self._get_country_name(),
'company_name': self.commercial_company_name or '',
'city_name': self.city_id.name or '',    
'city_code': self.city_id.code or '',  
}
for field in self._formatting_address_fields():
args[field] = getattr(self, field) or ''
if without_company:
args['company_name'] = ''
elif self.commercial_company_name:
address_format = '%(company_name)s\n' + address_format
return super(address_format) % args


What am I doing wrong? Is the usage of Super correct?


Thanks in advance  

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

You have inherited this or doing in the base code? if inherited then change the _name to _inherit. 



อวตาร
ละทิ้ง
ผู้เขียน

Worked, thanks!

For future notes: super was not necessary

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 19
4384
2
ธ.ค. 23
9938
override onchange function แก้ไขแล้ว
1
ต.ค. 21
342
1
เม.ย. 20
7422
1
มี.ค. 15
6718