diff --git a/addons/mrp_repair/__terp__.py b/addons/mrp_repair/__terp__.py
index 2f44e257a80..0cb90558a0c 100644
--- a/addons/mrp_repair/__terp__.py
+++ b/addons/mrp_repair/__terp__.py
@@ -39,9 +39,11 @@
'security/ir.model.access.csv',
'mrp_repair_sequence.xml',
'mrp_repair_wizard.xml',
+ 'mrp_repair_cancel_view.xml',
+ 'mrp_repair_make_invoice_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..6e900939fd6
--- /dev/null
+++ b/addons/mrp_repair/mrp_repair_cancel_view.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+ 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_make_invoice_view.xml b/addons/mrp_repair/mrp_repair_make_invoice_view.xml
new file mode 100644
index 00000000000..6d489e5704b
--- /dev/null
+++ b/addons/mrp_repair/mrp_repair_make_invoice_view.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+ Make Invoice
+ mrp.repair.make_invoice
+ form
+
+
+
+
+
+
+ Make Invoice
+ ir.actions.act_window
+ mrp.repair.make_invoice
+ form
+ form
+ new
+ {'active_ids' : active_ids}
+
+
+
+
+ Make Invoice
+
+ client_action_multi
+ action
+ mrp.repair
+
+
+
+
diff --git a/addons/mrp_repair/mrp_repair_wizard.xml b/addons/mrp_repair/mrp_repair_wizard.xml
index 42383f517cc..b0b2c89d50d 100644
--- a/addons/mrp_repair/mrp_repair_wizard.xml
+++ b/addons/mrp_repair/mrp_repair_wizard.xml
@@ -1,21 +1,22 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/mrp_repair/wizard/__init__.py b/addons/mrp_repair/wizard/__init__.py
index ec3063f01de..4f3075f055c 100644
--- a/addons/mrp_repair/wizard/__init__.py
+++ b/addons/mrp_repair/wizard/__init__.py
@@ -19,7 +19,7 @@
#
##############################################################################
-import wizard_cancel_repair
-import wizard_make_invoice
+import cancel_repair
+import make_invoice
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_repair/wizard/cancel_repair.py b/addons/mrp_repair/wizard/cancel_repair.py
new file mode 100644
index 00000000000..423be2e27b3
--- /dev/null
+++ b/addons/mrp_repair/wizard/cancel_repair.py
@@ -0,0 +1,63 @@
+# -*- 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 netsvc
+from osv import osv,fields
+from tools.translate import _
+
+class repair_cancel(osv.osv_memory):
+ _name = 'mrp.repair.cancel'
+ _description = 'Cancel Repair'
+
+ def cancel_repair(self, cr, uid, ids, context):
+ record_id = context and context.get('record_id', False) or False
+ if record_id:
+ repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])
+
+ if repair_obj[0].invoiced or repair_obj[0].invoice_method == 'none':
+ self.pool.get('mrp.repair').write(cr, uid, record_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 fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+ record_id = context and context.get('record_id', False) or False
+ res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+ if record_id:
+ repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])[0]
+ if not repair_obj.invoice_id:
+ res['arch'] = """
+ """
+ return res
+
+repair_cancel()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp_repair/wizard/make_invoice.py b/addons/mrp_repair/wizard/make_invoice.py
new file mode 100644
index 00000000000..983ebabac25
--- /dev/null
+++ b/addons/mrp_repair/wizard/make_invoice.py
@@ -0,0 +1,52 @@
+# -*- 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 netsvc
+from osv import osv, fields
+
+class make_invoice(osv.osv_memory):
+ _name = 'mrp.repair.make_invoice'
+ _description = 'Make Invoice'
+
+ _columns = {
+ 'group': fields.boolean('Group by partner invoice address'),
+ }
+
+ def make_invoices(self, cr, uid, ids, context):
+ inv = self.browse(cr, uid, ids[0])
+ order_obj = self.pool.get('mrp.repair')
+ newinv = order_obj.action_invoice_create(cr, uid, context['active_ids'], group=inv.group,context=context)
+
+ return {
+ 'domain': [('id','in', newinv.values())],
+ 'name': 'Invoices',
+ 'view_type': 'form',
+ 'view_mode': 'tree,form',
+ 'res_model': 'account.invoice',
+ 'view_id': False,
+ 'context': "{'type':'out_invoice'}",
+ 'type': 'ir.actions.act_window'
+ }
+
+make_invoice()
+
+# 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:
-
diff --git a/addons/mrp_repair/wizard/wizard_make_invoice.py b/addons/mrp_repair/wizard/wizard_make_invoice.py
deleted file mode 100644
index 71aefadfe4b..00000000000
--- a/addons/mrp_repair/wizard/wizard_make_invoice.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
-
-invoice_form = """
-
-"""
-invoice_fields = {
- 'group': {
- 'string': 'Group by partner invoice address',
- 'type':'boolean'
- },
-}
-
-ack_form = """
-"""
-
-ack_fields = {}
-
-def _makeInvoices(self, cr, uid, data, context):
- order_obj = pooler.get_pool(cr.dbname).get('mrp.repair')
- newinv = order_obj.action_invoice_create(cr, uid, data['ids'],group=data['form']['group'],context=context)
-
- return {
- 'domain': [('id','in', newinv.values())],
- 'name': 'Invoices',
- 'view_type': 'form',
- 'view_mode': 'tree,form',
- 'res_model': 'account.invoice',
- 'view_id': False,
- 'context': "{'type':'out_refund'}",
- 'type': 'ir.actions.act_window'
- }
-
-
-class make_invoice(wizard.interface):
- states = {
- 'init' : {
- 'actions' : [],
- 'result' : {'type' : 'form',
- 'arch' : invoice_form,
- 'fields' : invoice_fields,
- 'state' : [('end', 'Cancel'),('invoice', 'Create invoices') ]}
- },
- 'invoice' : {
- 'actions' : [],
- 'result' : {'type' : 'action',
- 'action' : _makeInvoices,
- 'state' : 'end'}
- },
- }
-make_invoice("mrp.repair.make_invoice")
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-