Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
5243 มุมมอง

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 ?

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ส.ค. 17
4200
0
ส.ค. 17
3135
1
เม.ย. 25
3680
3
ธ.ค. 22
11600
How to get current url from bowser? แก้ไขแล้ว
5
เม.ย. 24
42157