[REF] *: remove t-set of a property of an Object

As all the templates are now imported in the owl app, the templates must
comply to owl.

t-set of a property of an Object is not allowed in owl.

Part of task~3443861

Part-of: odoo/odoo#130467
This commit is contained in:
Jorge Pinna Puissant
2023-08-11 14:32:28 +02:00
committed by Samuel Degueldre
parent f956e83c74
commit 363251986d
2 changed files with 23 additions and 20 deletions
@@ -161,8 +161,28 @@ const FormEditor = options.Class.extend({
if (!field.id) {
field.id = weUtils.generateHTMLId();
}
const params = { field: { ...field } };
if (["url", "email", "tel"].includes(field.type)) {
params.field.inputType = field.type;
}
if (["boolean", "selection", "binary"].includes(field.type)) {
params.field.isCheck = true;
}
if (field.type === "one2many" && field.relation !== "ir.attachment") {
params.field.isCheck = true;
}
if (field.custom && !field.string) {
params.field.string = field.name;
}
if (field.type === "description") {
if (field.description) {
params.default_description = _t("Describe your field here.");
} else if (["email_cc", "email_to"].includes(field.name)) {
params.default_description = _t("Separate email addresses with a comma.");
}
}
const template = document.createElement('template');
template.content.append(renderToElement("website.form_field_" + field.type, {field: field}));
template.content.append(renderToElement("website.form_field_" + field.type, params));
if (field.description && field.description !== true) {
$(template.content.querySelector('.s_website_form_field_description')).replaceWith(field.description);
}
@@ -674,6 +694,8 @@ options.registry.WebsiteFormEditor = FormEditor.extend({
field: {
name: fieldName,
value: value,
dnone: true,
formatInfo: {},
},
});
this.$target.find('.s_website_form_submit').before(hiddenField);
@@ -56,7 +56,6 @@
</t>
<t t-name="website.form_label_content">
<t t-if="field.custom and !field.string" t-set="field.string" t-value="field.name"/>
<span class="s_website_form_label_content" t-esc="field.string"/>
<t t-if="field.required or field.modelRequired">
<span class="s_website_form_mark" t-if="field.formatInfo.requiredMark" t-esc="' ' + field.formatInfo.mark"/>
@@ -69,15 +68,6 @@
<t t-name="website.form_field_description">
<!-- The actual value for this case is handled in JS as it can be -->
<!-- edited with formatting by the user -->
<t t-set="default_description">
<t t-if="field.description">
Describe your field here.
</t>
<t t-elif="['email_cc', 'email_to'].includes(field.name)">
Separate email addresses with a comma.
</t>
</t>
<t t-set="default_description" t-value="default_description and default_description.trim()"/>
<div t-if="default_description" class="s_website_form_field_description small form-text text-muted" contenteditable="true">
<t t-esc="default_description"/>
</div>
@@ -85,8 +75,6 @@
<!-- Hidden Field -->
<t t-name="website.form_field_hidden">
<t t-set="field.dnone" t-value="true"/>
<t t-set="field.formatInfo" t-value="{}"/>
<t t-call="website.form_field">
<input
type="hidden"
@@ -116,19 +104,16 @@
<!-- Email Field -->
<t t-name="website.form_field_email">
<t t-set="field.inputType" t-value="'email'"/>
<t t-call="website.form_field_char"/>
</t>
<!-- Telephone Field -->
<t t-name="website.form_field_tel">
<t t-set="field.inputType" t-value="'tel'"/>
<t t-call="website.form_field_char"/>
</t>
<!-- Url Field -->
<t t-name="website.form_field_url">
<t t-set="field.inputType" t-value="'url'"/>
<t t-call="website.form_field_char"/>
</t>
@@ -230,7 +215,6 @@
<!-- Boolean Field -->
<t t-name="website.form_field_boolean">
<t t-set="field.isCheck" t-value="true"/>
<t t-call="website.form_field">
<div class="form-check">
<input
@@ -248,7 +232,6 @@
<!-- Selection Field -->
<t t-name="website.form_field_selection">
<t t-set="field.isCheck" t-value="true"/>
<t t-call="website.form_field">
<t t-if="!field.records">
<input
@@ -323,7 +306,6 @@
</t>
<!-- Generic one2many -->
<t t-if="field.relation != 'ir.attachment'">
<t t-set="field.isCheck" t-value="true"/>
<t t-call="website.form_field">
<t t-if="!field.records || field.records.length == 0">
<input
@@ -372,7 +354,6 @@
<!-- Binary Field -->
<t t-name="website.form_field_binary">
<t t-set="field.isCheck" t-value="true"/>
<t t-call="website.form_field">
<input
type="file"