diff options
| author | nch@tinyerp.com <> | 2010-05-12 12:17:56 +0530 |
|---|---|---|
| committer | nch@tinyerp.com <> | 2010-05-12 12:17:56 +0530 |
| commit | f0aa8a0a0c1367161eba7426d9a37d61ba8bd899 (patch) | |
| tree | 468357a929cf8584e174458c1ead6f19bee58014 /addons/mrp/wizard | |
| parent | ce10539ffb5bd18fa2578689f152c88be6966d89 (diff) | |
| parent | bd933e119001332a6eea3255d490a62ccf7fb5fb (diff) | |
[MERGE]
bzr revid: nch@tinyerp.com-20100512064756-778rth7jwjwhcjsz
Diffstat (limited to 'addons/mrp/wizard')
| -rw-r--r-- | addons/mrp/wizard/__init__.py | 4 | ||||
| -rw-r--r-- | addons/mrp/wizard/make_procurement_product.py | 122 | ||||
| -rw-r--r-- | addons/mrp/wizard/make_procurement_view.xml | 40 | ||||
| -rw-r--r-- | addons/mrp/wizard/mrp_procurement.py | 52 | ||||
| -rw-r--r-- | addons/mrp/wizard/mrp_procurement_view.xml | 34 | ||||
| -rw-r--r-- | addons/mrp/wizard/mrp_track_prod.py | 56 | ||||
| -rw-r--r-- | addons/mrp/wizard/orderpoint_procurement.py | 70 | ||||
| -rw-r--r-- | addons/mrp/wizard/orderpoint_procurement_view.xml | 34 | ||||
| -rw-r--r-- | addons/mrp/wizard/schedulers_all.py | 68 | ||||
| -rw-r--r-- | addons/mrp/wizard/schedulers_all_view.xml | 37 |
10 files changed, 29 insertions, 488 deletions
diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py index 045d7f1bd71..aa4408e543e 100644 --- a/addons/mrp/wizard/__init__.py +++ b/addons/mrp/wizard/__init__.py @@ -20,14 +20,10 @@ ############################################################################## import mrp_product_produce -import orderpoint_procurement -import mrp_procurement -import schedulers_all import mrp_price import mrp_workcenter_load #import mrp_track_prod import change_production_qty -import make_procurement_product # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/wizard/make_procurement_product.py b/addons/mrp/wizard/make_procurement_product.py deleted file mode 100644 index a2dd62327bb..00000000000 --- a/addons/mrp/wizard/make_procurement_product.py +++ /dev/null @@ -1,122 +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 netsvc -import time - -from osv import fields, osv - -class make_procurement(osv.osv_memory): - _name = 'make.procurement' - _description = 'Make Procurements' - - def onchange_product_id(self, cr, uid, ids, prod_id): - """ On Change of Product ID getting the value of related UoM. - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param prod_id: Changed ID of Product - @return: A dictionary which gives the UoM of the changed Product - """ - product = self.pool.get('product.product').browse(cr, uid, prod_id) - return {'value': {'uom_id': product.uom_id.id}} - - _columns = { - 'qty': fields.float('Quantity', digits=(16,2), required=True), - 'product_id': fields.many2one('product.product', 'Product', required=True, readonly=1), - 'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True), - 'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True), - 'date_planned': fields.date('Planned Date', required=True), - } - - _defaults = { - 'date_planned': lambda *args: time.strftime('%Y-%m-%d'), - 'qty': lambda *args: 1.0, - } - - def make_procurement(self, cr, uid, ids, context=None): - """ Creates procurement order for selected product. - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - @return: A dictionary which loads Procurement form view. - """ - user = self.pool.get('res.users').browse(cr, uid, uid, context).login - wh_obj = self.pool.get('stock.warehouse') - procurement_obj = self.pool.get('mrp.procurement') - wf_service = netsvc.LocalService("workflow") - data_obj = self.pool.get('ir.model.data') - - for proc in self.browse(cr, uid, ids): - wh = wh_obj.browse(cr, uid, proc.warehouse_id.id, context) - procure_id = procurement_obj.create(cr, uid, { - 'name':'INT: '+str(user), - 'date_planned': proc.date_planned, - 'product_id': proc.product_id.id, - 'product_qty': proc.qty, - 'product_uom': proc.uom_id.id, - 'location_id': wh.lot_stock_id.id, - 'procure_method':'make_to_order', - }) - - wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr) - - - id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view') - id3 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_form_view') - - if id2: - id2 = data_obj.browse(cr, uid, id2, context=context).res_id - if id3: - id3 = data_obj.browse(cr, uid, id3, context=context).res_id - - return { - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'mrp.procurement', - 'res_id' : procure_id, - 'views': [(id3,'form'),(id2,'tree')], - 'type': 'ir.actions.act_window', - } - - def default_get(self, cr, uid, fields, context=None): - """ To get default values for the object. - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - @return: A dictionary which of fields with values. - """ - record_id = context and context.get('active_id', False) or False - - res = super(make_procurement, self).default_get(cr, uid, fields, context=context) - product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id - if 'product_id' in fields: - res.update({'product_id':product_id}) - return res - -make_procurement() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/mrp/wizard/make_procurement_view.xml b/addons/mrp/wizard/make_procurement_view.xml deleted file mode 100644 index e98f1c013a0..00000000000 --- a/addons/mrp/wizard/make_procurement_view.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - - <!-- Make Procurement --> - - <record id="view_make_procurment_wizard" model="ir.ui.view"> - <field name="name">Procurement Request</field> - <field name="model">make.procurement</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form string="Procurement Request"> - <label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." colspan="4"/> - <field name="product_id" on_change="onchange_product_id(product_id)"/> - <field name="qty"/> - <field name="uom_id"/> - <field name="date_planned"/> - <field name="warehouse_id" colspan="4"/> - <newline/> - <group col="2" colspan="4"> - <button icon='gtk-cancel' special="cancel" - string="Cancel" /> - <button name="make_procurement" string="Ask New Products" - colspan="1" type="object" icon="gtk-ok" /> - </group> - </form> - </field> - </record> - - <act_window name="Procurement Request" - res_model="make.procurement" - src_model="product.product" - view_mode="form" - target="new" - key2="client_action_multi" - id="act_make_procurement" - groups="base.group_extended"/> - - </data> -</openerp> diff --git a/addons/mrp/wizard/mrp_procurement.py b/addons/mrp/wizard/mrp_procurement.py deleted file mode 100644 index 1c3f3dd5c8a..00000000000 --- a/addons/mrp/wizard/mrp_procurement.py +++ /dev/null @@ -1,52 +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 threading -from osv import osv, fields - -class procurement_compute(osv.osv_memory): - _name = 'mrp.procurement.compute' - _description = 'Compute Procurement' - - def _procure_calculation_procure(self, cr, uid, ids, context): - try: - proc_obj = self.pool.get('mrp.procurement') - proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context) - finally: - cr.close() - return {} - - def procure_calculation(self, cr, uid, ids, context): - """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - """ - threaded_calculation = threading.Thread(target=self._procure_calculation_procure, args=(cr, uid, ids, context)) - threaded_calculation.start() - return {} - -procurement_compute() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/mrp/wizard/mrp_procurement_view.xml b/addons/mrp/wizard/mrp_procurement_view.xml deleted file mode 100644 index 817f7011e0c..00000000000 --- a/addons/mrp/wizard/mrp_procurement_view.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - - <!-- Compute Procurement --> - - <record id="view_compute_procurment_wizard" model="ir.ui.view"> - <field name="name">Compute Procurements</field> - <field name="model">mrp.procurement.compute</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form string="Parameters"> - <label string="This wizard will schedule procurements." colspan="4" align="0.0"/> - <newline/> - <group col="2" colspan="4"> - <button icon='gtk-cancel' special="cancel" - string="Cancel" /> - <button name="procure_calculation" string="Compute Procurements" - colspan="1" type="object" icon="gtk-ok" /> - </group> - </form> - </field> - </record> - -<!-- <act_window name="Compute Procurements" --> -<!-- res_model="mrp.procurement.compute"--> -<!-- src_model="mrp.procurement"--> -<!-- view_mode="form"--> -<!-- target="new" --> -<!-- key2="client_action_multi" --> -<!-- id="act_compute_procurement"/> --> - - </data> -</openerp> diff --git a/addons/mrp/wizard/mrp_track_prod.py b/addons/mrp/wizard/mrp_track_prod.py index 11e1ec32ec6..43929b47dc7 100644 --- a/addons/mrp/wizard/mrp_track_prod.py +++ b/addons/mrp/wizard/mrp_track_prod.py @@ -56,33 +56,35 @@ class mrp_track_move(osv.osv_memory): """ res = super(mrp_track_move, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False) record_id = context and context.get('active_id', False) or False - if record_id: - prod_obj = self.pool.get('mrp.production') - prod = prod_obj.browse(cr, uid, record_id) - try: - if prod.state != 'done': - res['arch'] = '''<form string="Track lines"> - <label colspan="4" string="You can not split an unfinished production Output." /> - <group col="2" colspan="4"> - <button icon='gtk-cancel' special="cancel" - string="Exit" /> - </group> - </form> - ''' - else: - arch_lst = ['<form string="Track lines">', '<label colspan="4" string="The field on each line says whether this lot should be tracked or not." />'] - for m in [line for line in prod.move_created_ids]: - quantity = m.product_qty - res['fields']['track%s' %m.id] = {'string' : m.product_id.name, 'type' : 'boolean', 'default' : lambda x,y,z: False} - arch_lst.append('<field name="track%s" />\n<newline />' %m.id) - arch_lst.append('<group col="2" colspan="4">') - arch_lst.append('<button icon=\'gtk-cancel\' special="cancel" string="Cancel" />') - arch_lst.append('<button name="track_lines" string="Track" colspan="1" type="object" icon="gtk-ok" />') - arch_lst.append('</group>') - arch_lst.append('</form>') - res['arch'] = '\n'.join(arch_lst) - except Exception,e: - return res + active_model = context.get('active_model') + + if not record_id or (active_model and active_model != 'mrp.production'): + return res + + prod_obj = self.pool.get('mrp.production') + prod = prod_obj.browse(cr, uid, record_id) + if prod.state != 'done': + res['arch'] = '''<form string="Track lines"> + <label colspan="4" string="You can not split an unfinished production Output." /> + <group col="2" colspan="4"> + <button icon='gtk-cancel' special="cancel" + string="Exit" /> + </group> + </form> + ''' + else: + arch_lst = ['<form string="Track lines">', '<label colspan="4" string="The field on each line says whether this lot should be tracked or not." />'] + for m in [line for line in prod.move_created_ids]: + quantity = m.product_qty + res['fields']['track%s' %m.id] = {'string' : m.product_id.name, 'type' : 'boolean', 'default' : lambda x,y,z: False} + arch_lst.append('<field name="track%s" />\n<newline />' %m.id) + arch_lst.append('<group col="2" colspan="4">') + arch_lst.append('<button icon=\'gtk-cancel\' special="cancel" string="Cancel" />') + arch_lst.append('<button name="track_lines" string="Track" colspan="1" type="object" icon="gtk-ok" />') + arch_lst.append('</group>') + arch_lst.append('</form>') + res['arch'] = '\n'.join(arch_lst) + return res def track_lines(self, cr, uid, ids, context): diff --git a/addons/mrp/wizard/orderpoint_procurement.py b/addons/mrp/wizard/orderpoint_procurement.py deleted file mode 100644 index 56302660939..00000000000 --- a/addons/mrp/wizard/orderpoint_procurement.py +++ /dev/null @@ -1,70 +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/>. -# -############################################################################## - -# -# Order Point Method: -# - Order if the virtual stock of today is bellow the min of the defined order point -# - -import threading -from osv import fields,osv - -class procurement_compute(osv.osv_memory): - _name = 'mrp.procurement.orderpoint.compute' - _description = 'Automatic Order Point' - - _columns = { - 'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'), - } - - _defaults = { - 'automatic' : lambda *a: False, - } - - def _procure_calculation_orderpoint(self, cr, uid, ids, context): - """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - """ - proc_obj = self.pool.get('mrp.procurement') - for proc in self.browse(cr, uid, ids): - proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context) - - return {} - - def procure_calculation(self, cr, uid, ids, context): - """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - """ - threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, args=(cr, uid, ids, context)) - threaded_calculation.start() - return {} - -procurement_compute() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp/wizard/orderpoint_procurement_view.xml b/addons/mrp/wizard/orderpoint_procurement_view.xml deleted file mode 100644 index c17bedae84f..00000000000 --- a/addons/mrp/wizard/orderpoint_procurement_view.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> - <data> - - <!-- Compute Stock Minimum Rules Only --> - - <record id="view_procurement_compute_wizard" model="ir.ui.view"> - <field name="name">Compute Stock Minimum Rules Only</field> - <field name="model">mrp.procurement.orderpoint.compute</field> - <field name="type">form</field> - <field name="arch" type="xml"> - <form string="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 Stock" - colspan="1" type="object" icon="gtk-ok" /> - </group> - </form> - </field> - </record> - - <act_window name="Compute Stock Minimum Rules Only" - res_model="mrp.procurement.orderpoint.compute" - src_model="mrp.procurement" - view_mode="form" - target="new" - key2="client_action_multi" - id="action_procurement_compute"/> - - </data> -</openerp> diff --git a/addons/mrp/wizard/schedulers_all.py b/addons/mrp/wizard/schedulers_all.py deleted file mode 100644 index ad67b1330d0..00000000000 --- a/addons/mrp/wizard/schedulers_all.py +++ /dev/null @@ -1,68 +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 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): - """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - """ - 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): - """ - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param ids: List of IDs selected - @param context: A standard dictionary - """ - 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: - diff --git a/addons/mrp/wizard/schedulers_all_view.xml b/addons/mrp/wizard/schedulers_all_view.xml deleted file mode 100644 index b8b465e03e9..00000000000 --- a/addons/mrp/wizard/schedulers_all_view.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?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> - - <act_window name="Compute Schedulers" - res_model="mrp.procurement.compute.all" - src_model="mrp.procurement" - view_mode="form" - target="new" - key2="client_action_multi" - id="action_compute_schedulers"/> - - <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> |
