[FIX] handle multilines in <label> tags of form views

bzr revid: chs@openerp.com-20120207140628-4yxgxv849cjg5fl9
This commit is contained in:
Christophe Simonis 2012-02-07 15:06:28 +01:00
parent ce65bc3ac3
commit 7d05f195d9
3 changed files with 12 additions and 1 deletions

View File

@ -1307,6 +1307,10 @@ label.error {
white-space: normal; white-space: normal;
} }
.openerp .oe_forms .oe_form_paragraph.oe_multilines {
white-space: pre;
}
.openerp .oe_form_field_one2many .oe-actions h3.oe_view_title, .openerp .oe_form_field_one2many .oe-actions h3.oe_view_title,
.openerp .oe_form_field_one2many_list .oe-actions h3.oe_view_title{ .openerp .oe_form_field_one2many_list .oe-actions h3.oe_view_title{
display: inline; display: inline;

View File

@ -1176,6 +1176,11 @@ openerp.web.form.WidgetLabel = openerp.web.form.Widget.extend({
this._super(view, node); this._super(view, node);
if (this.node.tag == 'label' && !this.string && this.node.children.length) {
this.string = this.node.children[0];
this.align = 'left';
}
if (this.node.tag == 'label' && (this.align === 'left' || this.node.attrs.colspan || (this.string && this.string.length > 32))) { if (this.node.tag == 'label' && (this.align === 'left' || this.node.attrs.colspan || (this.string && this.string.length > 32))) {
this.form_template = "WidgetParagraph"; this.form_template = "WidgetParagraph";
this.colspan = parseInt(this.node.attrs.colspan || 1, 10); this.colspan = parseInt(this.node.attrs.colspan || 1, 10);
@ -1184,6 +1189,8 @@ openerp.web.form.WidgetLabel = openerp.web.form.Widget.extend({
if (isNaN(parseFloat(this.node.attrs.align))) { if (isNaN(parseFloat(this.node.attrs.align))) {
this.align = 'left'; this.align = 'left';
} }
this.multilines = this.string && _.str.lines(this.string).length > 1;
} else { } else {
this.colspan = 1; this.colspan = 1;
this.width = '1%'; this.width = '1%';

View File

@ -927,7 +927,7 @@
</ul> </ul>
</t> </t>
<t t-name="WidgetParagraph"> <t t-name="WidgetParagraph">
<p t-attf-class="oe_form_paragraph oe_align_#{widget.align}"><t t-esc="widget.string"/></p> <p t-attf-class="oe_form_paragraph oe_align_#{widget.align} #{widget.multilines ? 'oe_multilines' : ''}"><t t-esc="widget.string"/></p>
</t> </t>
<t t-name="FieldChar"> <t t-name="FieldChar">
<input t-att-type="widget.password ? 'password' : 'text'" size="1" <input t-att-type="widget.password ? 'password' : 'text'" size="1"