[FIX] stock: multicompany warehouse creation
When creating a new warehouse, the linked locations should have the same company as the warehouse. The company_id field is required on warehouse (not necessary in vals as could be added by default values) while it is not for stock.location (meaning global location, also filled with default value).
This commit is contained in:
parent
980d23f98b
commit
d6fd96d0e9
|
@ -3229,11 +3229,14 @@ class stock_warehouse(osv.osv):
|
|||
location_obj = self.pool.get('stock.location')
|
||||
|
||||
#create view location for warehouse
|
||||
wh_loc_id = location_obj.create(cr, uid, {
|
||||
loc_vals = {
|
||||
'name': _(vals.get('code')),
|
||||
'usage': 'view',
|
||||
'location_id': data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_locations')[1]
|
||||
}, context=context)
|
||||
'location_id': data_obj.get_object_reference(cr, uid, 'stock', 'stock_location_locations')[1],
|
||||
}
|
||||
if vals.get('company_id'):
|
||||
loc_vals['company_id'] = vals.get('company_id')
|
||||
wh_loc_id = location_obj.create(cr, uid, loc_vals, context=context)
|
||||
vals['view_location_id'] = wh_loc_id
|
||||
#create all location
|
||||
def_values = self.default_get(cr, uid, {'reception_steps', 'delivery_steps'})
|
||||
|
@ -3249,12 +3252,15 @@ class stock_warehouse(osv.osv):
|
|||
{'name': _('Packing Zone'), 'active': delivery_steps == 'pick_pack_ship', 'field': 'wh_pack_stock_loc_id'},
|
||||
]
|
||||
for values in sub_locations:
|
||||
location_id = location_obj.create(cr, uid, {
|
||||
loc_vals = {
|
||||
'name': values['name'],
|
||||
'usage': 'internal',
|
||||
'location_id': wh_loc_id,
|
||||
'active': values['active'],
|
||||
}, context=context_with_inactive)
|
||||
}
|
||||
if vals.get('company_id'):
|
||||
loc_vals['company_id'] = vals.get('company_id')
|
||||
location_id = location_obj.create(cr, uid, loc_vals, context=context_with_inactive)
|
||||
vals[values['field']] = location_id
|
||||
|
||||
#create WH
|
||||
|
|
Loading…
Reference in New Issue