summaryrefslogtreecommitdiff
path: root/addons/procurement/procurement.py
diff options
context:
space:
mode:
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>2014-04-03 09:10:10 +0200
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>2014-04-03 09:10:10 +0200
commitfe0e95d29be5c49b57765336f85f619d4af468ca (patch)
treec1dd88b414bd706b0e5caec44417345eccf96e78 /addons/procurement/procurement.py
parent5b980f2b293ba1f272780dec85f76925b2d22385 (diff)
[IMP] procurement: removed the schedule_range field on res.company which was error prone and not really usefull + made the scheduler run in SUPERUSER to avoid intercompany and access rights issues + made the run of procurement as SUPERUSER too for the same reasons
bzr revid: qdp-launchpad@openerp.com-20140403071010-5mrox75rkufur2nw
Diffstat (limited to 'addons/procurement/procurement.py')
-rw-r--r--addons/procurement/procurement.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
index b35a7755b28..1439b323173 100644
--- a/addons/procurement/procurement.py
+++ b/addons/procurement/procurement.py
@@ -21,9 +21,7 @@
import time
-from datetime import datetime
-from dateutil.relativedelta import relativedelta
-
+from openerp import SUPERUSER_ID
from openerp.osv import fields, osv
import openerp.addons.decimal_precision as dp
from openerp.tools.translate import _
@@ -31,7 +29,7 @@ import openerp
class procurement_group(osv.osv):
'''
- The procurement requirement class is used to group products together
+ The procurement group class is used to group products together
when computing procurements. (tasks, physical products, ...)
The goal is that when you have one sale order of several products
@@ -56,12 +54,11 @@ class procurement_group(osv.osv):
_description = 'Procurement Requisition'
_order = "id desc"
_columns = {
- 'name': fields.char('Reference', required=True),
+ 'name': fields.char('Reference', required=True),
'move_type': fields.selection([
('direct', 'Partial'), ('one', 'All at once')],
'Delivery Method', required=True),
- 'partner_id': fields.many2one('res.partner', string = 'Partner'), #Sale should pass it here
- 'procurement_ids': fields.one2many('procurement.order', 'group_id', 'Procurements'),
+ 'procurement_ids': fields.one2many('procurement.order', 'group_id', 'Procurements'),
}
_defaults = {
'name': lambda self, cr, uid, c: self.pool.get('ir.sequence').get(cr, uid, 'procurement.group') or '',
@@ -266,7 +263,8 @@ class procurement_order(osv.osv):
#
def run_scheduler(self, cr, uid, use_new_cursor=False, context=None):
'''
- Call the scheduler to check the procurement order
+ Call the scheduler to check the procurement order. This is intented to be done for all existing companies at
+ the same time, so we're running all the methods as SUPERUSER to avoid intercompany and access rights issues.
@param self: The object pointer
@param cr: The current row, from the database cursor,
@@ -282,25 +280,22 @@ class procurement_order(osv.osv):
if use_new_cursor:
cr = openerp.registry(use_new_cursor).db.cursor()
- company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
- maxdate = (datetime.today() + relativedelta(days=company.schedule_range)).strftime('%Y-%m-%d %H:%M:%S')
-
# Run confirmed procurements
while True:
- ids = self.search(cr, uid, [('state', '=', 'confirmed'), ('date_planned', '<=', maxdate)], context=context)
+ ids = self.search(cr, SUPERUSER_ID, [('state', '=', 'confirmed')], context=context)
if not ids:
break
- self.run(cr, uid, ids, context=context)
+ self.run(cr, SUPERUSER_ID, ids, context=context)
if use_new_cursor:
cr.commit()
# Check if running procurements are done
offset = 0
while True:
- ids = self.search(cr, uid, [('state', '=', 'running'), ('date_planned', '<=', maxdate)], offset=offset, context=context)
+ ids = self.search(cr, SUPERUSER_ID, [('state', '=', 'running')], offset=offset, context=context)
if not ids:
break
- done = self.check(cr, uid, ids, context=context)
+ done = self.check(cr, SUPERUSER_ID, ids, context=context)
offset += len(ids) - len(done)
if use_new_cursor:
cr.commit()