This question has been flagged
4 Replies
7950 Views

I would like to be able to create a new project from a template directly in Kanban view. The button in form view is this:

<button string="New Project Based on Template" name="duplicate_template"  type="object" states="template" context="{'parent_id':parent_id}" class="oe_highlight" groups="base.group_user"/>

I inherited the kanban view and can put the button in there, but I can't figure out how to insert the context parent_id correctly?

I googled a lot, looked at the code inside openerp but found no example. I am stuck at

<button string="New Project Based on Template" name="duplicate_template" states="template" type="object" t-att-context="{'parent_id' : record.parent_id.raw_value}" class="oe_highlight" groups="base.group_user" ><span>Create new Project</span></button>

which creates a new project, but without the parent_id set.

How can I define the context in there?

Avatar
Discard
Best Answer

Hi guys, I found a solution (odoo8) :

<button string="New Project Based on Template" name="duplicate_template" states="template" type="object" t-attf-data-context="{'parent_id' : {{record.parent_id.raw_value[0]}}}" class="oe_highlight" groups="base.group_user" ><span>Create new Project</span></button>

Avatar
Discard
Best Answer

I can confirm that the option from Remi still works in Odoo 11:

This works for both buttons and a

<a 
    name="action_you_want"
    type="object"
    t-attf-data-context="{'id' : {{record.id_field.raw_value}}}">
    Link string
</a>
Avatar
Discard
Author Best Answer

Remi Francois:

Your solution does not work for me in v7. I receive an error

Error: QWeb2: Error evaluating template: SyntaxError: missing ) in parenthetical


Avatar
Discard
Best Answer

Same for me - it seems that there is no way to pass context in a kanban view to the called action :(


I did ask more or less the same question here: https://www.odoo.com/forum/help-1/question/how-to-pass-context-to-a-called-action-with-kanban-view-links-or-buttons-83722

Avatar
Discard