Reputation: 3207
I open the wizard from button in OpenERP 7. But when click on button Compute of wizard my wizard got close but I do not want to close the wizard on button click of Compute instead of my wizard close when click on button Close of wizard. I am using OpenERP 7.
class test_pass_student(osv.osv_memory):
_name = 'test.pass.student'
_column ={
'pass_id': fields.many2one('pass.student', 'Passed'),
'student_id':fields.many2one('student.student', 'Student'),
}
test_pass_student()
def _reopen(self, res_id, model):
return {'type': 'ir.actions.act_window',
'view_mode': 'form',
'view_type': 'form',
'res_id': res_id,
'res_model': self._name,
'target': 'new',
'context': {
'default_model': model,
},
}
class pass_student(osv.osv_memory):
_name = 'pass.student'
_columns = {
'student_id':fields.many2one('student.student', 'Student'),
'lines': fields.one2many('test.pass.student','pass_id', 'Passed students'),
}
def add_student(self, cr, uid, ids,context=None):
lines_obj = self.pool.get('test.pass.student')
for record in self.browse(cr,uid,ids,context):
for line in record.student_id.scores:
if line.pass_score > 50:
lines_obj.create(cr,uid,{'pass_id': record.id,'student_id':line.student_id.id})
return _reopen(self, record.id, record._model)
pass_student()
Shen S select first student check, if his/her marks greater than 50 then added in one2many, and then again check another student, same things repeat again.
Upvotes: 1
Views: 4934
Reputation: 11
For closing the wizard on button click add this code on view form xml:
<button string="Cancel" class="oe_link" special="cancel"/>
Upvotes: 1
Reputation: 21
I reply myself, in the wizard if, instead of button type workflow, I put button type object and there trigger wf works (no close), but is that the right path?
If someone need this is my object button event code (for my picking.import.wizard wizard):
def signal_import_load_2(self, cr, uid, ids, context=None):
import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, 'picking.import.wizard', ids[0], 'signal_import_load', cr)
view_id = self.pool.get('ir.ui.view').search(cr,uid,[('model','=','picking.import.wizard'), ('name','=','Wizard import picking from CSV')])
return {
'type': 'ir.actions.act_window',
'name': "Import",
'res_model': 'picking.import.wizard',
'res_id': ids[0],
'view_type': 'form',
'view_mode': 'form',
'view_id': view_id,
'target': 'new',
'nodestroy': True,
}
Upvotes: 0
Reputation: 16743
no need to write separate method to open wizard again. You can just take object reference and return it with view id. for example.
def add_student(self, cr, uid, ids,context=None):
model_data_obj = self.pool.get('ir.model.data')
lines_obj = self.pool.get('test.pass.student')
for record in self.browse(cr,uid,ids,context):
for line in record.student_id.scores:
if line.pass_score > 50:
lines_obj.create(cr,uid,{'pass_id': record.id,'student_id':line.student_id.id})
view_rec = model_data_obj.get_object_reference(cr, uid, 'pass_student', 'add_student_form_view_id')
view_id = view_rec and view_rec[1] or False
return {
'view_type': 'form',
'view_id' : [view_id],
'view_mode': 'form',
'res_model': 'pass.student',
'type': 'ir.actions.act_window',
'target': 'new',
'context': context
}
Hope it will help you!
Upvotes: 0
Reputation: 4117
The default behavior for wizard buttons (with type="object
) as of OpenERP 6.1 (hence in 7.0 as well) is to immediately close the wizard pop-up. 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 (it could also be the same view if it needs to be displayed again).
You can find examples in the official addons source code, for example in the mail.compose.message
wizard modified by the email_template
module, that uses a similar trick to re-open itself.
This question and this other one may also contain useful examples.
Upvotes: 1