Skip to Content
Menu
This question has been flagged
1 Reply
1741 Views

In my code, I've write defalut_get method and it is perfectly working when I create new record. but, when I open existing record default value is not showing

here is my code:

@api.model
def default_get(self, fields):
    print('fields ------------', fields)
    res = super(SalesTarget, self).default_get(fields)
    activity_stage_target_ids = [(5, 0, 0)]
    stage_rec = self.env['crm.stage'].search([])
    for stage in stage_rec:
        line = (0, 0, {
            'stage_id': stage.id
        })
        activity_stage_target_ids.append(line)
res.update({
'activity_stage_target_ids': activity_stage_target_ids,
})
return res


Avatar
Discard
Best Answer

Hello, @Roshan Pandey

Hope you are doing well,

- default_get method works only when you create new record , 
for you to update existing record you need to use compute method or xmlrpc.

Hope this will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

Avatar
Discard