diff --git a/addons/stock/stock.py b/addons/stock/stock.py
index 68b6edb5f8d..4e9a8a2099b 100644
--- a/addons/stock/stock.py
+++ b/addons/stock/stock.py
@@ -208,6 +208,8 @@ class stock_location(osv.osv):
'stock_virtual_value': fields.function(_product_value, method=True, type='float', string='Virtual Stock Value', multi="stock", digits_compute=dp.get_precision('Account')),
'company_id': fields.many2one('res.company', 'Company', select=1, help='Let this field empty if this location is shared between all companies'),
'scrap_location': fields.boolean('Scrap Location', help='Check this box to allow using this location to put scrapped/damaged goods.'),
+ 'valuation_in_account_id': fields.many2one('account.account', 'Valuation In Account',domain = [('type','=','regular')], help='when there is an incoming move for the location, we have to use this field of that location instead of account from product/product category.'),
+ 'valuation_out_account_id': fields.many2one('account.account', 'Valuation Out Account',domain = [('type','=','regular')], help='when there is an outgoing move for the location, we have to use this field of that location instead of account from product/product category.'),
}
_defaults = {
'active': True,
@@ -1976,8 +1978,16 @@ class stock_move(osv.osv):
"""
product_obj=self.pool.get('product.product')
accounts = product_obj.get_product_accounts(cr, uid, move.product_id.id, context)
- acc_src = accounts['stock_account_input']
- acc_dest = accounts['stock_account_output']
+ if move.location_id.valuation_out_account_id:
+ acc_src = move.location_id.valuation_out_account_id.id
+ else:
+ acc_src = accounts['stock_account_input']
+
+ if move.location_dest_id.valuation_in_account_id:
+ acc_dest = move.location_dest_id.valuation_in_account_id.id
+ else:
+ acc_dest = accounts['stock_account_output']
+
acc_variation = accounts.get('property_stock_variation', False)
journal_id = accounts['stock_journal']
@@ -2585,7 +2595,7 @@ class stock_inventory(osv.osv):
account_move_data_l = account_move_obj.read(cr, uid, account_move_ids, ['state'], context=context)
for account_move in account_move_data_l:
if account_move['state'] == 'posted':
- raise osv.except_osv(_('UserError'),
+ raise osv.except_osv(_('UserError'),
_('You can not cancel inventory which has any account move with posted state.'))
account_move_obj.unlink(cr, uid, [account_move['id']], context=context)
self.write(cr, uid, [inv.id], {'state': 'cancel'}, context=context)
diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml
index 85c1231b75a..aede7188c02 100644
--- a/addons/stock/stock_view.xml
+++ b/addons/stock/stock_view.xml
@@ -410,7 +410,7 @@
{'full':'1',"search_default_available":1}
This is the list of all the production lots (serial numbers) you recorded. When you select a lot, you can get the upstream or downstream traceability of the products contained in lot. By default, the list is filtred on the serial numbers that are available in your warehouse but you can uncheck the 'Available' button to get all the lots you produced, received or delivered to customers.
-
@@ -493,6 +493,8 @@
+
+