Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
3350 Представления

I have an object of sale.order: sale.order(24,). I know that there is 'partner_id' in this object. I would like to get then country_id from 'partner_id'.
sale.order --> partner_id --> country_id

Thanks!

Аватар
Отменить

It depends on what you want to do. You want to get it on python code, email template, or print report?

Лучший ответ

Hi,

country_id = self.partner_id.country_id.id


Аватар
Отменить
Лучший ответ

Hi, there,

if you want to get the country_id(defined in the res. country) from the sale. order.

you can try this(for example):

@api.model
def name_get(self):
_logger.info('----entry sale.order name_get----')
result = []
for rec in self:
if rec.origin:
result.append((rec.id, "{}-{}".format(rec.origin, rec.name)))
else:
result.append((rec.id, "{}".format(rec.partner_id.country_id.name)))
return result

the backend is the relationship among sale. order, res. partner,res.country. you can use the many2one field to retrieve the value that you want.

hope it is useful.

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
февр. 22
3642
1
февр. 22
2767
1
янв. 22
3130
2
июл. 23
4991
1
окт. 22
3114