Improve product stock view

Update the window name with the product name and the default uom
This commit is contained in:
Cédric Krier
2008-05-20 17:38:43 +02:00
parent 2d42387ce5
commit a868581e33
2 changed files with 22 additions and 8 deletions
+16
View File
@@ -95,6 +95,22 @@ class Location(OSV):
self._tree_qty(qty_by_ltn, childs, ids, to_compute)
return qty_by_ltn
def view_header_get(self, cursor, user, value, view_type='form',
context=None):
product_obj = self.pool.get('product.product')
uom_obj = self.pool.get('product.uom')
if context is None:
context = {}
if context.get('product'):
product_name = product_obj.name_get(cursor, user, context['product'],
context=context)[0][1]
product = product_obj.browse(cursor, user, context['product'],
context=context)
uom_name = uom_obj.name_get(cursor, user, product.default_uom.id,
context=context)[0][1]
return value + ': ' + product_name + ' (' + uom_name + ')'
return False
Location()
+6 -8
View File
@@ -13,7 +13,7 @@
<field name="default_uom" select="2"/>
<field name="active" select="2"/>
</tree>
]]>
]]>
</field>
</record>
@@ -23,23 +23,21 @@
<field name="field_childs">childs</field>
<field name="arch" type="xml">
<![CDATA[
<tree string="Locations">
<field name="name" select="1"/>
<field name="code" select="2"/>
<field name="type" select="1"/>
<field name="quantity" select="1"/>
<field name="active" select="2"/>
<tree string="Product Stock">
<field name="name"/>
<field name="quantity"/>
</tree>
]]>
</field>
</record>
<record model="ir.action.act_window" id="act_location_quantity_tree">
<field name="name">Product Availability</field>
<field name="name">Product Stock</field>
<field name="src_model">product.product</field>
<field name="res_model">stock.location</field>
<field name="view_type">tree</field>
<field name="context">{'product': active_id}</field>
<field name="domain">[('parent', '=', False)]</field>
<field name="window_name" eval="False"/>
</record>
<record model="ir.action.act_window.view" id="act_location_quantity_tree_view">
<field name="sequence" eval="10"/>