代码拉取完成,页面将自动刷新
import logging
_logger = logging.getLogger(__name__)
def multi(method):
method._api = 'multi'
return method
def model_cr(method):
method._api = 'model_cr'
return method
from odoo import api
api.multi = multi
api.model_cr = model_cr
try:
from odoo import api
api.multi = multi
api.model_cr = model_cr
except:
import traceback;traceback.print_exc()
from odoo import models
origin_write = models.BaseModel.write
def write(self, vals):
_vals = {}
for k,v in vals.items():
if k in self._fields:
_vals[k] = v
else:
_logger.warning('>>> odoo 13 hook: model %s has no field %s', self._name, k)
#vals = { k:v for k,v in vals.items() if k in self._fields}
return origin_write(self, _vals)
models.BaseModel.write = write
origin_create = models.BaseModel.create
@api.model_create_multi
def create(self, vals_list):
_vals_list = []
for vals in vals_list:
_vals = {}
for k,v in vals.items():
if k in self._fields:
_vals[k] = v
else:
_logger.warning('>>> odoo 13 hook: model %s has no field %s', self._name, k)
#vals = { k:v for k,v in vals.items() if k in self._fields}
_vals_list.append(_vals)
return origin_create(self, _vals_list)
models.BaseModel.create = create
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。