[IMP] mrp: Converted 'Compute Schedulers' wizard into osv_memory wizard.
bzr revid: uco@tinyerp.co.in-20100309085406-cd2vk9u95n5h3v5n
This commit is contained in:
parent
3182690728
commit
a753efb0bf
|
@ -64,6 +64,7 @@
|
|||
'wizard/make_procurement_view.xml',
|
||||
'wizard/change_production_qty_view.xml',
|
||||
'wizard/orderpoint_procurement_view.xml',
|
||||
'wizard/schedulers_all_view.xml',
|
||||
'mrp_view.xml',
|
||||
'mrp_wizard.xml',
|
||||
'mrp_report.xml',
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<wizard id="wiz_mrp_proc0" model="mrp.procurement" string="Compute Schedulers" name="mrp.procurement.compute.all"/>
|
||||
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
|
||||
<menuitem action="wiz_mrp_proc0" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" type="wizard" sequence="90"/>
|
||||
<!-- <wizard id="wiz_mrp_proc0" model="mrp.procurement" string="Compute Schedulers" name="mrp.procurement.compute.all"/>-->
|
||||
<!-- <menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>-->
|
||||
<!-- <menuitem action="wiz_mrp_proc0" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" type="wizard" sequence="90"/>-->
|
||||
<!--
|
||||
<menuitem action="wiz_mrp_proc1" id="menu_wiz_mrp_proc1" parent="mrp.mrp_Sched_all" type="wizard"/>
|
||||
-->
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
import orderpoint_procurement
|
||||
import wizard_procurement
|
||||
import wizard_schedulers_all
|
||||
import schedulers_all
|
||||
import wizard_price
|
||||
import wizard_workcenter_load
|
||||
import wizard_track_prod
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
# -*- 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 threading
|
||||
|
||||
from osv import osv, fields
|
||||
|
||||
class procurement_compute(osv.osv_memory):
|
||||
_name = 'mrp.procurement.compute.all'
|
||||
_description = 'Compute all schedulers'
|
||||
|
||||
_columns = {
|
||||
'automatic': fields.boolean('Automatic orderpoint',help='Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.'),
|
||||
}
|
||||
|
||||
_defaults ={
|
||||
'automatic': lambda *a: False,
|
||||
}
|
||||
|
||||
def _procure_calculation_all(self, cr, uid, ids, context):
|
||||
proc_obj = self.pool.get('mrp.procurement')
|
||||
for proc in self.browse(cr, uid, ids):
|
||||
proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\
|
||||
context=context)
|
||||
return {}
|
||||
|
||||
def procure_calculation(self, cr, uid, ids, context):
|
||||
threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
|
||||
threaded_calculation.start()
|
||||
return {}
|
||||
|
||||
procurement_compute()
|
||||
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Compute Schedulers -->
|
||||
|
||||
<record id="view_compute_schedulers_wizard" model="ir.ui.view">
|
||||
<field name="name">Compute Schedulers</field>
|
||||
<field name="model">mrp.procurement.compute.all</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Scheduler Parameters">
|
||||
<field name="automatic"/>
|
||||
<separator colspan="4"/>
|
||||
<group col="2" colspan="4">
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="procure_calculation" string="Compute Schedulers"
|
||||
colspan="1" type="object" icon="gtk-ok" />
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_compute_schedulers" model="ir.actions.act_window">
|
||||
<field name="name">Compute Schedulers</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">mrp.procurement.compute.all</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="compute_all_schedulers">
|
||||
<field name="model_id" ref="mrp.model_mrp_procurement" />
|
||||
<field name="object" eval="1" />
|
||||
<field name="name">Compute Schedulers</field>
|
||||
<field name="key2">client_action_multi</field>
|
||||
<field name="value" eval="'ir.actions.act_window,' + str(ref('action_compute_schedulers'))" />
|
||||
<field name="key">action</field>
|
||||
<field name="model">mrp.procurement</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
|
||||
<menuitem action="action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
|
||||
|
||||
</data>
|
||||
</openerp>
|
|
@ -1,64 +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 threading
|
||||
import pooler
|
||||
|
||||
parameter_form = '''<?xml version="1.0"?>
|
||||
<form string="Scheduler Parameters" colspan="4">
|
||||
<field name="automatic" />
|
||||
</form>'''
|
||||
|
||||
parameter_fields = {
|
||||
'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.', 'default': lambda *a: False},
|
||||
}
|
||||
|
||||
def _procure_calculation_all(self, db_name, uid, data, context):
|
||||
db, pool = pooler.get_db_and_pool(db_name)
|
||||
cr = db.cursor()
|
||||
proc_obj = pool.get('mrp.procurement')
|
||||
automatic = data['form']['automatic']
|
||||
proc_obj.run_scheduler(cr, uid, automatic=automatic, use_new_cursor=cr.dbname,\
|
||||
context=context)
|
||||
cr.close()
|
||||
return {}
|
||||
|
||||
def _procure_calculation(self, cr, uid, data, context):
|
||||
threaded_calculation = threading.Thread(target=_procure_calculation_all, args=(self, cr.dbname, uid, data, context))
|
||||
threaded_calculation.start()
|
||||
return {}
|
||||
|
||||
class procurement_compute(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock') ]}
|
||||
},
|
||||
'compute': {
|
||||
'actions': [_procure_calculation],
|
||||
'result': {'type': 'state', 'state':'end'}
|
||||
},
|
||||
}
|
||||
procurement_compute('mrp.procurement.compute.all')
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
Loading…
Reference in New Issue