博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
odoo 12.0 track_visibility = 'always' 无效
阅读量:5359 次
发布时间:2019-06-15

本文共 2693 字,大约阅读时间需要 8 分钟。

  • 原因
    • odoo12.0 对属性track_visibility 只做了非False判断, 也就是说track_visibility 属性不写False, 或者不定义这个属性,其他都为onchange
      • if getattr(field, 'track_visibility', False):
  • 解决方法修改addons/mail/models/mail_thread.py的_message_track方法为
def _message_track(self, tracked_fields, initial):    """ For a given record, fields to check (tuple column name, column info)    and initial values, return a structure that is a tuple containing :        - a set of updated column names        - a list of changes (initial value, new value, column name, column info) """    self.ensure_one()    changes = set()  # contains always and onchange tracked fields that changed    displays = set()  # contains always tracked field that did not change but displayed for information    tracking_value_ids = []    display_values_ids = []    # generate tracked_values data structure: {'col_name': {col_info, new_value, old_value}}    for col_name, col_info in tracked_fields.items():        track_visibility = getattr(self._fields[col_name], 'track_visibility', 'onchange')        initial_value = initial[col_name]        new_value = getattr(self, col_name)        if new_value != initial_value and (new_value or initial_value):  # because browse null != False            track_sequence = getattr(self._fields[col_name], 'track_sequence', 100)            tracking = self.env['mail.tracking.value'].create_tracking_values(initial_value, new_value, col_name,                                                                                col_info, track_sequence)            if tracking:                tracking_value_ids.append([0, 0, tracking])            if col_name in tracked_fields:                changes.add(col_name)        # 'always' tracked fields in separate variable; added if other changes        elif new_value == initial_value and track_visibility == 'always' and col_name in tracked_fields:            track_sequence = getattr(self._fields[col_name], 'track_sequence', 100)            tracking = self.env['mail.tracking.value'].create_tracking_values(initial_value, new_value, col_name,                                                                                col_info, track_sequence)            if tracking:                display_values_ids.append([0, 0, tracking])                displays.add(col_name)    if changes and displays:        tracking_value_ids = display_values_ids + tracking_value_ids    return changes, tracking_value_ids
  • 不过
    • 我发现, 这个always和我想的用法不太一样, 他是只有在修改track_visibility为onchange的字段的值时才会记录, 也就是说, 当你修改没有设定track_visibility 的字段时, 不会记录always对应字段的值
  • 啰啰嗦嗦
    • 看源码发现问题后
    • 就google了下odoo addon mail mail_thread.py "always"
    • 找到了不知啥版本的odoo
    • 看了看,美滋滋, 对always做了判断
    • 直接替换, 哪报错改哪, 完美

转载于:https://www.cnblogs.com/edhg/p/11434625.html

你可能感兴趣的文章
使用iperf测试网络性能
查看>>
Docker 安装MySQL5.7(三)
查看>>
解决VS+QT无法生成moc文件的问题
查看>>
AngularJs练习Demo14自定义服务
查看>>
关于空想X
查看>>
CF1067C Knights 构造
查看>>
[BZOJ2938] 病毒
查看>>
webstorm修改文件,webpack-dev-server不会自动编译刷新
查看>>
Scikit-learn 库的使用
查看>>
CSS: caption-side 属性
查看>>
python 用数组实现队列
查看>>
认证和授权(Authentication和Authorization)
查看>>
CSS3中box-sizing的理解
查看>>
传统企业-全渠道营销解决方案-1
查看>>
Lucene全文检索
查看>>
awk工具-解析1
查看>>
CRM product UI里assignment block的显示隐藏逻辑
查看>>
AMH V4.5 – 基于AMH4.2的第三方开发版
查看>>
Web.Config文件配置之配置Session变量的生命周期
查看>>
mysql导入source注意点
查看>>