Odoo Help


open the same form from button

Julian Osorio
on 5/11/16, 7:08 PM 709 views
I want to doisthe following

1. Aformis filled
2.when clickingon the "done" buttonanda dialog boxappears with twofields of the sameform
3.fills andclick onaccept thedialog
4.changes the status of"draft"to"done"
5.the two fieldson the form

my questionsis

1. the contextto pass dataused inthe actionorthe button

aswould defineinpythonmove from"drafta" done "

Thank you

    <button name="%(action_done)d" type="action"
attrs="{'invisible': [('state','=', 'done')]}"
<field name="name"/>
<field name="field 1" attrs="{'invisible': ['!', ('state', '=', 'done')]}"/>
<field name="field 2" attrs="{'invisible': ['!', ('state', '=', 'done')]}""/>

          <field name="arch" type="xml">
<group class="oe_title">
<field name="field 1"/>
<field name="field 2"/>
<button name="action_done" string="done" type="object" class="btn btn-sm btn-primary"/>
<button string="Cancel" class="btn btn-sm btn-default" special="cancel"/>

    <record id="action_done" model="ir.actions.act_window">
<field name="name">done</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">model.model</field>
<field name="view_mode">form</field>
<field name="view_id" ref="view_model_done_form"/>
<field name="target">new</field>


Gavin Yap
On 5/12/16, 3:59 AM

I believe you cannot do in this way.

First of all, in your "action_done", it does not have a res_id reference. To would meant that when you open up the form, the form does not know which record in the model to reference to and hence, your popup form will be empty.

What you can do is instead of using "%(action_done)d", you could create a method in your model.

def action_done(self):
 id = self.id
   return {
'name': self.name,
'res_model': 'module.Model',
'type': 'ir.actions.act_window',
'context': {},
'view_mode': 'form',
'view_type': 'form',
      'view_id': self.env.ref('module.my_form_view'),
'target': 'current',

and change your button to

<button name="action_done" type="object" .. />

Julian Osorio
On 5/12/16, 3:19 PM


it worked

def action_done(self):
return {
'name': self.name,
'res_model': 'calendar.event',
'type': 'ir.actions.act_window',
'res_id': self.id,
'context': {},
'view_type': 'form',
'view_mode': 'form',
'views': [(self.env.ref('ceiinc_crm.view_calendar_event_done_form').id, 'form')],
'view_id': self.env.ref('ceiinc_crm.view_calendar_event_done_form').id,
'target': 'new',

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 5/11/16, 7:08 PM
Seen: 709 times
Last updated: 5/12/16, 3:19 PM