Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
1215 Visualizzazioni

Hello Odoo Community:

   I'd like to create an automated action in model sale.order.inherited, in which every time (on creation and update) the field "name" has a keyword "sample", the invoice.status will change to "no" (nothing to invoice); before update, "name" is not set; after update, "name" (order.reference) contains "sample"; I have tried update the record -->invoice.status--> value --> no, but it doesn't work; I'd like to try execute the python code, would you please help me write the code

["invoice_status","=","no"]

Thanks a lot

Avatar
Abbandona
Risposta migliore

Hi, 

Try this code:

# Assuming 'sample' is case-sensitive in the order reference
if record.name and 'sample' in record.name:
    record.invoice_status = 'no'


Hope it helps

Avatar
Abbandona
Autore

Thank you for your reply, but it shows "forbidden opcode(s) in "if record.name and 'sample' in record.name:\n record.invoice_status = 'no'": STORE_ATTR"

Autore

Also, how to I write the code if it is the name field contains the keyword "sample"; name, ilike, sample?

Post correlati Risposte Visualizzazioni Attività
1
gen 24
1099
1
dic 23
1483
1
feb 19
21884
3
lug 18
4586
2
apr 16
8268