Skip to content

Commit

Permalink
cms_form: add basic file widget
Browse files Browse the repository at this point in the history
  • Loading branch information
simahawk committed Sep 18, 2023
1 parent 3a01d10 commit 99e456f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cms_form/models/widgets/widget_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,11 @@ class ImageWidget(models.AbstractModel):
_description = "CMS Form image widget"

w_template = fields.Char(default="cms_form.field_widget_image")


class FileWidget(models.AbstractModel):
_name = "cms.form.widget.binary"
_inherit = "cms.form.widget.binary.mixin"
_description = "CMS Form file widget"

w_template = fields.Char(default="cms_form.field_widget_file")
11 changes: 11 additions & 0 deletions cms_form/templates/widgets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,15 @@ License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
</t>
</div>
</template>
<template id="field_widget_file" name="CMS form image field widget">
<input
type="file"
t-att-name="widget.html_fname"
t-att-id="widget.w_fname"
t-attf-class="form-control #{widget.w_css_klass}"
t-att-required="widget.w_field['required'] and '1' or None"
t-att-readonly="widget.html_readonly or None"
t-att-disabled="'disabled' if widget.html_readonly else None"
/>
</template>
</odoo>

0 comments on commit 99e456f

Please sign in to comment.