تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
3230 أدوات العرض

Hello Community.

In the model account_move, I have a field called "invoice_origin" that have the ID of a sale order. It's define like this:

invoice_origin = fields.Char(string='Origin', readonly=True, tracking=True)

I need the entire sale.order because a need the the "business_unit_it", but I onlyhave this data. How can I search and return the entire sale.order, in the move_account file?


I've tried something like this but it doesn't work


client_order_ref = fields.Char('get_sale_order().client_order_ref')

# Get a sale order with the invoice_origin field
def get_sale_order(self):
sale_order = self.env['sale.order'].search([
('name', '=', self.invoice_origin)
])
return sale_order


Thank you! :)

الصورة الرمزية
إهمال
أفضل إجابة

Hi 

Try,

client_order_ref = fields.Char(compute='_get_sale_order')

# Get a sale order with the invoice_origin field
def _get_sale_order(self):
for rec in self:
sale_order = self.env['sale.order'].search([
('id', '=', int(rec.invoice_origin))
])
rec.client_order_ref = sale_order.name if sale_order else False


الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
0
أكتوبر 22
2726
0
أغسطس 21
2717
2
سبتمبر 23
10334
1
مارس 23
2778
1
سبتمبر 22
2829