Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
4 Risposte
18978 Visualizzazioni


Hello friends!!!

Please, i have a button that opens a pop up.

The problem here is that after creating records in that popup and saving.

It will not close automatically the popup depspite the fact in an other case it will disappear (close).

So, my question is how to control my pop up when i want to close it automatically after clicking on save it will be close and when i want to let open it will appear.

Please help really need an answer.

Thanks and regards.

Avatar
Abbandona
Risposta migliore

The default behavior for wizard buttons (button  type="object) as of OpenERP is to immediately close the wizard.

The method called by the button can return an action definition dictionary that will be executed.

When you do not want the wizard to close it is usually because you have several steps. As multi-steps wizards usually have different form views, their button methods simply return actions to open the same wizard record using the next step's view or another view.

Avatar
Abbandona
Autore

Thanks for the answer but i didnt understand how to manage it please

Autore Risposta migliore

Thanks for the answer friend.

Here is my code:

def edit_data(self, cr, uid, ids, context=None):

mod_obj = self.pool.get('ir.model.data')

res = mod_obj.get_object_reference(cr, uid, 'test_paie', 'test_paie_form')

momo_id = self.read(cr, uid, ids,['id','year','period','employee_id'])

print("momo_id =" , momo_id)

ref_id = self.check_data(cr, uid,momo_id[0]['employee_id'][0],momo_id[0]['year'],momo_id[0]['period'])

return {

'name': 'New Data',

'view_type': 'form',

'view_mode': 'form',

'view_id': [res and res[1] or False],

'res_model': 'test_paie',

'context': {'default_employee_id':momo_id[0]['employee_id'][0],'default_period' : str(momo_id[0]['period']), 'default_year' : str(momo_id[0]['year'])},

'type': 'ir.actions.act_window',

'nodestroy': True,

'target': 'new',

'flags' : { 'action_buttons' : True,},

'res_id': ref_id,

}

return {}

Avatar
Abbandona
Risposta migliore

Drees,

If you used the wizard, the Save and Close buttons(on footer) will automatically close the pop up. If you are doing a call of method from wizard, you must return {'type': 'ir.actions.act_window_close'} and your purpose will be served.

If you used dialog box from JS, you must use window.close for that.

How did you manage to add the pop up?

Thanks.

Avatar
Abbandona
Risposta migliore

Hey,

I had the same issue and I solve it by adding footer to the form view :

<footer>
<field name="id" invisible="1"/>
<button string="Create" name="action_close" type="object" class="btn-primary"
attrs="{'invisible': [('id', '!=', False)]}"
/>
<button string="Save" name="action_close" type="object" class="btn-primary"
attrs="{'invisible': [('id', '=', False)]}"
/>

<button string="Cancel" class="btn-secondary" special="cancel"/> footer>

then In my model i define the function action_close : 


def action_close(self):
return {'type': 'ir.actions.act_window_close'}




Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
ago 25
2758
1
lug 25
1103
1
ago 25
1151
0
mag 25
1528
2
apr 25
3724