[IMP] Stock valuation: Avoid consumables with real-time valuation
When the product is a consumable, avoid to use real-time valuation, by adapting the onchange in the views and making the valuation field invisible when the product is a consumable / service.
This commit is contained in:
parent
d8d3b38cbd
commit
cf6d7479d5
|
@ -651,6 +651,9 @@ class product_template(osv.osv):
|
|||
res = False
|
||||
return res
|
||||
|
||||
def onchange_type(self, cr, uid, ids, type):
|
||||
return {}
|
||||
|
||||
def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id):
|
||||
if uom_id:
|
||||
return {'value': {'uom_po_id': uom_id}}
|
||||
|
@ -1021,6 +1024,9 @@ class product_product(osv.osv):
|
|||
self.pool.get('product.template').unlink(cr, uid, unlink_product_tmpl_ids, context=context)
|
||||
return res
|
||||
|
||||
def onchange_type(self, cr, uid, ids, type):
|
||||
return {}
|
||||
|
||||
def onchange_uom(self, cursor, user, ids, uom_id, uom_po_id):
|
||||
if uom_id and uom_po_id:
|
||||
uom_obj=self.pool.get('product.uom')
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<page string="Information">
|
||||
<group colspan="4">
|
||||
<group>
|
||||
<field name="type"/>
|
||||
<field name="type" on_change="onchange_type(type)"/>
|
||||
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="product.group_uom"/>
|
||||
<field name="list_price"/>
|
||||
</group>
|
||||
|
|
|
@ -58,6 +58,11 @@ class product_template(osv.osv):
|
|||
'valuation': 'manual_periodic',
|
||||
}
|
||||
|
||||
def onchange_type(self, cr, uid, ids, type):
|
||||
res = super(product_template, self).onchange_type(cr, uid, ids, type)
|
||||
if type in ('consu', 'service'):
|
||||
res = {'value': {'valuation': 'manual_periodic'}}
|
||||
return res
|
||||
|
||||
def get_product_accounts(self, cr, uid, product_id, context=None):
|
||||
""" To get the stock input account, stock output account and stock journal related to product.
|
||||
|
@ -151,7 +156,14 @@ class product_template(osv.osv):
|
|||
return True
|
||||
|
||||
|
||||
class product_product(osv.osv):
|
||||
_inherit = 'product.product'
|
||||
|
||||
def onchange_type(self, cr, uid, ids, type):
|
||||
res = super(product_product, self).onchange_type(cr, uid, ids, type)
|
||||
if type in ('consu', 'service'):
|
||||
res = {'value': {'valuation': 'manual_periodic'}}
|
||||
return res
|
||||
|
||||
|
||||
class product_category(osv.osv):
|
||||
|
|
|
@ -37,9 +37,9 @@
|
|||
</field>
|
||||
<xpath expr="//group[@name='properties']" position="before">
|
||||
<group groups="stock_account.group_inventory_valuation" attrs="{'invisible': [('type','=','service')]}">
|
||||
<separator string="Inventory Valuation" colspan="4"/>
|
||||
<separator string="Inventory Valuation" attrs="{'invisible':[('type', 'in', ('service', 'consu'))]}" colspan="4"/>
|
||||
<group colspan="2" col="2">
|
||||
<field name="valuation" attrs="{'readonly':[('type', '=', 'service')]}"/>
|
||||
<field name="valuation" attrs="{'invisible':[('type', 'in', ('service', 'consu'))]}"/>
|
||||
</group>
|
||||
<group colspan="2" col="2">
|
||||
<field name="property_stock_account_input" attrs="{'invisible':[('valuation', '!=', 'real_time')]}"
|
||||
|
|
Loading…
Reference in New Issue