跳至内容
菜单
此问题已终结
2 回复
5285 查看

Hii All,

I have applied copy function for "duplicate" button. But after applying this function my record is not saved.  Here "create" and "new" are states selection field. But when i save "duplicate" record then state is not changed from "create" to "new". It consist only "create". Can anyone check it. Here is my python code for copy function.

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

        if default is None:

            default = {}

            print "default", default

            default['create'] = ['new']

        return super(sun_helpdesk, self).copy(cr, uid, id, default, context)

形象
丢弃
最佳答案

Which version do you use ?

#v7

Edit `copy` function like this:

def copy(self, cr, uid, id, default=None, context=None):
        if default is None:
            default = {}
        default.update({'state': 'new'})
        return super(sun_helpdesk, self).copy(cr, uid, id, default, context)

#v10 

Remove `copy` function in your model and declare field `state` like this:

state = fields.Selection([('new', 'New'), ('create', 'Create')], string='Status', default='new', copy=False)
形象
丢弃
编写者 最佳答案

Thank you, it's work. But what can i do when i require current state from where i click on duplicate button and save.

形象
丢弃

Sorry, i don't understand your question.

Could you explain more detail ?

相关帖文 回复 查看 活动
1
8月 17
4245
0
8月 17
3145
1
4月 25
3702
3
12月 22
11625
5
4月 24
42187