zoukankan      html  css  js  c++  java
  • odoo 12.0 track_visibility = 'always' 无效

    • 原因

      • 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
    
  • 相关阅读:
    [Effective JavaScript 笔记] 第7条:视字符串为16位的代码单元序列
    [翻译]CSS模块-未来的编码方式
    [Effective JavaScript 笔记] 第6条:了解分号插入的局限
    [Effective JavaScript 笔记] 第5条:避免对混合类型使用==运算符
    [Effective JavaScript 笔记] 第4条:原始类型优于封闭对象
    [翻译]理解CSS模块方法
    [翻译]纠正PostCSS的4大认识误区
    [翻译]Gulp.js简介
    [Effective JavaScript笔记]第3条:当心隐式的强制转换
    [翻译]在gulp构建工具中使用PostCSS
  • 原文地址:https://www.cnblogs.com/twfb/p/11434625.html
Copyright © 2011-2022 走看看