Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
1253 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

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"

ผู้เขียน

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

Related Posts ตอบกลับ มุมมอง กิจกรรม
Odoo 14 custom field python coding แก้ไขแล้ว
1
ม.ค. 24
1133
1
ธ.ค. 23
1521
Automatically send emails แก้ไขแล้ว
1
ก.พ. 19
21925
3
ก.ค. 18
4607
2
เม.ย. 16
8290