문제

I building a custom module in openerp version 7. I'm facing problems in trying to link an anchor tag in a kanban view item to an action window which will open the clicked on item in a form view.

Here's a sinppet of the kanban view

<a  type="action"  name="myaction">
 <img t-att-src="kanban_image('vessel', 'image_medium', record.id.value)" class="oe_employee_picture" />
</a>

Here's the action that will be invoked on click

<record model="ir.actions.act_window" id="myaction">
  <field name="name">Vessel</field>     
  <field name="res_model">vessel</field>
  <field name="view_type">form</field>
  <field name="view_id" ref="crew_management.view_crew_management_vessels_form"/>
  <field name="view_mode">form</field>
  <field name="context">{'id': active_id}</field>
</record>

Currently when clicking on the link it opens the correct form view but empty. It seems that the active id of the selected item is not passed somehow.

도움이 되었습니까?

해결책

To pass the active id of an object use res_id instead.

<field name="context">{'res_id': active_id}</field>

The complete code would be

<a  type="action"  name="action_id">
       <!-- Anything Here -->
</a

<record model="ir.actions.act_window" id="action_id">
  <field name="name">demo</field>     
  <field name="res_model">demo</field>
  <field name="view_type">form</field>
  <field name="view_id" ref="my_module.demo_view_id"/>
  <field name="view_mode">form</field>
  <field name="context">{'res_id': active_id}</field>
</record>

다른 팁

try passing <field name="context">{'active_id': active_id}</field>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top