[FIX] fixing misc bugs due to the removal of stock in the dependancies of sale
bzr revid: qdp-launchpad@openerp.com-20130802113308-nicou96ebqtcgdm0
This commit is contained in:
parent
841024adc2
commit
56cbc9421d
|
@ -126,9 +126,8 @@ class procurement_order(osv.osv):
|
|||
('done', 'Done')
|
||||
], 'Status', required=True, track_visibility='onchange'),
|
||||
'message': fields.text('Latest error', help="Exception occurred while computing procurement orders."),
|
||||
|
||||
|
||||
}
|
||||
|
||||
_defaults = {
|
||||
'state': 'confirmed',
|
||||
'priority': '1',
|
||||
|
|
|
@ -173,7 +173,7 @@ class sale_order(osv.osv):
|
|||
('done', 'Done'),
|
||||
], 'Status', readonly=True, track_visibility='onchange',
|
||||
help="Gives the status of the quotation or sales order. \nThe exception status is automatically set when a cancel operation occurs in the processing of a document linked to the sales order. \nThe 'Waiting Schedule' status is set when the invoice is confirmed but waiting for the scheduler to run on the order date.", select=True),
|
||||
'date_order': fields.date('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
|
||||
'date_order': fields.datetime('Date', required=True, readonly=True, select=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}),
|
||||
'create_date': fields.datetime('Creation Date', readonly=True, select=True, help="Date on which sales order is created."),
|
||||
'date_confirm': fields.date('Confirmation Date', readonly=True, select=True, help="Date on which sales order is confirmed."),
|
||||
'user_id': fields.many2one('res.users', 'Salesperson', states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, select=True, track_visibility='onchange'),
|
||||
|
@ -223,7 +223,7 @@ class sale_order(osv.osv):
|
|||
'procurement_group_id': fields.many2one('procurement.group', 'Procurement group'),
|
||||
}
|
||||
_defaults = {
|
||||
'date_order': fields.date.context_today,
|
||||
'date_order': fields.datetime.now,
|
||||
'order_policy': 'manual',
|
||||
'company_id': _get_default_company,
|
||||
'state': 'draft',
|
||||
|
@ -623,12 +623,7 @@ class sale_order(osv.osv):
|
|||
def action_done(self, cr, uid, ids, context=None):
|
||||
return self.write(cr, uid, ids, {'state': 'done'}, context=context)
|
||||
|
||||
|
||||
|
||||
|
||||
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id = False, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', 'stock_location_customers')
|
||||
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id=False, context=None):
|
||||
date_planned = self._get_date_planned(cr, uid, order, line, order.date_order, context=context)
|
||||
return {
|
||||
'name': line.name,
|
||||
|
@ -637,18 +632,14 @@ class sale_order(osv.osv):
|
|||
'product_id': line.product_id.id,
|
||||
'product_qty': line.product_uom_qty,
|
||||
'product_uom': line.product_uom.id,
|
||||
'product_uos_qty': (line.product_uos and line.product_uos_qty)\
|
||||
or line.product_uom_qty,
|
||||
'product_uos': (line.product_uos and line.product_uos.id)\
|
||||
or line.product_uom.id,
|
||||
'location_id': location_id,
|
||||
'product_uos_qty': (line.product_uos and line.product_uos_qty) or line.product_uom_qty,
|
||||
'product_uos': (line.product_uos and line.product_uos.id) or line.product_uom.id,
|
||||
'company_id': order.company_id.id,
|
||||
'note': line.name,
|
||||
'group_id': group_id,
|
||||
'group_id': group_id,
|
||||
}
|
||||
|
||||
def _get_date_planned(self, cr, uid, order, line, start_date, context=None):
|
||||
start_date = self.date_to_datetime(cr, uid, start_date, context)
|
||||
date_planned = datetime.strptime(start_date, DEFAULT_SERVER_DATETIME_FORMAT) + relativedelta(days=line.delay or 0.0)
|
||||
date_planned = (date_planned - timedelta(days=order.company_id.security_lead)).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return date_planned
|
||||
|
|
|
@ -59,11 +59,11 @@ class sale_order(osv.osv):
|
|||
def _get_shipped(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
for sale in self.browse(cr, uid, ids, context=context):
|
||||
res[sale.id]= True
|
||||
res[sale.id] = True
|
||||
#TODO: not better to use picking
|
||||
pickingstates = []
|
||||
for pick in sale.picking_ids:
|
||||
pickingstates += [x.state not in ['cancel', 'done'] for x in pick.move_lines if x]
|
||||
pickingstates += [x.state not in ['cancel', 'done'] for x in pick.move_lines]
|
||||
if any(pickingstates):
|
||||
res[sale.id] = False
|
||||
return res
|
||||
|
@ -77,7 +77,6 @@ class sale_order(osv.osv):
|
|||
res.add(proc.group_id.sale_id.id)
|
||||
return list(res)
|
||||
|
||||
|
||||
def _get_picking_ids(self, cr, uid, ids, name, args, context=None):
|
||||
res = {}
|
||||
if not ids: return res
|
||||
|
@ -95,17 +94,24 @@ class sale_order(osv.osv):
|
|||
res[r[0]].append(r[1])
|
||||
return res
|
||||
|
||||
'''for element in self.browse(cr, uid, ids, context=context):
|
||||
procu_ids = []
|
||||
for line in element.order_line:
|
||||
if line.procurement_id:
|
||||
procu_ids.append(line.procurement_id.id)
|
||||
picking_ids = []
|
||||
for procurement in self.pool.get('procurement.order').browse(cr, uid, list(set(procu_ids)), context=context):
|
||||
if procurement.move_id and procurement.move_id.picking_id and procurement.move_id.picking_id.type == 'out':
|
||||
picking_ids.append(procurement.move_id.picking_id.id)
|
||||
res[element.id] = list(set(picking_ids))
|
||||
return res'''
|
||||
#for element in self.browse(cr, uid, ids, context=context):
|
||||
# procu_ids = []
|
||||
# for line in element.order_line:
|
||||
# if line.procurement_id:
|
||||
# procu_ids.append(line.procurement_id.id)
|
||||
# picking_ids = []
|
||||
# for procurement in self.pool.get('procurement.order').browse(cr, uid, list(set(procu_ids)), context=context):
|
||||
# if procurement.move_id and procurement.move_id.picking_id and procurement.move_id.picking_id.type == 'out':
|
||||
# picking_ids.append(procurement.move_id.picking_id.id)
|
||||
# res[element.id] = list(set(picking_ids))
|
||||
#return res
|
||||
|
||||
def _prepare_order_line_procurement(self, cr, uid, order, line, group_id = False, context=None):
|
||||
mod_obj = self.pool.get('ir.model.data')
|
||||
vals = super(sale_order, self)._prepare_order_line_procurement(cr, uid, order, line, group_id=group_id, context=context)
|
||||
location_model, location_id = mod_obj.get_object_reference(cr, uid, 'stock', 'stock_location_customers')
|
||||
vals['location_id'] = location_id
|
||||
return vals
|
||||
|
||||
_columns = {
|
||||
'state': fields.selection([
|
||||
|
@ -217,30 +223,6 @@ class sale_order(osv.osv):
|
|||
self.write(cr, uid, [o.id], {'order_policy': 'manual'}, context=context)
|
||||
return res
|
||||
|
||||
|
||||
def date_to_datetime(self, cr, uid, userdate, context=None):
|
||||
""" Convert date values expressed in user's timezone to
|
||||
server-side UTC timestamp, assuming a default arbitrary
|
||||
time of 12:00 AM - because a time is needed.
|
||||
|
||||
:param str userdate: date string in in user time zone
|
||||
:return: UTC datetime string for server-side use
|
||||
"""
|
||||
# TODO: move to fields.datetime in server after 7.0
|
||||
user_date = datetime.strptime(userdate, DEFAULT_SERVER_DATE_FORMAT)
|
||||
if context and context.get('tz'):
|
||||
tz_name = context['tz']
|
||||
else:
|
||||
tz_name = self.pool.get('res.users').read(cr, SUPERUSER_ID, uid, ['tz'])['tz']
|
||||
if tz_name:
|
||||
utc = pytz.timezone('UTC')
|
||||
context_tz = pytz.timezone(tz_name)
|
||||
user_datetime = user_date + relativedelta(hours=12.0)
|
||||
local_timestamp = context_tz.localize(user_datetime, is_dst=False)
|
||||
user_datetime = local_timestamp.astimezone(utc)
|
||||
return user_datetime.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
return user_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
# if mode == 'finished':
|
||||
# returns True if all lines are done, False otherwise
|
||||
# if mode == 'canceled':
|
||||
|
|
Loading…
Reference in New Issue