[FIX] Store for moving package with inner packages. Further Fixes #5125
[IMP] Search quant instead of underlying packages
This commit is contained in:
parent
08888b21b8
commit
73899fd2dd
|
@ -3683,10 +3683,29 @@ class stock_package(osv.osv):
|
||||||
"""Returns packages from quants for store"""
|
"""Returns packages from quants for store"""
|
||||||
res = set()
|
res = set()
|
||||||
for quant in self.browse(cr, uid, ids, context=context):
|
for quant in self.browse(cr, uid, ids, context=context):
|
||||||
if quant.package_id:
|
pack = quant.package_id
|
||||||
res.add(quant.package_id.id)
|
while pack:
|
||||||
|
res.add(pack.id)
|
||||||
|
pack = pack.parent_id
|
||||||
return list(res)
|
return list(res)
|
||||||
|
|
||||||
|
def _get_package_info(self, cr, uid, ids, name, args, context=None):
|
||||||
|
quant_obj = self.pool.get("stock.quant")
|
||||||
|
default_company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
||||||
|
res = dict((res_id, {'location_id': False, 'company_id': default_company_id, 'owner_id': False}) for res_id in ids)
|
||||||
|
for pack in self.browse(cr, uid, ids, context=context):
|
||||||
|
quants = quant_obj.search(cr, uid, [('package_id', 'child_of', pack.id)], context=context)
|
||||||
|
if quants:
|
||||||
|
quant = quant_obj.browse(cr, uid, quants[0], context=context)
|
||||||
|
res[pack.id]['location_id'] = quant.location_id.id
|
||||||
|
res[pack.id]['owner_id'] = quant.owner_id.id
|
||||||
|
res[pack.id]['company_id'] = quant.company_id.id
|
||||||
|
else:
|
||||||
|
res[pack.id]['location_id'] = False
|
||||||
|
res[pack.id]['owner_id'] = False
|
||||||
|
res[pack.id]['company_id'] = False
|
||||||
|
return res
|
||||||
|
|
||||||
def _get_packages_to_relocate(self, cr, uid, ids, context=None):
|
def _get_packages_to_relocate(self, cr, uid, ids, context=None):
|
||||||
res = set()
|
res = set()
|
||||||
for pack in self.browse(cr, uid, ids, context=context):
|
for pack in self.browse(cr, uid, ids, context=context):
|
||||||
|
@ -3695,20 +3714,6 @@ class stock_package(osv.osv):
|
||||||
res.add(pack.parent_id.id)
|
res.add(pack.parent_id.id)
|
||||||
return list(res)
|
return list(res)
|
||||||
|
|
||||||
def _get_package_info(self, cr, uid, ids, name, args, context=None):
|
|
||||||
default_company_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id.id
|
|
||||||
res = dict((res_id, {'location_id': False, 'company_id': default_company_id, 'owner_id': False}) for res_id in ids)
|
|
||||||
for pack in self.browse(cr, uid, ids, context=context):
|
|
||||||
if pack.quant_ids:
|
|
||||||
res[pack.id]['location_id'] = pack.quant_ids[0].location_id.id
|
|
||||||
res[pack.id]['owner_id'] = pack.quant_ids[0].owner_id and pack.quant_ids[0].owner_id.id or False
|
|
||||||
res[pack.id]['company_id'] = pack.quant_ids[0].company_id.id
|
|
||||||
elif pack.children_ids:
|
|
||||||
res[pack.id]['location_id'] = pack.children_ids[0].location_id and pack.children_ids[0].location_id.id or False
|
|
||||||
res[pack.id]['owner_id'] = pack.children_ids[0].owner_id and pack.children_ids[0].owner_id.id or False
|
|
||||||
res[pack.id]['company_id'] = pack.children_ids[0].company_id and pack.children_ids[0].company_id.id or False
|
|
||||||
return res
|
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'name': fields.char('Package Reference', select=True, copy=False),
|
'name': fields.char('Package Reference', select=True, copy=False),
|
||||||
'complete_name': fields.function(_complete_name, type='char', string="Package Name",),
|
'complete_name': fields.function(_complete_name, type='char', string="Package Name",),
|
||||||
|
|
Loading…
Reference in New Issue