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!
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
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!
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.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
1
Feb 22
|
2068 | ||
|
1
Feb 22
|
1506 | ||
|
1
Jan 22
|
1594 | ||
|
2
Jul 23
|
2997 | ||
|
1
Oct 22
|
1639 |
It depends on what you want to do. You want to get it on python code, email template, or print report?