Reputation: 61
When i discard the duplication of an object (Duplicate -> Discard) is created because the creation take effect on click duplicate not on click save but i want the Discard button really works and the creation take effect on click save not on click duplicate.
Upvotes: 1
Views: 453
Reputation: 14746
You can override copy method and you can ignore unwanted values from the source data.
def copy(self, cr, uid, id, default=None, context=None, done_list=None, local=False):
default = {} if default is None else default.copy()
### update default dictionary to ignore/replace unwanted values.
default.update({'source_field1':'', 'source_field2' : False})
return super(class_name, self).copy(cr, uid, id, default, context=context)
The fields you have defined in default will be ignored and set defined values in target.
Upvotes: 0
Reputation: 61
The object is first duplicated in the database (i.e. the record is duplicated and created in database) and then new created record will be displayed in an edit mode to let use to change anything.
"Discard" button discards any subsequent changes done by use.
Upvotes: 0
Reputation: 1108
You can override the copy function which duplicate an item with the provided id.
So, try to return the values of given item within action of new one. Without calling super copy function.
Upvotes: 0