diff --git a/addons/mrp_repair/__terp__.py b/addons/mrp_repair/__terp__.py
index 2f44e257a80..5b20d6737d4 100644
--- a/addons/mrp_repair/__terp__.py
+++ b/addons/mrp_repair/__terp__.py
@@ -39,9 +39,10 @@
'security/ir.model.access.csv',
'mrp_repair_sequence.xml',
'mrp_repair_wizard.xml',
+ 'mrp_repair_cancel_view.xml',
'mrp_repair_view.xml',
'mrp_repair_workflow.xml',
- 'mrp_repair_report.xml'
+ 'mrp_repair_report.xml',
],
'demo_xml': [],
'installable': True,
diff --git a/addons/mrp_repair/mrp_repair_cancel_view.xml b/addons/mrp_repair/mrp_repair_cancel_view.xml
new file mode 100644
index 00000000000..b865f5f5a77
--- /dev/null
+++ b/addons/mrp_repair/mrp_repair_cancel_view.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+ Cancel Repair
+ mrp.repair.cancel
+ form
+
+
+
+
+
+
+ Cancel Repair
+ ir.actions.act_window
+ mrp.repair.cancel
+ form
+ form
+ new
+ {'record_id' : active_id}
+
+
+
+
+
+ Cancel Repair
+
+ action
+ mrp.repair
+
+
+
+
diff --git a/addons/mrp_repair/mrp_repair_wizard.xml b/addons/mrp_repair/mrp_repair_wizard.xml
index 42383f517cc..fd7c04d5ece 100644
--- a/addons/mrp_repair/mrp_repair_wizard.xml
+++ b/addons/mrp_repair/mrp_repair_wizard.xml
@@ -1,14 +1,15 @@
-
+
+
+
+
+
+
+
+
+
).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+##############################################################################
+
+import netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class repair_cancel(osv.osv_memory):
+ _name = 'mrp.repair.cancel'
+ _description = 'Cancel Repair'
+
+ _columns = {
+ 'repair_id': fields.many2one('mrp.repair', 'Repair ID', readonly=True),
+ 'cancel': fields.boolean('Cancel Repair'),
+ }
+
+ _defaults = {
+ 'cancel': lambda *a: False,
+ }
+
+ def cancel_repair(self, cr, uid, ids, context):
+ repair_cancel = self.browse(cr, uid, ids[0])
+ repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [repair_cancel.repair_id.id])
+ if repair_obj[0].invoice_id and repair_cancel.cancel:
+ self.pool.get('mrp.repair').write(cr, uid, repair_cancel.repair_id.id, {'state':'cancel'})
+ mrp_line_obj = self.pool.get('mrp.repair.line')
+ for line in repair_obj:
+ mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'})
+ else:
+ raise osv.except_osv(_('Warning!'),_('Repair is not cancelled. It is not invoiced.'))
+ return {}
+
+ def default_get(self, cr, uid, fields, context=None):
+ record_id = context and context.get('record_id', False) or False
+ res = super(repair_cancel, self).default_get(cr, uid, fields, context=context)
+ if record_id:
+ repair_id = self.pool.get('mrp.repair').browse(cr, uid, record_id, context=context)
+ res['repair_id'] = repair_id.id
+ return res
+
+repair_cancel()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp_repair/wizard/wizard_cancel_repair.py b/addons/mrp_repair/wizard/wizard_cancel_repair.py
deleted file mode 100644
index d895096ce6f..00000000000
--- a/addons/mrp_repair/wizard/wizard_cancel_repair.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-# OpenERP, Open Source Management Solution
-# Copyright (C) 2004-2010 Tiny SPRL ().
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see .
-#
-##############################################################################
-
-import wizard
-import netsvc
-import pooler
-
-cancel_form = """
-
-"""
-
-cancel_fields = {}
-
-def check_state(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])[0]
- if repair_obj.invoice_id:
- return 'display'
- else:
- pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
- return 'end'
-
-
-def _cancel_repair(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- repair_obj = pool.get('mrp.repair').browse(cr, uid, data['ids'])
- pool.get('mrp.repair').write(cr,uid,data['ids'],{'state':'cancel'})
- mrp_line_obj = pool.get('mrp.repair.line')
- for line in repair_obj:
- mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'})
- return {}
-
-class repair_cancel(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'choice', 'next_state' : check_state}
- },
-
- 'display' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : cancel_form,
- 'fields' : cancel_fields,
- 'state' : [('end', 'No'),('yes', 'Yes') ]}
- },
- 'yes' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action' : _cancel_repair,
- 'state' : 'end'}
- },
- 'end' : {
- 'actions' : [],
- 'result': {'type': 'state', 'state': 'end'},
- },
- }
-repair_cancel("mrp.repair.cancel")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-