--- stock/stock.py 2010-10-14 00:47:03 +0000 +++ stock/stock.py 2010-10-15 03:10:46 +0000 @@ -356,7 +356,7 @@ Attempt to find a quantity ``product_qty`` (in the product's default uom or the uom passed in ``context``) of product ``product_id`` in locations with id ``ids`` and their child locations. If ``lock`` is True, the stock.move lines of product with id ``product_id`` in the searched location will be write-locked using Postgres's - "FOR UPDATE NOWAIT" option until the transaction is committed or rolled back, to prevent reservin + "FOR UPDATE NOWAIT" option until the transaction is committed or rolled back, to prevent reservin twice the same products. If ``lock`` is True and the lock cannot be obtained (because another transaction has locked some of the same stock.move lines), a log line will be output and False will be returned, as if there was @@ -501,14 +501,14 @@ def unlink(self, cr, uid, ids, context=None): raise osv.except_osv(_('Error'), _('You can not remove a lot line !')) - + def action_traceability(self, cr, uid, ids, context={}): """ It traces the information of a product @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 @return: A dictionary of values """ value={} @@ -632,7 +632,7 @@ 'move_lines': fields.one2many('stock.move', 'picking_id', 'Internal Moves', states={'done': [('readonly', True)], 'cancel': [('readonly', True)]}), 'auto_picking': fields.boolean('Auto-Picking'), 'address_id': fields.many2one('res.partner.address', 'Address', help="Address of partner"), - 'partner_id': fields.related('address_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True), + 'partner_id': fields.related('address_id','partner_id',type='many2one',relation='res.partner',string='Partner',store=True), 'invoice_state': fields.selection([ ("invoiced", "Invoiced"), ("2binvoiced", "To Be Invoiced"), @@ -666,7 +666,7 @@ picking_obj = self.browse(cr, uid, [res], context)[0] for move in picking_obj.move_lines: move_obj.write(cr, uid, [move.id], {'tracking_id': False,'prodlot_id':False}) - return res + return res def onchange_partner_in(self, cr, uid, context=None, partner_id=None): return {} @@ -1072,14 +1072,14 @@ if move.state not in ('cancel',): return False return True - + def allow_cancel(self, cr, uid, ids, context={}): for pick in self.browse(cr, uid, ids, context=context): if not pick.move_lines: return True for move in pick.move_lines: if move.state == 'done': - raise osv.except_osv(_('Error'), _('You cannot cancel picking because stock move is in done state !')) + raise osv.except_osv(_('Error'), _('You cannot cancel picking because stock move is in done state !')) return True def unlink(self, cr, uid, ids, context=None): move_obj = self.pool.get('stock.move') @@ -1167,8 +1167,9 @@ # Record the values that were chosen in the wizard, so they can be # used for inventory valuation if real-time valuation is enabled. - move_obj.write(cr, uid, [move.id], + move_obj.write(cr, uid, [move.id], {'price_unit': product_price, + 'hist_cost': product_price, 'price_currency_id': product_currency}) @@ -1338,7 +1339,7 @@ 'prefix': fields.char('Prefix', size=64, help="Optional prefix to prepend when displaying this serial number: PREFIX/SERIAL [INT_REF]"), 'product_id': fields.many2one('product.product', 'Product', required=True), 'date': fields.datetime('Creation Date', required=True), - 'stock_available': fields.function(_get_stock, fnct_search=_stock_search, method=True, type="float", string="Available", select=True, + 'stock_available': fields.function(_get_stock, fnct_search=_stock_search, method=True, type="float", string="Available", select=True, help="Current quantity of products with this Production Lot Number available in company warehouses", digits_compute=dp.get_precision('Product UoM')), 'revisions': fields.one2many('stock.production.lot.revision', 'lot_id', 'Revisions'), @@ -1358,8 +1359,8 @@ @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 @return: A dictionary of values """ value=self.pool.get('action.traceability').action_traceability(cr,uid,ids,context) @@ -1444,7 +1445,7 @@ 'date': fields.datetime('Date', required=True, help="Move date: scheduled date until move is done, then date of actual move processing", readonly=True), 'date_expected': fields.datetime('Scheduled Date', states={'done': [('readonly', True)]},required=True, help="Scheduled date for the processing of this move"), 'product_id': fields.many2one('product.product', 'Product', required=True, select=True, domain=[('type','<>','service')],states={'done': [('readonly', True)]}), - + 'hist_cost': fields.float('Historical Cost', digits_compute=dp.get_precision('Account'), help="Cost Used on wizard in the moment of recalculate costs, if average and automatic calculation is selected, this value represents the one used to post accounting valuation lines", readonly=True), 'product_qty': fields.float('Quantity', digits_compute=dp.get_precision('Product UoM'), required=True,states={'done': [('readonly', True)]}), 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True,states={'done': [('readonly', True)]}), 'product_uos_qty': fields.float('Quantity (UOS)', digits_compute=dp.get_precision('Product UoM')), @@ -1493,7 +1494,7 @@ if context.get('move_line', []): if context['move_line'][0]: if isinstance(context['move_line'][0], (tuple, list)): - return context['move_line'][0][2] and context['move_line'][0][2].get('location_dest_id',False) + return context['move_line'][0][2] and context['move_line'][0][2].get('location_dest_id',False) else: move_list = self.pool.get('stock.move').read(cr, uid, context['move_line'][0], ['location_dest_id']) return move_list and move_list['location_dest_id'][0] or False @@ -1855,7 +1856,7 @@ """ Return the accounts and journal to use to post Journal Entries for the real-time valuation of the move. - + :param context: context dictionary that can explicitly mention the company to consider via the 'force_company' key :raise: osv.except_osv() is any mandatory account or journal is not defined. """ @@ -1895,13 +1896,13 @@ default_uom = move.product_id.uom_id.id qty = product_uom_obj._compute_qty(cr, uid, move.product_uom.id, move.product_qty, default_uom) - # if product is set to average price and a specific value was entered in the picking wizard, + # if product is set to average price and a specific value was entered in the picking wizard, # we use it if move.product_id.cost_method == 'average' and move.price_unit: reference_amount = qty * move.price_unit reference_currency_id = move.price_currency_id.id or reference_currency_id - # Otherwise we default to the company's valuation price type, considering that the values of the + # Otherwise we default to the company's valuation price type, considering that the values of the # valuation field are expressed in the default currency of the move's company. else: if context is None: @@ -1943,7 +1944,7 @@ move_obj = self.pool.get('account.move') for j_id, move_lines in account_moves: - move_obj.create(cr, uid, + move_obj.create(cr, uid, {'name': move.name, 'journal_id': j_id, 'line_id': move_lines, @@ -2002,10 +2003,10 @@ def _create_account_move_line(self, cr, uid, move, src_account_id, dest_account_id, reference_amount, reference_currency_id, context=None): """ - Generate the account.move.line values to post to track the stock valuation difference due to the + Generate the account.move.line values to post to track the stock valuation difference due to the processing of the given stock move. """ - # prepare default values considering that the destination accounts have the reference_currency_id as their main currency + # prepare default values considering that the destination accounts have the reference_currency_id as their main currency 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 debit_line_vals = { 'name': move.name, @@ -2029,7 +2030,7 @@ } # if we are posting to accounts in a different currency, provide correct values in both currencies correctly - # when compatible with the optional secondary currency on the account. + # when compatible with the optional secondary currency on the account. # Financial Accounts only accept amounts in secondary currencies if there's no secondary currency on the account # or if it's the same as that of the secondary amount being posted. account_obj = self.pool.get('account.account') @@ -2298,8 +2299,9 @@ # Record the values that were chosen in the wizard, so they can be # used for inventory valuation if real-time valuation is enabled. - self.write(cr, uid, [move.id], + self.write(cr, uid, [move.id], {'price_unit': product_price, + 'hist_cost': product_price, 'price_currency_id': product_currency, }) --- stock/stock_view.xml 2010-10-14 00:47:03 +0000 +++ stock/stock_view.xml 2010-10-15 02:05:44 +0000 @@ -114,7 +114,7 @@ string="Split inventory lines" groups="base.group_extended" type="action" icon="terp-stock_effects-object-colorize"/> - + @@ -302,7 +302,7 @@ - + @@ -315,7 +315,7 @@ - + @@ -1473,6 +1473,7 @@ +