2010-03-03 13:44:05 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
##############################################################################
|
2012-08-06 17:08:41 +00:00
|
|
|
#
|
2010-03-03 13:44:05 +00:00
|
|
|
# OpenERP, Open Source Management Solution
|
|
|
|
# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
|
|
|
|
#
|
|
|
|
# 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
|
2012-08-06 17:08:41 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-03 13:44:05 +00:00
|
|
|
#
|
|
|
|
##############################################################################
|
|
|
|
|
2012-12-06 14:56:32 +00:00
|
|
|
from openerp.osv import osv,fields
|
|
|
|
from openerp.tools.translate import _
|
2010-03-03 13:44:05 +00:00
|
|
|
|
|
|
|
class repair_cancel(osv.osv_memory):
|
|
|
|
_name = 'mrp.repair.cancel'
|
|
|
|
_description = 'Cancel Repair'
|
2010-03-04 07:40:44 +00:00
|
|
|
|
2010-11-19 13:48:01 +00:00
|
|
|
def cancel_repair(self, cr, uid, ids, context=None):
|
2010-04-06 06:52:09 +00:00
|
|
|
""" Cancels the repair
|
|
|
|
@param self: The object pointer.
|
|
|
|
@param cr: A database cursor
|
|
|
|
@param uid: ID of the user currently logged in
|
2012-08-06 17:08:41 +00:00
|
|
|
@param ids: List of IDs selected
|
|
|
|
@param context: A standard dictionary
|
|
|
|
@return:
|
2010-03-10 07:17:18 +00:00
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
if context is None:
|
2010-11-19 13:48:01 +00:00
|
|
|
context = {}
|
2010-03-11 14:24:49 +00:00
|
|
|
record_id = context and context.get('active_id', False) or False
|
2012-08-06 17:08:41 +00:00
|
|
|
assert record_id, _('Active ID not Found')
|
2010-03-11 14:24:49 +00:00
|
|
|
repair_order_obj = self.pool.get('mrp.repair')
|
|
|
|
repair_line_obj = self.pool.get('mrp.repair.line')
|
2010-11-19 13:48:01 +00:00
|
|
|
repair_order = repair_order_obj.browse(cr, uid, record_id, context=context)
|
2012-08-06 17:08:41 +00:00
|
|
|
|
2010-03-11 14:24:49 +00:00
|
|
|
if repair_order.invoiced or repair_order.invoice_method == 'none':
|
2012-08-06 17:08:41 +00:00
|
|
|
repair_order_obj.action_cancel(cr, uid, [record_id], context=context)
|
2010-03-11 14:24:49 +00:00
|
|
|
else:
|
2010-05-20 12:53:50 +00:00
|
|
|
raise osv.except_osv(_('Warning!'),_('Repair order is not invoiced.'))
|
2012-08-06 17:08:41 +00:00
|
|
|
|
2010-12-28 10:41:38 +00:00
|
|
|
return {'type': 'ir.actions.act_window_close'}
|
2012-08-06 17:08:41 +00:00
|
|
|
|
2010-03-04 06:38:57 +00:00
|
|
|
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
2010-04-06 06:52:09 +00:00
|
|
|
""" Changes the view dynamically
|
|
|
|
@param self: The object pointer.
|
|
|
|
@param cr: A database cursor
|
|
|
|
@param uid: ID of the user currently logged in
|
2012-08-06 17:08:41 +00:00
|
|
|
@param context: A standard dictionary
|
2010-04-06 06:52:09 +00:00
|
|
|
@return: New arch of view.
|
2010-03-10 07:17:18 +00:00
|
|
|
"""
|
2010-11-23 07:05:05 +00:00
|
|
|
if context is None:
|
2010-11-19 13:48:01 +00:00
|
|
|
context = {}
|
2010-03-04 06:38:57 +00:00
|
|
|
res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
|
2012-08-06 17:08:41 +00:00
|
|
|
record_id = context and context.get('active_id', False) or False
|
2010-05-10 06:10:36 +00:00
|
|
|
active_model = context.get('active_model')
|
2012-08-06 17:08:41 +00:00
|
|
|
|
2010-05-10 06:10:36 +00:00
|
|
|
if not record_id or (active_model and active_model != 'mrp.repair'):
|
|
|
|
return res
|
2012-08-06 17:08:41 +00:00
|
|
|
|
2010-11-19 13:48:01 +00:00
|
|
|
repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id, context=context)
|
2010-05-10 06:10:36 +00:00
|
|
|
if not repair_order.invoiced:
|
2012-06-29 09:32:56 +00:00
|
|
|
res['arch'] = """
|
|
|
|
<form string="Cancel Repair" version="7.0">
|
|
|
|
<header>
|
|
|
|
<button name="cancel_repair" string="_Yes" type="object" class="oe_highlight"/>
|
|
|
|
or
|
|
|
|
<button string="Cancel" class="oe_link" special="cancel"/>
|
|
|
|
</header>
|
|
|
|
<label string="Do you want to continue?"/>
|
2012-08-06 17:08:41 +00:00
|
|
|
</form>
|
2012-06-29 09:32:56 +00:00
|
|
|
"""
|
2010-03-04 06:38:57 +00:00
|
|
|
return res
|
2010-03-04 07:40:44 +00:00
|
|
|
|
2010-03-03 13:44:05 +00:00
|
|
|
|
|
|
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
|
|
|
|