how to change the default field value from another model in odoo

假如想象 提交于 2019-12-07 02:11:27
Rinaldi

try this :

@api.model   
def create(self, vals):
    status = self.env['formdownload'].browse(vals['form_serial_no_id'])         
    if self.form_serial_no_id.id == status.status:
        status.write({'status': True})     
    return super(PlotAllocation, self).create(vals)

Try this:

@api.model
def create(self, vals):
    form_id = vals['form_serial_no_id'].id
    form_obj = self.env['formdownload'].browse([form_id])

    if your condition:
        form_obj.write({'status':True})

    return super(PlotAllocation, self).create(vals)

i tried this code and it work just fine :

@api.model
 def create(self, vals):
        rec_id = super(PlotAllocation, self).create(vals)
        if rec_id.form_serial_no_id :
            # raise exceptions.ValidationError('Your code is here should make the status of companyname to true')
            # print 'Your code is here should make the status of companyname to true'
            rec_id.form_serial_no_id.status = True
        return rec_id
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!