[UPD] exp_transation_letters: update _getAttachmentsDomain and add is_system domain

This commit is contained in:
Samir Ladoui 2025-02-12 13:05:36 +01:00
parent 3a555d982b
commit ff9db1adfd
3 changed files with 35 additions and 0 deletions

View File

@ -24,6 +24,7 @@ Letters Managment
'views/letters_view.xml',
'reports/letter_template.xml',
'reports/formal_letter.xml',
'views/editor.xml'
],
'qweb' : [
],

View File

@ -0,0 +1,24 @@
odoo.define("exp_transation_letters.custom_file_widget", function (require) {
"use strict";
var FileWidget = require("wysiwyg.widgets.media").FileWidget;
var session = require("web.session");
FileWidget.include({
/**
* Override _getAttachmentsDomain to restrict attachments to the current user,
* but allow admins (base.group_system) to see everything.
*/
_getAttachmentsDomain: function (needle) {
var domain = this._super.apply(this, arguments);
// Check if the user is an admin (base.group_system) synchronously
if (!session.is_system) {
// Restrict to only attachments created by the current user
domain.push(["create_uid", "=", session.uid]);
}
return domain;
},
});
});

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="custom_web_editor_assets" inherit_id="web_editor.assets_wysiwyg">
<xpath expr="." position="inside">
<script type="text/javascript" src="/exp_transation_letters/static/src/js/media.js"/>
</xpath>
</template>
</odoo>