问题
I would like to know if it's possible to show a One2many field in a kanban view in Odoo (note that I'm not talking about Qweb in templates or reports, only about Qweb in kanban views).
I have a model which has a One2many field named other_contact_ids
. I want to show the name of each contact in the kanban view:
<t t-foreach="record.other_contact_ids.raw_value" t-as="contact">
<p>
<t t-esc="contact.name"/>
</p>
</t>
I'm getting an error, because the t-as
is storing only the ID of the objects in contact
instead of storing the whole object with its fields.
And I think that may be this problem is much related to another question I did earlier: How to use the dot notation in a kanban view in Odoo?
Of course I've tried a lot of ways, for example without using raw_value. And then it shows me the list of attributes of the tag field, like required
, invisible
, depends
, value
, raw_value
, etc...
I've looked for other t-foreach in kanban and for the moment I didn't find anything, so I'm starting to think that it's not possible. Am I right?
回答1:
Yes, with web_one2many_kanban module is available in apps for V7, V8 and V9. Thanks to Serpent Consulting
回答2:
If you go to customer view, then there is a tab called contacts. It is actually a one2many to partner model itself. It think it will be helpful.
回答3:
If it is an image
rooms = fields.One2many('block.rooms', 'block_id')
<t t-foreach="record.rooms.raw_value" t-as="room">
<img t-att-src="kanban_image('block.room', 'image_field_name', room)" t-att-data-member_id="room"/>
</t>
来源:https://stackoverflow.com/questions/30805475/is-it-possible-to-show-an-one2many-field-in-a-kanban-view-in-odoo