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

Hello,

When you duplicate a product all the content of the files are copied. How can i disable this for a certain file. E.g. The field Available in the Point of Sale. If this is checked on the original product, and you duplicate the product. The boolean will also be checked on the new product. 

How can i disable this, can sb help me


Kind Regards.

Ramzi 

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

When you duplicate any document type, the COPY method is called.

To change how COPY works, write a new function like this:

def copy(self, default=None):
  default = dict(default or {})
 default.update({ '[field you want to change the default value of]': '[value you want]', })

return super([class you are changing], self).copy(default)

default is a dictionary that tells Odoo that you want to use the contents as defaults for a new record (instead of the value already in the field from the record you are duplicating).

Also see http://stackoverflow.com/questions/20335480/what-really-happens-when-i-press-duplicate 


Ảnh đại diện
Huỷ bỏ

Hi @Ray Carnes,

What about if I want to prevent "chatter" from being copied?

Imagine I have an invoice with exact (or at least) most of the information and I want to use it as a base of another customer invoice? How can I prevent the "chatter" from being copied?

Thank you

Chatter is not copied when duplicating an Invoice - you can try for yourself and see this.

Câu trả lời hay nhất

Use copy=False in python file

field_name = fields.Char('XXX', copy=False)
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 3 15
4203
2
thg 5 25
1151
3
thg 8 24
15254
2
thg 1 24
2720
2
thg 12 23
4780