odoo owl对应的可调用函数
- search、create、write
async saveClick(){
if (this.state.currentThemeColor.length >0){
let userColor = await this.orm.search('dynamic.color.tree', [['user_id', '=', this.user.userId]],{limit:1})
if (userColor.length > 0){
await this.orm.write('dynamic.color.tree', [userColor[0]], {bg_color: this.state.currentThemeColor, button_color: this.state.currentButtonColor})
} else {
await this.orm.create('dynamic.color.tree', [{bg_color: this.state.currentThemeColor, user_id: this.user.userId, button_color: this.state.currentButtonColor}])
}
await this.drawerClick()
await this.notification.add(this.env._t("保存成功"), {
type: "success",
});
}else {
TypeError("Can't convert object to primitive value");
}
}
- unlick
async cancelClick(){
let userColor = await this.orm.search('dynamic.color.tree', [['user_id', '=', this.user.userId]],{limit:1})
if (userColor.length > 0) {
this.orm.unlink('dynamic.color.tree', [userColor[0]])
this.drawerClick()
this.notification.add(
'重置成功',{type: "danger",});
}
}
- searchRead
async onWillStart(){
let userColor = await this.orm.searchRead('dynamic.color.tree', [['user_id', '=', this.user.userId]], ['bg_color', 'button_color'])
console.log(userColor)
if (userColor.length > 0) {
this.colorClick(userColor[0].bg_color)
this.colorButtonClick(userColor[0].button_color)
}
}