Odoo14 设置Binary字段默认值
1 # Odoo14 设置Binary字段默认值 2 def _default_design_image(self): 3 # 获取文件路劲,第一个参数是模块名,第二个是模块中相对目录,第三个参数是具体文件名 4 path = get_resource_path('ship', 'static/description', 'icon.png') 5 return base64.b64encode(open(path, 'rb').read()) if path else False 6 7 # 字段声明 8 design_image = fields.Binary('Picture', default=_default_design_image)