Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
2845 Widoki

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! :)

Awatar
Odrzuć
Najlepsza odpowiedź

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


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
paź 22
2502
0
sie 21
2521
2
wrz 23
9992
1
mar 23
2577
1
wrz 22
2499