3 changed files with 36 additions and 57 deletions
@ -1,59 +1,33 @@ |
|||||
/** @odoo-module */ |
/** @odoo-module */ |
||||
import { |
import { patch } from "@web/core/utils/patch"; |
||||
FormArchParser |
import { useService } from "@web/core/utils/hooks"; |
||||
} from "@web/views/form/form_arch_parser"; |
import { Chatter } from "@mail/components/chatter/chatter"; |
||||
import { |
import { ChatterContainer } from "@mail/components/chatter_container/chatter_container"; |
||||
patch |
|
||||
} from "@web/core/utils/patch"; |
|
||||
import { |
|
||||
archParseBoolean |
|
||||
} from "@web/views/utils"; |
|
||||
var rpc = require('web.rpc'); |
var rpc = require('web.rpc'); |
||||
|
const {onMounted} = owl; |
||||
patch(FormArchParser.prototype, "parse", { |
import { FormRenderer } from '@web/views/form/form_renderer'; |
||||
/** |
/** Patched FormRender for hiding the chatter. */ |
||||
* Patched version of the 'parse' method in 'FormArchParser'. |
patch(Chatter.prototype, "parse", { |
||||
* Modifies the parsing behavior by removing the chatter node from the XML if the model is configured to hide the chatter. |
async setup() { |
||||
* |
this._super(...arguments) |
||||
* @param {string} arch - The XML architecture to parse. |
this.orm = useService("orm"); |
||||
* @param {Object} models - The model definitions. |
onMounted(async () => { |
||||
* @param {string} modelName - The name of the model being parsed. |
try { |
||||
* @returns {Object} - The parsed result. |
// Fetch the list of model names from the configuration parameter
|
||||
*/ |
const response = await this.orm.call("ir.config_parameter", "get_param", [ |
||||
parse(arch, models, modelName) { |
"chatter_enable.model_ids", ]) |
||||
const parsedResult = this._super.apply(this, arguments); |
const model = await rpc.query({ |
||||
rpc.query({ |
model: "ir.model", |
||||
model: "ir.model", |
method: "search", |
||||
method: "search", |
args: [[["model", "=", this.chatter.threadModel]]], |
||||
args: [ |
kwargs: { limit: 1 },}) |
||||
[ |
if ( response && response.includes(model[0]) |
||||
["model", "=", modelName] |
) { |
||||
] |
this.el.classList.add("d-none") |
||||
], |
} |
||||
kwargs: { |
}catch (error) { |
||||
limit: 1 |
console.error("Error fetching configuration parameter:", error); |
||||
}, |
} |
||||
}).then((result) => { |
}) |
||||
const resModelId = result; |
|
||||
rpc.query({ |
|
||||
model: "ir.config_parameter", |
|
||||
method: "get_param", |
|
||||
args: ["chatter_enable.model_ids"], |
|
||||
}).then((result) => { |
|
||||
const modelIds = JSON.parse(result); |
|
||||
if (modelIds){ |
|
||||
if (modelIds.includes(resModelId[0])) { |
|
||||
const { |
|
||||
xmlDoc |
|
||||
} = parsedResult; |
|
||||
const chatterNode = xmlDoc.querySelector("div.oe_chatter"); |
|
||||
if (chatterNode && chatterNode.parentElement) { |
|
||||
chatterNode.parentElement.removeChild(chatterNode); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
}) |
|
||||
}) |
|
||||
return parsedResult; |
|
||||
}, |
}, |
||||
}); |
}); |
||||
|
Loading…
Reference in new issue