This question has been flagged
2 Replies
5255 Views

I want to make text ellipsis in kanban view.

Here is my code:

<kanban>
	<field name="logo_img"/>
	<field name="name"/>
	<field name="info"/>
	<templates>
		<t t-name="kanban-box">
			<div class="oe_kanban_global_click">
				<div class="o_kanban_image">
					<img t-att-src="kanban_image('product.manufacturer', 'logo_img', record.id.value)"/>
				</div>
				<div class="oe_kanban_details">
					<strong>
						<field name="name"/>
					</strong>
					<div>
						<t t-esc="kanban_text_ellipsis(record.info.value, 32)" />
					</div>
				</div>
			</div>
		</t>
	</templates>
</kanban>

But I get an error

TypeError: dict.kanban_text_ellipsis is not a function
Avatar
Discard
Best Answer

This part of the web_kanban addon was completely rewritten and kanban_text_ellipsis() was dropped since you can achieve the same goal with CSS. The docs has been updated to reflect this.

More info: https://github.com/odoo/odoo/pull/17082

If you really need that exact functionnality, you'll have to make a JS extension which includes the function on web_kanban.Record. Here's the JS I did for Odoo 10:

odoo.define('my_module.Record', function (require) {
  "use strict";

  var Record = require('web_kanban.Record');

  var KanbanRecord = Record.include({
    kanban_text_ellipsis: function(s, size) {
      size = size || 160;
      if (!s) {
        return '';
      } else if (s.length <= size) {
        return s;
      } else {
        return s.substr(0, size) + '...';
      }
    }
  });

  return KanbanRecord;
});


Avatar
Discard
Best Answer

Hi Nikola, I have the same issue with version 9. Were you able to solve it?

Avatar
Discard