Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1272 Lượt xem

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

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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

Ảnh đại diện
Huỷ bỏ
Tác giả

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"

Tác giả

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

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 24
1152
1
thg 12 23
1538
1
thg 2 19
21974
3
thg 7 18
4618
2
thg 4 16
8305