在日期odoo之后更新其他字段的字段 [英] update fields from other fields after date odoo

查看:189
本文介绍了在日期odoo之后更新其他字段的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用另一个字段更新一个字段

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')

我想通过 * state_work_id * 更新 region_new country_work_id_new * country_work_id * 在模型hr.employee if 中,date_cration> = date_transfer

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

我尝试添加函数self.date_cration> ="date_transfer",但不适用于日期

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

推荐答案

您知道 @ api.depends 装饰器?

这篇关于在日期odoo之后更新其他字段的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆