[WIP] First quant package menuitem and views and use name with parent names in it as with locations for quant packages
bzr revid: jco@openerp.com-20130722091109-np3r9pj6vgj2rg1l
This commit is contained in:
parent
43d5f2a2db
commit
795ae67052
|
@ -2266,8 +2266,38 @@ class stock_package(osv.osv):
|
|||
"""
|
||||
_name = "stock.quant.package"
|
||||
_description = "Physical Packages"
|
||||
_parent_name = "parent_id"
|
||||
_parent_store = True
|
||||
_parent_order = 'name'
|
||||
_order = 'parent_left'
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
res = self._complete_name(cr, uid, ids, 'complete_name', None, context=context)
|
||||
return res.items()
|
||||
|
||||
def _complete_name(self, cr, uid, ids, name, args, context=None):
|
||||
""" Forms complete name of location from parent location to child location.
|
||||
@return: Dictionary of values
|
||||
"""
|
||||
res = {}
|
||||
for m in self.browse(cr, uid, ids, context=context):
|
||||
res[m.id] = m.name
|
||||
parent = m.parent_id
|
||||
while parent:
|
||||
res[m.id] = parent.name + ' / ' + res[m.id]
|
||||
parent = parent.location_id
|
||||
return res
|
||||
|
||||
def _get_subpackages(self, cr, uid, ids, context=None):
|
||||
""" return all sublocations of the given stock locations (included) """
|
||||
return self.search(cr, uid, [('id', 'child_of', ids)], context=context)
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Package Reference', size=64, select=True),
|
||||
'complete_name': fields.function(_complete_name, type='char', string="Package Name",
|
||||
store={'stock.quant.package': (_get_subpackages, ['name', 'parent_id'], 10)}),
|
||||
'parent_left': fields.integer('Left Parent', select=1),
|
||||
'parent_right': fields.integer('Right Parent', select=1),
|
||||
'packaging_id': fields.many2one('product.packaging', 'Type of Packaging'),
|
||||
'location_id': fields.related('quant_ids', 'location_id', type='many2one', relation='stock.location', string='Location', readonly=True),
|
||||
'quant_ids': fields.one2many('stock.quant', 'package_id', 'Bulk Content'),
|
||||
|
|
|
@ -1601,7 +1601,6 @@
|
|||
<field name="name">stock.quant.tree</field>
|
||||
<field name="model">stock.quant</field>
|
||||
<field eval="10" name="priority"/>
|
||||
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Quants">
|
||||
<field name="product_id"/>
|
||||
|
@ -1740,5 +1739,41 @@
|
|||
</group>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="view_quant_package_form">
|
||||
<field name="name">stock.quant.package.form</field>
|
||||
<field name="model">stock.quant.package</field>
|
||||
<field eval="10" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Package">
|
||||
<field name="complete_name"/>
|
||||
<field name="name"/>
|
||||
<field name="packaging_id"/>
|
||||
<field name="location_id"/>
|
||||
<field name="quant_ids"/>
|
||||
<field name="children_ids"/>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record model="ir.ui.view" id="view_quant_package_tree">
|
||||
<field name="name">stock.quant.package.tree</field>
|
||||
<field name="model">stock.quant.package</field>
|
||||
<field eval="10" name="priority"/>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Package">
|
||||
<field name="complete_name"/>
|
||||
<field name="packaging_id"/>
|
||||
<field name="location_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="action_package_view">
|
||||
<field name="context">{}</field>
|
||||
<field name="name">Packages</field>
|
||||
<field name="res_model">stock.quant.package</field>
|
||||
</record>
|
||||
<menuitem id="menu_package" name="Packages" parent="stock.menu_stock_configuration" action="action_package_view"/>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue