[ADD, REF] mrp_repair: Added osv_memory wizard for 'Make Invoices'. Optimized the code for 'Cancel Repair' wizard.
bzr revid: uco@tinyerp.co.in-20100304074044-kbb4m3ym2toh7a0a
This commit is contained in:
parent
fb5b3adb20
commit
dd224ef319
|
@ -40,6 +40,7 @@
|
||||||
'mrp_repair_sequence.xml',
|
'mrp_repair_sequence.xml',
|
||||||
'mrp_repair_wizard.xml',
|
'mrp_repair_wizard.xml',
|
||||||
'mrp_repair_cancel_view.xml',
|
'mrp_repair_cancel_view.xml',
|
||||||
|
'mrp_repair_make_invoice_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',
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Requisition Request">
|
<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"/>
|
<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="repair_id" invisible="1"/>
|
|
||||||
<newline/>
|
<newline/>
|
||||||
<group col="2" colspan="4">
|
<group col="2" colspan="4">
|
||||||
<button icon='gtk-cancel' special="cancel"
|
<button icon='gtk-cancel' special="cancel"
|
||||||
|
|
|
@ -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>
|
|
@ -10,13 +10,13 @@
|
||||||
<!-- 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"-->
|
||||||
model="mrp.repair"
|
<!-- model="mrp.repair"-->
|
||||||
name="mrp.repair.make_invoice"
|
<!-- name="mrp.repair.make_invoice"-->
|
||||||
multi="True"
|
<!-- multi="True"-->
|
||||||
string="Make invoices"/>
|
<!-- string="Make invoices"/>-->
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import cancel_repair
|
import cancel_repair
|
||||||
import wizard_make_invoice
|
import make_invoice
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
||||||
|
|
|
@ -26,22 +26,20 @@ from tools.translate import _
|
||||||
class repair_cancel(osv.osv_memory):
|
class repair_cancel(osv.osv_memory):
|
||||||
_name = 'mrp.repair.cancel'
|
_name = 'mrp.repair.cancel'
|
||||||
_description = 'Cancel Repair'
|
_description = 'Cancel Repair'
|
||||||
|
|
||||||
_columns = {
|
|
||||||
'repair_id': fields.many2one('mrp.repair', 'Repair ID', readonly=True),
|
|
||||||
}
|
|
||||||
|
|
||||||
def cancel_repair(self, cr, uid, ids, context):
|
def cancel_repair(self, cr, uid, ids, context):
|
||||||
cancel = self.browse(cr, uid, ids[0])
|
record_id = context and context.get('record_id', False) or False
|
||||||
repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [cancel.repair_id.id])
|
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.'))
|
||||||
|
|
||||||
if repair_obj[0].invoiced or repair_obj[0].invoice_method == 'none':
|
|
||||||
self.pool.get('mrp.repair').write(cr, uid, 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 {}
|
return {}
|
||||||
|
|
||||||
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
|
||||||
|
@ -51,8 +49,6 @@ class repair_cancel(osv.osv_memory):
|
||||||
repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])[0]
|
repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])[0]
|
||||||
if not repair_obj.invoice_id:
|
if not repair_obj.invoice_id:
|
||||||
res['arch'] = """ <form string="Cancel Repair" colspan="4">
|
res['arch'] = """ <form string="Cancel Repair" colspan="4">
|
||||||
<field name="repair_id" invisible="1"/>
|
|
||||||
<newline/>
|
|
||||||
<group col="2" colspan="2">
|
<group col="2" colspan="2">
|
||||||
<button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
|
<button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
|
||||||
<button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/>
|
<button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/>
|
||||||
|
@ -60,15 +56,7 @@ class repair_cancel(osv.osv_memory):
|
||||||
</form>
|
</form>
|
||||||
"""
|
"""
|
||||||
return res
|
return res
|
||||||
|
|
||||||
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()
|
repair_cancel()
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# 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
|
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
Loading…
Reference in New Issue