[FIX] dashboard_warehouse problem of id

bzr revid: vir@tinyerp.com-20100318112502-o62g2l712cxss5uk
This commit is contained in:
RCH(Open ERP)
2010-03-18 16:55:02 +05:30
committed by Vir (Open ERP)
parent 3d8b6315b7
commit d1c818f1f1
+58 -58
View File
@@ -223,7 +223,7 @@ class stock_location(osv.osv):
# Take the user company and pricetype
price_type_id=self.pool.get('res.users').browse(cr,uid,uid).company_id.property_valuation_price_type.id
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
if not product_ids:
product_ids = product_obj.search(cr, uid, [])
@@ -254,10 +254,10 @@ class stock_location(osv.osv):
continue
product = products_by_id[product_id]
quantity_total += qty[product_id]
# Compute based on pricetype
# Choose the right filed standard_price to read
amount_unit=product.price_get(pricetype.field, context)[product.id]
amount_unit=product.price_get(pricetype.field, context)[product.id]
price = qty[product_id] * amount_unit
# price = qty[product_id] * product.standard_price
@@ -666,8 +666,8 @@ class stock_picking(osv.osv):
if type in ('in_invoice', 'in_refund'):
# Take the user company and pricetype
price_type_id=self.pool.get('res.users').browse(cr,users,users).company_id.property_valuation_price_type.id
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
pricetype=self.pool.get('product.price.type').browse(cr,uid,price_type_id)
amount_unit=move_line.product_id.price_get(pricetype.field, context)[move_line.product_id.id]
return amount_unit
else:
return move_line.product_id.list_price
@@ -1383,12 +1383,12 @@ class stock_move(osv.osv):
# Base computation on valuation price type
else:
company_id=move.company_id.id
pricetype=self.pool.get('product.price.type').browse(cr,uid,move.company_id.property_valuation_price_type.id)
amount_unit=move.product_id.price_get(pricetype.field, context)[move.product_id.id]
amount=amount_unit * q or 1.0
# amount = q * move.product_id.standard_price
partner_id = False
if move.picking_id:
partner_id = move.picking_id.address_id and (move.picking_id.address_id.partner_id and move.picking_id.address_id.partner_id.id or False) or False
@@ -1434,7 +1434,7 @@ class stock_move(osv.osv):
raise osv.except_osv(_('UserError'),
_('You can only delete draft moves.'))
return super(stock_move, self).unlink(
cr, uid, ids, context=context)
cr, uid, ids, context=context)
def _create_lot(self, cr, uid, ids, product_id, prefix=False):
prodlot_obj = self.pool.get('stock.production.lot')
@@ -1443,22 +1443,22 @@ class stock_move(osv.osv):
if not sequence:
raise wizard.except_wizard(_('Error!'), _('No production sequence defined'))
prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix': prefix}, {'product_id': product_id})
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
prodlot = prodlot_obj.browse(cr, uid, prodlot_id)
ref = ','.join(map(lambda x:str(x),ids))
if prodlot.ref:
ref = '%s, %s' % (prodlot.ref, ref)
ref = '%s, %s' % (prodlot.ref, ref)
prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
return prodlot_id
def split_lines(self, cr, uid, ids, quantity, split_by_qty=1, prefix=False, with_lot=True, context=None):
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
res = []
for move in self.browse(cr, uid, ids):
for move in self.browse(cr, uid, ids):
if split_by_qty <= 0 or quantity == 0:
return res
@@ -1470,8 +1470,8 @@ class stock_move(osv.osv):
update_val = {
'product_qty': split_by_qty,
'product_uos_qty': uos_qty,
}
for idx in range(int(quantity//split_by_qty)):
}
for idx in range(int(quantity//split_by_qty)):
if not idx and move.product_qty<=quantity:
current_move = move.id
else:
@@ -1481,89 +1481,89 @@ class stock_move(osv.osv):
update_val['prodlot_id'] = self._create_lot(cr, uid, [current_move], move.product_id.id)
self.write(cr, uid, [current_move], update_val)
if quantity_rest > 0:
idx = int(quantity//split_by_qty)
if quantity_rest > 0:
idx = int(quantity//split_by_qty)
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
if not idx and move.product_qty<=quantity:
current_move = move.id
update_val['product_uos_qty'] = uos_qty_rest
if not idx and move.product_qty<=quantity:
current_move = move.id
else:
current_move = self.copy(cr, uid, move.id, {'state': move.state})
current_move = self.copy(cr, uid, move.id, {'state': move.state})
res.append(current_move)
if with_lot:
if with_lot:
update_val['prodlot_id'] = self._create_lot(cr, uid, [current_move], move.product_id.id)
self.write(cr, uid, [current_move], update_val)
return res
return res
def consume_moves(self, cr, uid, ids, quantity, location_id=False, location_dest_id=False, consume=True, context=None):
def consume_moves(self, cr, uid, ids, quantity, location_id=False, location_dest_id=False, consume=True, context=None):
if not context:
context = {}
if quantity <= 0:
raise osv.except_osv(_('Warning!'), _('Please provide Proper Quantity !'))
res = []
for move in self.browse(cr, uid, ids, context=context):
res = []
for move in self.browse(cr, uid, ids, context=context):
move_qty = move.product_qty
quantity_rest = move.product_qty
quantity_rest -= quantity
quantity_rest -= quantity
uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
if quantity_rest <= 0:
quantity_rest = 0
quantity_rest = 0
uos_qty_rest = 0
quantity = move.product_qty
uos_qty = quantity / move_qty * move.product_uos_qty
if quantity_rest > 0:
if quantity_rest > 0:
default_val = {
'product_qty': quantity,
'product_uos_qty': uos_qty,
'state': move.state,
'product_qty': quantity,
'product_uos_qty': uos_qty,
'state': move.state,
}
if location_dest_id:
default_val.update({'location_dest_id': location_dest_id})
default_val.update({'location_dest_id': location_dest_id})
if location_id:
default_val.update({'location_id': location_id})
default_val.update({'location_id': location_id})
if move.product_id.track_production and location_id:
res += self.split_lines(cr, uid, [move.id], quantity, split_by_qty=1, context=context)
else:
current_move = self.copy(cr, uid, move.id, default_val)
res += [current_move]
update_val = {}
update_val = {}
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
self.write(cr, uid, [move.id], update_val)
update_val['product_uos_qty'] = uos_qty_rest
self.write(cr, uid, [move.id], update_val)
else:
quantity_rest = quantity
else:
quantity_rest = quantity
uos_qty_rest = uos_qty
if move.product_id.track_production and location_id:
res += self.split_lines(cr, uid, [move.id], quantity_rest, split_by_qty=1, context=context)
else:
res += [move.id]
update_val = {}
else:
res += [move.id]
update_val = {}
update_val['product_qty'] = quantity_rest
update_val['product_uos_qty'] = uos_qty_rest
if location_dest_id:
update_val.update({'location_dest_id': location_dest_id})
update_val.update({'location_dest_id': location_dest_id})
if location_id:
update_val.update({'location_id': location_id})
update_val.update({'location_id': location_id})
self.write(cr, uid, [move.id], update_val)
if consume:
self.action_done(cr, uid, res)
self.action_done(cr, uid, res)
return res
def scrap_moves(self, cr, uid, ids, quantity, location_dest_id, context=None):
@@ -1599,7 +1599,7 @@ class stock_inventory(osv.osv):
move_line = []
for line in inv.inventory_line_id:
pid = line.product_id.id
# price = line.product_id.standard_price or 0.0
amount = self.pool.get('stock.location')._product_get(cr, uid, line.location_id.id, [pid], {'uom': line.product_uom.id})[pid]
change = line.product_qty - amount
@@ -1764,7 +1764,7 @@ class report_products_to_received_planned(osv.osv):
tools.drop_view_if_exists(cr, 'report_products_to_received_planned')
cr.execute("""
create or replace view report_products_to_received_planned as (
select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty
select stock.date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty
from stock_picking picking
inner join stock_move stock
on picking.id = stock.picking_id and picking.type = 'in'
@@ -1773,7 +1773,7 @@ class report_products_to_received_planned(osv.osv):
union
select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty
select stock.date_planned, min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty
from stock_picking picking
inner join stock_move stock
on picking.id = stock.picking_id and picking.type = 'in'
@@ -1798,7 +1798,7 @@ class report_delivery_products_planned(osv.osv):
tools.drop_view_if_exists(cr, 'report_delivery_products_planned')
cr.execute("""
create or replace view report_delivery_products_planned as (
select stock.date, min(stock.id), sum(stock.product_qty) as qty, 0 as planned_qty
select stock.date, min(stock.id) as id, sum(stock.product_qty) as qty, 0 as planned_qty
from stock_picking picking
inner join stock_move stock
on picking.id = stock.picking_id and picking.type = 'out'
@@ -1807,7 +1807,7 @@ class report_delivery_products_planned(osv.osv):
union
select stock.date_planned, min(stock.id), 0 as actual_qty, sum(stock.product_qty) as planned_qty
select stock.date_planned, min(stock.id) as id, 0 as actual_qty, sum(stock.product_qty) as planned_qty
from stock_picking picking
inner join stock_move stock
on picking.id = stock.picking_id and picking.type = 'out'