[IMP] web: allow to give a maximum of file to upload in m2m binary

People may have used a m2m where we don't really want a m2m relationship.

Task-3605612 (WhatsApp: Fix header / upload / reporting usage)

closes odoo/odoo#160332

X-original-commit: 910e41baf0d6ab558c53d41e511b3f10bf9860ad
Related: odoo/enterprise#59987
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Akshat Trivedi
2024-04-03 16:27:12 +00:00
committed by Thibault Delavallée
parent 1b0dbb3645
commit a54e64d720
3 changed files with 16 additions and 1 deletions
+7
View File
@@ -4981,6 +4981,13 @@ msgstr ""
msgid "Not active state, click to change it"
msgstr ""
#. module: web
#. odoo-javascript
#: code:addons/web/static/src/views/fields/many2many_binary/many2many_binary_field.js:0
#, python-format
msgid "Number of files"
msgstr ""
#. module: web
#. odoo-javascript
#: code:addons/web/static/src/core/emoji_picker/emoji_data.js:0
@@ -18,6 +18,7 @@ export class Many2ManyBinaryField extends Component {
...standardFieldProps,
acceptedFileExtensions: { type: String, optional: true },
className: { type: String, optional: true },
numberOfFiles: { type: Number, optional: true },
};
setup() {
@@ -74,6 +75,11 @@ export const many2ManyBinaryField = {
name: "accepted_file_extensions",
type: "string",
},
{
label: _t("Number of files"),
name: "number_of_files",
type: "integer",
},
],
supportedTypes: ["many2many"],
isEmpty: () => false,
@@ -84,6 +90,7 @@ export const many2ManyBinaryField = {
extractProps: ({ attrs, options }) => ({
acceptedFileExtensions: options.accepted_file_extensions,
className: attrs.class,
numberOfFiles: options.number_of_files,
}),
};
@@ -8,7 +8,8 @@
<t t-call="Many2ManyBinaryField.attachment_preview"/>
</t>
</div>
<div t-if="!props.readonly" class="oe_add">
<div t-if="!props.readonly &amp;&amp; (!props.numberOfFiles or files.length &lt; props.numberOfFiles)"
class="oe_add">
<FileInput
acceptedFileExtensions="props.acceptedFileExtensions"
multiUpload="true"