【问题标题】:update fields from other fields after date odoo在日期 odoo 之后从其他字段更新字段
【发布时间】:2018-09-10 16:16:12
【问题描述】:

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

例如,当我选择一个员工时,我想在状态完成后更新他的坐标

    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_newcountry_work_id_new*country_work_id * 在模型 hr.employee if date_cration >= date_transfer

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

【问题讨论】:

  • 请描述更多,以便我们了解您想表达的内容。

标签: python function odoo


【解决方案1】:

你知道 @api.onchange@api.depends 装饰器吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-04
    • 1970-01-01
    • 2013-03-27
    • 2012-05-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    相关资源
    最近更新 更多