diff --git a/addons/procurement/company.py b/addons/procurement/company.py index ce39ca9a684..f6d1e69d122 100644 --- a/addons/procurement/company.py +++ b/addons/procurement/company.py @@ -28,11 +28,11 @@ class company(osv.osv): help="This is the time frame analysed by the scheduler when "\ "computing procurements. All procurements that are not between "\ "today and today+range are skipped for futur computation."), - } + } _defaults = { - 'schedule_range': lambda *a: 80.0, - } + 'schedule_range': 80.0, + } + company() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index d10cc89234c..45db8854e0d 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -464,7 +464,7 @@ class stock_warehouse_orderpoint(osv.osv): """ _name = "stock.warehouse.orderpoint" _description = "Minimum Inventory Rule" - + _columns = { 'name': fields.char('Name', size=32, required=True), 'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."), @@ -485,17 +485,17 @@ class stock_warehouse_orderpoint(osv.osv): 'company_id': fields.many2one('res.company','Company',required=True), } _defaults = { - 'active': lambda *a: 1, - 'logic': lambda *a: 'max', - 'qty_multiple': lambda *a: 1, + 'active': 1, + 'logic': 'max', + 'qty_multiple': 1, 'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'stock.orderpoint') or '', 'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False), 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c) } _sql_constraints = [ ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', _('Qty Multiple must be greater than zero.')), - ] - + ] + def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}): """ Finds location id for changed warehouse. @param warehouse_id: Changed id of warehouse. @@ -506,7 +506,7 @@ class stock_warehouse_orderpoint(osv.osv): v = {'location_id': w.lot_stock_id.id} return {'value': v} return {} - + def onchange_product_id(self, cr, uid, ids, product_id, context={}): """ Finds UoM for changed product. @param product_id: Changed id of product. @@ -517,7 +517,7 @@ class stock_warehouse_orderpoint(osv.osv): v = {'product_uom': prod.uom_id.id} return {'value': v} return {} - + def copy(self, cr, uid, id, default=None,context={}): if not default: default = {} @@ -525,6 +525,6 @@ class stock_warehouse_orderpoint(osv.osv): 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint') or '', }) return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context) - + stock_warehouse_orderpoint() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py index 36215dcdc73..dc66d9e3e8b 100644 --- a/addons/procurement/schedulers.py +++ b/addons/procurement/schedulers.py @@ -19,12 +19,12 @@ # ############################################################################## +import time +from mx import DateTime + from osv import osv import netsvc import pooler -from mx import DateTime -import time - class procurement_order(osv.osv): _inherit = 'procurement.order' @@ -37,7 +37,7 @@ class procurement_order(osv.osv): context = {} if use_new_cursor: - cr = pooler.get_db(use_new_cursor).cursor() + cr = pooler.get_db(use_new_cursor).cursor() wf_service = netsvc.LocalService("workflow") procurement_obj = self.pool.get('procurement.order') @@ -172,7 +172,7 @@ class procurement_order(osv.osv): if not context: context = {} if use_new_cursor: - cr = pooler.get_db(use_new_cursor).cursor() + cr = pooler.get_db(use_new_cursor).cursor() orderpoint_obj = self.pool.get('stock.warehouse.orderpoint') location_obj = self.pool.get('stock.location') procurement_obj = self.pool.get('procurement.order') @@ -196,7 +196,7 @@ class procurement_order(osv.osv): qty = max(op.product_min_qty, op.product_max_qty)-prods reste = qty % op.qty_multiple if reste > 0: - qty += op.qty_multiple - reste + qty += op.qty_multiple - reste newdate = DateTime.now() + DateTime.RelativeDateTime( days = int(op.product_id.seller_delay)) if op.product_id.supply_method == 'buy': @@ -238,6 +238,7 @@ class procurement_order(osv.osv): cr.commit() cr.close() return {} + procurement_order() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/procurement/wizard/orderpoint_procurement.py b/addons/procurement/wizard/orderpoint_procurement.py index ee3207833d3..cec7d13554d 100644 --- a/addons/procurement/wizard/orderpoint_procurement.py +++ b/addons/procurement/wizard/orderpoint_procurement.py @@ -30,36 +30,36 @@ from osv import fields,osv class procurement_compute(osv.osv_memory): _name = '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'), + '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, + 'automatic': 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 - """ + @param ids: List of IDs selected + @param context: A standard dictionary + """ proc_obj = self.pool.get('procurement.order') 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 + @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() diff --git a/addons/procurement/wizard/schedulers_all.py b/addons/procurement/wizard/schedulers_all.py index 8b1be81d276..9b2ac6d59b8 100644 --- a/addons/procurement/wizard/schedulers_all.py +++ b/addons/procurement/wizard/schedulers_all.py @@ -26,43 +26,41 @@ from osv import osv, fields class procurement_compute_all(osv.osv_memory): _name = 'procurement.order.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 + @param ids: List of IDs selected + @param context: A standard dictionary """ proc_obj = self.pool.get('procurement.order') for proc in self.browse(cr, uid, ids): proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\ - context=context) + 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 + @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_all() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file