[FIX]:regression - cannot specify dedicated inventory accounts for periodical inventory or production

lp bug: https://launchpad.net/bugs/697273 fixed

bzr revid: ksa@tinyerp.co.in-20110117131339-i57z5w9plal1vw9c
This commit is contained in:
ksa (Open ERP) 2011-01-17 18:43:39 +05:30
parent 46a066686d
commit da1ea6e05f
2 changed files with 16 additions and 4 deletions

View File

@ -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)

View File

@ -410,7 +410,7 @@
<field name="context">{'full':'1',"search_default_available":1}</field>
<field name="help">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.</field>
</record>
<menuitem action="action_production_lot_form" id="menu_action_production_lot_form"
<menuitem action="action_production_lot_form" id="menu_action_production_lot_form"
parent="menu_traceability" groups="base.group_extended"
sequence="1"/>
@ -493,6 +493,8 @@
<field name="chained_auto_packing"/>
<field name="chained_delay"/>
<field name="chained_journal_id"/>
<field name="valuation_in_account_id" attrs="{'readonly':[('usage','not in',('inventory','production'))]}"/>
<field name="valuation_out_account_id" attrs="{'readonly':[('usage','not in',('inventory','production'))]}"/>
<field name="chained_picking_type"/>
<field name="chained_company_id" widget="selection"/>
</group>