'checks that all quants in a package are stored in the same location. This function cannot be used
as a constraint because it needs to be checked on pack operations (they may not call write on the
package)'

def _check_location_constraint(self):

    for pack in self:
        parent = pack
        while parent.parent_id:
            parent = parent.parent_id
        locations = parent.get_content().filtered((lambda quant: (quant.qty > 0.0))).mapped('location_id')
        if (len(locations) != 1):
            raise UserError(_('Everything    inside    a    package    should    be    in    the    same    location'))
    return True
