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

How can I add a field to the SO table where I can check it if the SO was created by a user via the Create New SO button or if by Duplicate button from an existing PO?

Thanks

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

Create button will trigger the ORM method "create"

similarly Duplicate Action will trigger the ORM method "copy"

So you can inherit the copy method, and append a flag (probably a boolean: set it as true) to the param "default" before returning the super call


Note:

There are 2 methods/ways involved while duplicating a record.

"copy" : will copy the data and creates a new record, returning the ID of the newly created one.

"copy_data": will just copy the data and returns you the dict of values which are being copied.

So according to your need, use the appropriate one.

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

Thanks! Do you have an example? I would only mark the SOs with copy, I would want to use the copy (not copy_data). So like:

def copy(self, cr, uid, id, default={}, context=None):

if not default:

default = {}

default.update({

'[field]': '[value]',

})

return super([class], self).copy(cr, uid, id, default, context=context)`

Bài viết liên quan Trả lời Lượt xem Hoạt động
5
thg 12 23
22077
0
thg 4 22
2356
2
thg 4 21
7622
1
thg 3 15
3754
0
thg 1 25
1264