#Odoo-on-the-go: `@api.preupdate` 和 `@api.postupdate`
-
新的提交:https://github.com/odoo/odoo/pull/31059 引入两个新的装饰器:
@api.preupdate和@api.postupdate, 用来处理对应字段更新前和更新后的处理逻辑,这样我们就不需要覆写create,write方法。比如下面当记录中的驾驶员改变后,我们将驾驶员信息添加到历史记录中:@api.postupdate('driver_id') def _postupdate_driver_history(self, vals): if 'driver_id' in vals and vals['driver_id']: self.create_driver_history(vals['driver_id'])
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login