有关 ECMAScript 2020 新特性的全面解析
758
2022-10-24
odoo 如何设置字段变更跟踪
且看源码:
@api.model def _get_tracked_fields(self, updated_fields): """ Return a structure of tracked fields for the current model. :param list updated_fields: modified field names :return dict: a dict mapping field name to description, containing on_change fields """ tracked_fields = [] for name, field in self._fields.items(): if getattr(field, 'track_visibility', False): tracked_fields.append(name) if tracked_fields: return self.fields_get(tracked_fields) return {}
设置的关键字为track_visibility
源码设置实例:
type = fields.Selection([ ('out_invoice','Customer Invoice'), ('in_invoice','Vendor Bill'), ('out_refund','Customer Credit Note'), ('in_refund','Vendor Credit Note'), ], readonly=True, states={'draft': [('readonly', False)]}, index=True, change_default=True, default=lambda self: self._context.get('type', 'out_invoice'), track_visibility='always')
当然模型需要继承 mail 的一系列模型
懂得,原来世界如此简单!
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~