Stock Module changes for Real-virual values(Ref: VRA)
bzr revid: jvo@tinyerp.com-20090121123828-pcquausd1n6fc7wu
This commit is contained in:
parent
8eadb120b3
commit
a76cdc5711
|
@ -236,7 +236,7 @@ class account_report_history(osv.osv):
|
|||
cr.execute('''create or replace view account_report as (select ar.id as tmp,((pr.id*100000)+ar.id) as id,ar.id as name,pr.id as period_id,pr.fiscalyear_id as fiscalyear_id from account_report_report as ar cross join account_period as pr group by ar.id,pr.id,pr.fiscalyear_id)''')
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}):
|
||||
raise osv.except_osv(_('Error !'), _('You can not delete an indicator history record. You may have to delete the concerned Indicator!'))
|
||||
raise osv.except_osv(_('Error !'), _('You cannot delete an indicator history record. You may have to delete the concerned Indicator!'))
|
||||
|
||||
account_report_history()
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class stock_report_prodlots(osv.osv):
|
|||
'product_id': fields.many2one('product.product', 'Product', readonly=True, select=True),
|
||||
'prodlot_id': fields.many2one('stock.production.lot', 'Production lot', readonly=True, select=True),
|
||||
}
|
||||
|
||||
def init(self, cr):
|
||||
cr.execute("""
|
||||
create or replace view stock_report_prodlots as (
|
||||
|
@ -68,5 +69,10 @@ class stock_report_prodlots(osv.osv):
|
|||
) as report
|
||||
group by location_id, product_id, prodlot_id
|
||||
)""")
|
||||
|
||||
def unlink(self, cr, uid, ids, context={}):
|
||||
raise osv.except_osv(_('Error !'), _('You cannot delete any record!'))
|
||||
|
||||
|
||||
stock_report_prodlots()
|
||||
|
||||
|
|
|
@ -99,7 +99,30 @@
|
|||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<menuitem parent="next_id_61" action="action_stock_line_date" id="menu_report_stock_line_date"/>
|
||||
|
||||
<menuitem parent="next_id_61" action="action_stock_line_date" id="menu_report_stock_line_date"/>
|
||||
|
||||
<record id="view_location_tree_3" model="ir.ui.view">
|
||||
<field name="name">stock.location.tree</field>
|
||||
<field name="model">stock.location</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Stock Location" colors="blue:usage=='view';darkred:usage=='internal'">
|
||||
<field name="complete_name"/>
|
||||
<field name="stock_real_value" />
|
||||
<field name="stock_virtual_value" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="action_location_tree_3" model="ir.actions.act_window">
|
||||
<field name="name">Locations' Values</field>
|
||||
<field name="res_model">stock.location</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree</field>
|
||||
<field name="view_id" ref="view_location_tree_3"/>
|
||||
</record>
|
||||
<menuitem action="action_location_tree_3" id="menu_action_location_tree_3" parent="next_id_61" />
|
||||
|
||||
<!-- end... -->
|
||||
|
||||
|
|
|
@ -84,7 +84,33 @@ class stock_location(osv.osv):
|
|||
if 'stock_virtual' in field_names:
|
||||
res[loc]['stock_virtual'] = prod.virtual_available
|
||||
return res
|
||||
|
||||
|
||||
|
||||
def product_detail(self, cr, uid, id, field):
|
||||
res = {}
|
||||
res[id] = {}
|
||||
final_value = 0.0
|
||||
field_to_read = 'virtual_available'
|
||||
if field == 'stock_real_value':
|
||||
field_to_read = 'qty_available'
|
||||
cr.execute('select distinct product_id from stock_move where location_id=%s',(id,))
|
||||
result = cr.dictfetchall()
|
||||
if result:
|
||||
for r in result:
|
||||
product = self.pool.get('product.product').read(cr, uid, r['product_id'], [field_to_read,'standard_price','name'])
|
||||
final_value += (product[field_to_read] * product['standard_price'])
|
||||
return final_value
|
||||
|
||||
def _product_value(self, cr, uid, ids, field_names, arg, context={}):
|
||||
result = {}
|
||||
for id in ids:
|
||||
result[id] = {}.fromkeys(field_names, 0.0)
|
||||
for field_name in field_names:
|
||||
for loc in ids:
|
||||
ret_dict = self.product_detail(cr,uid,loc,field=field_name)
|
||||
result[loc][field_name] = ret_dict
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Location Name', size=64, required=True, translate=True),
|
||||
'active': fields.boolean('Active'),
|
||||
|
@ -123,6 +149,8 @@ class stock_location(osv.osv):
|
|||
|
||||
'parent_left': fields.integer('Left Parent', select=1),
|
||||
'parent_right': fields.integer('Right Parent', select=1),
|
||||
'stock_real_value': fields.function(_product_value, method=True, type='float', string='Real Stock Value', multi="stock"),
|
||||
'stock_virtual_value': fields.function(_product_value, method=True, type='float', string='Virtual Stock Value', multi="stock"),
|
||||
}
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
|
|
|
@ -403,7 +403,7 @@
|
|||
<field name="view_id" ref="view_location_tree"/>
|
||||
</record>
|
||||
<menuitem action="action_location_tree" id="menu_action_location_tree" parent="menu_stock_root"/>
|
||||
|
||||
|
||||
=============================
|
||||
Warehouse
|
||||
=============================
|
||||
|
@ -1360,7 +1360,7 @@
|
|||
context="{'location': active_id}"
|
||||
domain="[('product_id','=',active_id),('state','in',('waiting','confirmed','assigned'))]"
|
||||
id="act_product_stock_move_futur_open"
|
||||
name="Futur Stock Moves"
|
||||
name="Future Stock Moves"
|
||||
res_model="stock.move"
|
||||
src_model="product.product"/>
|
||||
|
||||
|
@ -1381,8 +1381,5 @@
|
|||
<field eval="True" name="object"/>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue