From ea4c93472879f042f8aa343d5c42fa6c2bd5cfce Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Tue, 17 Dec 2019 16:29:13 +0000 Subject: [PATCH 1/3] [IMP] web: allow background-style images for custom models The `FieldBinaryImage` assumes that the image mixin is used to manage its fields - this is mostly true, until you use custom fields. This commit makes using the 'background' option of the Image widget possible by fallbacking the thumbnail field's name to the name of the field itself instead of `image_128` when we're dealing with a custom field. --- addons/web/static/src/js/fields/basic_fields.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 996e759a70a..f2c44891ea2 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1875,7 +1875,8 @@ var FieldBinaryImage = AbstractFieldBinary.extend({ this.$el.addClass(this.attrs.class); } - var urlThumb = this._getImageUrl(this.model, this.res_id, 'image_128', unique); + const image_field = this.field.manual ? this.name:'image_128'; + var urlThumb = this._getImageUrl(this.model, this.res_id, image_field, unique); this.$el.empty(); $img = this.$el; From 18e06fa90aadf126602e6d2ea1fff7ef13be3a73 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Tue, 17 Dec 2019 16:31:26 +0000 Subject: [PATCH 2/3] [IMP] web: kanban content container The 'new' (read: the classes not in the 'compatibility layer section') classes of the kanban views did not allow to cleanly separate an image header from a content container. This commit adds such a container, allowing a very simple layout that should work all the time for a typical 'card with left image and right content layout': ```xml
``` Before this commit, the absence of a container for the right side meant that the top/body/bottom were flex-growed in a flex-direction: row element, appearing as 3 columns instead of rows. --- addons/web/static/src/scss/kanban_view.scss | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/web/static/src/scss/kanban_view.scss b/addons/web/static/src/scss/kanban_view.scss index 84e52bda039..93605ab5640 100644 --- a/addons/web/static/src/scss/kanban_view.scss +++ b/addons/web/static/src/scss/kanban_view.scss @@ -58,6 +58,13 @@ width: $o-kanban-color-border-width; } + .o_kanban_record_details { + display: flex; + flex-direction: column; + justify-content: space-between; + width: 100%, + } + // Inner Sections .o_kanban_record_top, .o_kanban_record_body { margin-bottom: $o-kanban-inner-hmargin; From c2fccc9118852460df52bf216785b13afcab42b5 Mon Sep 17 00:00:00 2001 From: Damien Bouvy Date: Wed, 18 Dec 2019 17:54:36 +0000 Subject: [PATCH 3/3] [IMP] base: make name of custom models `copied` by default Copying a custom model's record seems pointless by default, since no field is actually copied. It makes sense to copy at least the `x_name` field, to make it clear to the user that the system understood it was duplicating something and not just creating something entirely new. --- odoo/addons/base/models/ir_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_model.py b/odoo/addons/base/models/ir_model.py index a33f80e9d9b..9c69d8057df 100644 --- a/odoo/addons/base/models/ir_model.py +++ b/odoo/addons/base/models/ir_model.py @@ -96,7 +96,7 @@ class IrModel(models.Model): def _default_field_id(self): if self.env.context.get('install_mode'): return [] # no default field when importing - return [(0, 0, {'name': 'x_name', 'field_description': 'Name', 'ttype': 'char'})] + return [(0, 0, {'name': 'x_name', 'field_description': 'Name', 'ttype': 'char', 'copied': True})] name = fields.Char(string='Model Description', translate=True, required=True) model = fields.Char(default='x_', required=True, index=True)