odoo遗留问题--无法重载write

Posted xushuotec

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了odoo遗留问题--无法重载write相关的知识,希望对你有一定的参考价值。

class Team(models.Model):
    _name = icbc.team
    _description = 专业组

    uid = fields.Integer(序号, required=1)
    name = fields.Char(专业组, required=1)
    team_leader_id = fields.Many2one(icbc.userinfo,组长)
    team_associate_leader_id = fields.Many2one(icbc.userinfo,副组长)
    team_member_ids = fields.One2many(comodel_name=icbc.userinfo, inverse_name=team_id, string=成员)

    @api.model
    def create(self, vals):
        # with pysnooper.snoop():
        if 1:
            if vals.get(uid)==0:
                uid = self.env[ir.sequence].next_by_code(icbc.team)
                vals[uid] = uid
            return super(Team, self).create(vals)
   

# @pysnooper.snoop()
# @api.model
# def write(self, vals):
# print(vals)
# # with pysnooper.snoop():
# # if 1:
# # if ‘team_leader_id‘ in vals:
# # new_team_leader = vals.get(‘team_leader_id‘, False)
# # old_team_leader = self.team_leader_id.id
# return super(Team, self).write(vals)

 

以上是关于odoo遗留问题--无法重载write的主要内容,如果未能解决你的问题,请参考以下文章

pycharm添加Odoo代码片段

在 Odoo 中,如何在 ir_attachment 类中覆盖 _file_write?

odoo write方法怎样设置事件

遗留项目中的重复代码删除策略

odoo 怎么重写模块默认方法

扭曲的transport.write