[REF] mrp_repair: Converted 'Cancel Repair' wizard to osv_memory wizard.
bzr revid: uco@tinyerp.co.in-20100303134405-jssoxxdop0tuttyn
This commit is contained in:
parent
83ac35ae9a
commit
a2b449f033
|
@ -39,9 +39,10 @@
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'mrp_repair_sequence.xml',
|
'mrp_repair_sequence.xml',
|
||||||
'mrp_repair_wizard.xml',
|
'mrp_repair_wizard.xml',
|
||||||
|
'mrp_repair_cancel_view.xml',
|
||||||
'mrp_repair_view.xml',
|
'mrp_repair_view.xml',
|
||||||
'mrp_repair_workflow.xml',
|
'mrp_repair_workflow.xml',
|
||||||
'mrp_repair_report.xml'
|
'mrp_repair_report.xml',
|
||||||
],
|
],
|
||||||
'demo_xml': [],
|
'demo_xml': [],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<openerp>
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<!-- Cancel Repair -->
|
||||||
|
|
||||||
|
<record id="view_cancel_repair" model="ir.ui.view">
|
||||||
|
<field name="name">Cancel Repair</field>
|
||||||
|
<field name="model">mrp.repair.cancel</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="Requisition Request">
|
||||||
|
<label string="This operation will cancel the Repair process, but will not cancel it's Invoice. Do you want to continue?" colspan="4"/>
|
||||||
|
<field name="cancel"/>
|
||||||
|
<field name="repair_id" invisible="1"/>
|
||||||
|
<newline/>
|
||||||
|
<group col="2" colspan="4">
|
||||||
|
<button icon='gtk-cancel' special="cancel"
|
||||||
|
string="No" />
|
||||||
|
<button name="cancel_repair" string="Yes"
|
||||||
|
colspan="1" type="object" icon="gtk-ok" />
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="action_cancel_repair" model="ir.actions.act_window">
|
||||||
|
<field name="name">Cancel Repair</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">mrp.repair.cancel</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_mode">form</field>
|
||||||
|
<field name="target">new</field>
|
||||||
|
<field name="context">{'record_id' : active_id}</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.values" id="action_cancel_repair_related">
|
||||||
|
<field name="model_id" ref="mrp_repair.model_mrp_repair" />
|
||||||
|
<field name="object" eval="1" />
|
||||||
|
<field name="name">Cancel Repair</field>
|
||||||
|
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_cancel_repair'))" />
|
||||||
|
<field name="key">action</field>
|
||||||
|
<field name="model">mrp.repair</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
|
</openerp>
|
|
@ -1,14 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<openerp>
|
<openerp>
|
||||||
<data>
|
<data>
|
||||||
<wizard
|
<!-- <wizard -->
|
||||||
id="action_cancel_repair"
|
<!-- id="action_cancel_repair" -->
|
||||||
model="mrp.repair"
|
<!-- model="mrp.repair" -->
|
||||||
name="mrp.repair.cancel"
|
<!-- name="mrp.repair.cancel"-->
|
||||||
string="Cancel Repair"
|
<!-- string="Cancel Repair"-->
|
||||||
menu = "False"
|
<!-- menu = "False"-->
|
||||||
multi = "True"
|
<!-- multi = "True"-->
|
||||||
/>
|
<!-- />-->
|
||||||
|
|
||||||
<wizard
|
<wizard
|
||||||
id="wizard_mrp_repair_make_invoice"
|
id="wizard_mrp_repair_make_invoice"
|
||||||
keyword="client_action_multi"
|
keyword="client_action_multi"
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import wizard_cancel_repair
|
import cancel_repair
|
||||||
import wizard_make_invoice
|
import wizard_make_invoice
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
|
@ -1,81 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# 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
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
import wizard
|
|
||||||
import netsvc
|
|
||||||
import pooler
|
|
||||||
|
|
||||||
cancel_form = """<?xml version="1.0"?>
|
|
||||||
<form string="Cancel Repair...??">
|
|
||||||
<label colspan="4" string="This operation will cancel the Repair process, but will not cancel it's Invoice.\nDo you want to continue?" />
|
|
||||||
</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:
|
|
||||||
|
|
Loading…
Reference in New Issue