[Fix] stock : Move the sale and purchase related code in to there module
bzr revid: sbh@tinyerp.com-20100915112508-9eq3w14bjylgzd7x
This commit is contained in:
@@ -102,5 +102,29 @@ class stock_picking(osv.osv):
|
||||
|
||||
stock_picking()
|
||||
|
||||
class stock_partial_picking(osv.osv_memory):
|
||||
_inherit = 'stock.partial.picking'
|
||||
|
||||
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.
|
||||
"""
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
|
||||
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
for m in pick.move_lines:
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
if pick.type == 'in' and pick.purchase_id:
|
||||
if m.sale_line_id:
|
||||
res['move%s_product_price'%(m.id)] = m.purchase_line_id.price_unit
|
||||
if pick.sale_id:
|
||||
res['move%s_product_currency'%(m.id)] = pick.purchase_line_id.pricelist_id.currency_id.id
|
||||
return res
|
||||
stock_partial_picking()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
||||
@@ -209,4 +209,28 @@ class stock_picking(osv.osv):
|
||||
|
||||
stock_picking()
|
||||
|
||||
class stock_partial_picking(osv.osv_memory):
|
||||
_inherit = 'stock.partial.picking'
|
||||
|
||||
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.
|
||||
"""
|
||||
pick_obj = self.pool.get('stock.picking')
|
||||
res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context)
|
||||
for pick in pick_obj.browse(cr, uid, context.get('active_ids', [])):
|
||||
for m in pick.move_lines:
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
if pick.type == 'out' and pick.sale_id:
|
||||
if m.sale_line_id:
|
||||
res['move%s_product_price'%(m.id)] = m.sale_line_id.price_unit
|
||||
if pick.sale_id:
|
||||
res['move%s_product_currency'%(m.id)] = pick.sale_id.pricelist_id.currency_id.id
|
||||
return res
|
||||
stock_partial_picking()
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
@@ -171,20 +171,9 @@ class stock_partial_picking(osv.osv_memory):
|
||||
res['move%s_product_uom'%(m.id)] = m.product_uom.id
|
||||
if 'move%s_prodlot_id'%(m.id) in fields:
|
||||
res['move%s_prodlot_id'%(m.id)] = m.prodlot_id.id
|
||||
|
||||
if (m.product_id.cost_method == 'average'):
|
||||
currency = False
|
||||
price = m.product_id.standard_price
|
||||
if (pick.type == 'in') and 'purchase_id' in pick._columns.keys():
|
||||
if hasattr(m, 'purchase_line_id') and m.purchase_line_id:
|
||||
price = m.purchase_line_id.price_unit
|
||||
if hasattr(pick, 'purchase_id') and pick.purchase_id:
|
||||
currency = pick.purchase_id.pricelist_id.currency_id.id
|
||||
if (pick.type == 'out') and 'sale_id' in pick._columns.keys():
|
||||
if hasattr(m, 'sale_line_id') and m.sale_line_id:
|
||||
price = m.sale_line_id.price_unit
|
||||
if hasattr(pick, 'sale_id') and pick.sale_id:
|
||||
currency = pick.sale_id.pricelist_id.currency_id.id
|
||||
if 'move%s_product_price'%(m.id) in fields:
|
||||
res['move%s_product_price'%(m.id)] = price
|
||||
if 'move%s_product_currency'%(m.id) in fields:
|
||||
|
||||
Reference in New Issue
Block a user