在Odoo 8中,我向模型添加了convertDataURItoFile(dataURI, fileName) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
var ia = new Uint8Array(ab);
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
// write the ArrayBuffer to a blob, and you're done
var blob: any = new Blob([ia], { type: mimeString });
//A Blob() is almost a File() - it's just missing the two properties below which we will add
blob.lastModifiedDate = new Date();
blob.name = fileName;
//Cast to a File() type
return <File>blob;
}
,限制了某些用户的写访问权限。我想个性化限制用户点击“保存”后收到的错误消息。我不能仅使用ir.rule
修改翻译,因为新消息必须特定于该模型。
有没有办法在Odoo 8中轻松完成此操作而无需修改Odoo本身的源代码?
答案 0 :(得分:0)
我假设Save
按钮调用模型的write
方法。在这种情况下,您可以覆盖此方法以在满足相应条件时引发自定义错误消息。您拥有调用uid
方法的用户的write
,因此它必须足以达到所需的效果。