[MERGE]: Merged with lp:~openerp-commiter/openobject-addons/osv-memory-wizards to get wizards of mrp_repair.
bzr revid: uco@tinyerp.co.in-20100309062822-a06w0wpk5bz5zr5h
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?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"/>
|
||||
<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>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Make Invoice -->
|
||||
|
||||
<record id="view_make_invoice" model="ir.ui.view">
|
||||
<field name="name">Make Invoice</field>
|
||||
<field name="model">mrp.repair.make_invoice</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Create invoices">
|
||||
<separator colspan="4" string="Do you really want to create the invoices ?" />
|
||||
<field name="group"/>
|
||||
<newline/>
|
||||
<group col="2" colspan="4">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="make_invoices" string="Create Invoice"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_make_invoice" model="ir.actions.act_window">
|
||||
<field name="name">Make Invoice</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.repair.make_invoice</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="context">{'active_ids' : active_ids}</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.values" id="action_make_invoice_related">
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Make Invoice</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_make_invoice'))" />
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="key">action</field>
|
||||
<field name="model">mrp.repair</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
@@ -1,21 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<wizard
|
||||
id="action_cancel_repair"
|
||||
model="mrp.repair"
|
||||
name="mrp.repair.cancel"
|
||||
string="Cancel Repair"
|
||||
menu = "False"
|
||||
multi = "True"
|
||||
/>
|
||||
<wizard
|
||||
id="wizard_mrp_repair_make_invoice"
|
||||
keyword="client_action_multi"
|
||||
model="mrp.repair"
|
||||
name="mrp.repair.make_invoice"
|
||||
multi="True"
|
||||
string="Make invoices"/>
|
||||
<!-- <wizard -->
|
||||
<!-- id="action_cancel_repair" -->
|
||||
<!-- model="mrp.repair" -->
|
||||
<!-- name="mrp.repair.cancel"-->
|
||||
<!-- string="Cancel Repair"-->
|
||||
<!-- menu = "False"-->
|
||||
<!-- multi = "True"-->
|
||||
<!-- />-->
|
||||
|
||||
<!-- <wizard-->
|
||||
<!-- id="wizard_mrp_repair_make_invoice"-->
|
||||
<!-- keyword="client_action_multi"-->
|
||||
<!-- model="mrp.repair"-->
|
||||
<!-- name="mrp.repair.make_invoice"-->
|
||||
<!-- multi="True"-->
|
||||
<!-- string="Make invoices"/>-->
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# -*- 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'
|
||||
|
||||
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'] = """ <form string="Cancel Repair" colspan="4">
|
||||
<group col="2" colspan="2">
|
||||
<button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
|
||||
<button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/>
|
||||
</group>
|
||||
</form>
|
||||
"""
|
||||
return res
|
||||
|
||||
repair_cancel()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
# -*- 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
|
||||
|
||||
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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
invoice_form = """<?xml version="1.0"?>
|
||||
<form string="Create invoices">
|
||||
<separator colspan="4" string="Do you really want to create the invoices ?" />
|
||||
<field name="group"/>
|
||||
</form>
|
||||
"""
|
||||
invoice_fields = {
|
||||
'group': {
|
||||
'string': 'Group by partner invoice address',
|
||||
'type':'boolean'
|
||||
},
|
||||
}
|
||||
|
||||
ack_form = """<?xml version="1.0"?>
|
||||
<form string="Create invoices">
|
||||
<separator string="Invoices created" />
|
||||
</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:
|
||||
|
||||
Reference in New Issue
Block a user