update fields from other fields after date odoo

余生长醉 提交于 2019-12-11 16:17:51

问题


I want to update a field by another field

for example when I select an employee I want to update his coordinates after the states done

    class Hr_transf_employee(models.Model):
        _name = 'hr.employee.transfer'
        _rec_name = 'employee_id'


@api.multi
def transfert(self):
    self.date_cration ==  "date_transfer"
    if self.region_new :
       self.state_work_id = self.region_new.id
    if self.country_work_id_new :
       self.country_work_id = self.country_work_id_new.id


        date_cration = fields.Date(string='Date order', required=True, default=datetime.today())
        date_transfer = fields.Date(string='Date transfer')
        employee_id = fields.Many2one('hr.employee',string='Employee', required=True) 

        job_id_new = fields.Many2one('hr.job',string='Job title', required=True) 
        country_work_id_new = fields.Many2one('res.country', 'Country work new') 

        state = fields.Selection([
            ('draft', 'Draft'),
            ('accept', 'Accept'),
            ('done', 'Done'),
            ('cancel', 'Cancel'),
        ], string='Order Status', readonly=True, copy=False, store=True, default='draft')

I want to update region_new by *state_work_id * and country_work_id_new by *country_work_id * in the model hr.employee if the date_cration >= date_transfer

i try to add in function self.date_cration >= "date_transfer" but it's not apply with date


回答1:


Do you know @api.onchange and @api.depends decorators ?



来源:https://stackoverflow.com/questions/52261821/update-fields-from-other-fields-after-date-odoo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!