diff --git a/addons/auth_signup/res_users.py b/addons/auth_signup/res_users.py
index 38beb087c7a..6b79e1ab461 100644
--- a/addons/auth_signup/res_users.py
+++ b/addons/auth_signup/res_users.py
@@ -260,10 +260,9 @@ class res_users(osv.Model):
# send email to users with their signup url
template = False
if context.get('create_user'):
- try:
- template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'set_password_email')
- except ValueError:
- pass
+ template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'set_password_email')
+ if not template.exists():
+ template = False
if not bool(template):
template = self.pool.get('ir.model.data').get_object(cr, uid, 'auth_signup', 'reset_password_email')
assert template._name == 'email.template'
diff --git a/addons/edi/models/res_partner.py b/addons/edi/models/res_partner.py
index 057e84b5541..3c3ca45949f 100644
--- a/addons/edi/models/res_partner.py
+++ b/addons/edi/models/res_partner.py
@@ -55,7 +55,7 @@ class res_partner(osv.osv, EDIMixin):
res_partner_bank_type = self.pool.get('res.partner.bank.type')
try:
return self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'bank_normal', context=context).code
- except ValueError:
+ except:
pass
# second option: create a new custom type for EDI or use it if already created, as IBAN type is
# not always appropriate: we need a free-form bank type for max flexibility (users can correct
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 9692b94f159..44973696cb7 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -461,9 +461,8 @@ class mail_thread(osv.AbstractModel):
posted = False
for subtype in subtypes:
- try:
- subtype_rec = self.pool.get('ir.model.data').get_object(cr, uid, subtype.split('.')[0], subtype.split('.')[1], context=context)
- except ValueError, e:
+ subtype_rec = self.pool.get('ir.model.data').get_object(cr, uid, subtype.split('.')[0], subtype.split('.')[1], context=context)
+ if not subtype_rec.exists():
_logger.debug('subtype %s not found, giving error "%s"' % (subtype, e))
continue
message = format_message(subtype_rec.description if subtype_rec.description else subtype_rec.name, tracked_values)
diff --git a/addons/mail/update.py b/addons/mail/update.py
index bcf9bb8c7c9..3d07ce739ab 100644
--- a/addons/mail/update.py
+++ b/addons/mail/update.py
@@ -94,13 +94,11 @@ class publisher_warranty_contract(osv.osv):
# old behavior based on res.log; now on mail.message, that is not necessarily installed
IMD = self.pool['ir.model.data']
user = self.pool['res.users'].browse(cr, SUPERUSER_ID, SUPERUSER_ID)
- try:
- poster = IMD.get_object(cr, SUPERUSER_ID, 'mail', 'group_all_employees')
- except ValueError:
- # Cannot found group, post the message on the wall of the admin
- poster = user
+ poster = IMD.get_object(cr, SUPERUSER_ID, 'mail', 'group_all_employees')
if not poster.exists():
- return True
+ if not user.exists():
+ return True
+ poster = user
for message in result["messages"]:
try:
poster.message_post(body=message, subtype='mt_comment', partner_ids=[user.partner_id.id])
diff --git a/addons/sale/res_config.py b/addons/sale/res_config.py
index 04958521ab5..70ef3371d41 100644
--- a/addons/sale/res_config.py
+++ b/addons/sale/res_config.py
@@ -87,12 +87,9 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
user = self.pool.get('res.users').browse(cr, uid, uid, context)
res['time_unit'] = user.company_id.project_time_mode_id.id
else:
- try:
- product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant')
+ product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant')
+ if product.exists():
res['time_unit'] = product.uom_id.id
- except ValueError:
- # keep default value in that case
- _logger.warning("Product with xml_id 'product.product_product_consultant' not found")
return res
def _get_default_time_unit(self, cr, uid, context=None):
@@ -108,10 +105,10 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
wizard = self.browse(cr, uid, ids)[0]
if wizard.time_unit:
- try:
- product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant')
+ product = ir_model_data.get_object(cr, uid, 'product', 'product_product_consultant')
+ if product.exists():
product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id})
- except ValueError:
+ else:
_logger.warning("Product with xml_id 'product.product_product_consultant' not found, UoMs not updated!")
if wizard.module_project and wizard.time_unit:
diff --git a/addons/stock/wizard/stock_fill_inventory.py b/addons/stock/wizard/stock_fill_inventory.py
index b367e6069d8..71deb99a9d6 100644
--- a/addons/stock/wizard/stock_fill_inventory.py
+++ b/addons/stock/wizard/stock_fill_inventory.py
@@ -27,8 +27,10 @@ class stock_fill_inventory(osv.osv_memory):
_description = "Import Inventory"
def _default_location(self, cr, uid, ids, context=None):
+ location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
+ if not location.exists():
+ return False
try:
- location = self.pool.get('ir.model.data').get_object(cr, uid, 'stock', 'stock_location_stock')
location.check_access_rule('read', context=context)
location_id = location.id
except (ValueError, orm.except_orm), e:
diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py
index 8eadebf676d..20d1e06b630 100644
--- a/addons/website/models/ir_http.py
+++ b/addons/website/models/ir_http.py
@@ -25,7 +25,7 @@ class ir_http(orm.AbstractModel):
def _auth_method_public(self):
if not request.session.uid:
request.uid = request.registry['website'].get_public_user(
- request.cr, openerp.SUPERUSER_ID, request.context).id
+ request.cr, openerp.SUPERUSER_ID, request.context)
else:
request.uid = request.session.uid
diff --git a/addons/website/models/website.py b/addons/website/models/website.py
index a442f95bd95..4f9be2b8895 100644
--- a/addons/website/models/website.py
+++ b/addons/website/models/website.py
@@ -69,6 +69,10 @@ def urlplus(url, params):
))
class website(osv.osv):
+ def _get_public_user(self, cr, uid, ids, name='public_user', arg=(), context=None):
+ ref = self.get_public_user(cr, uid, context=context)
+ return dict( map(lambda x: (x, ref), ids) )
+
_name = "website" # Avoid website.website convention for conciseness (for new api). Got a special authorization from xmo and rco
_description = "Website"
_columns = {
@@ -82,9 +86,9 @@ class website(osv.osv):
'social_linkedin': fields.char('LinkedIn Account'),
'social_youtube': fields.char('Youtube Account'),
'social_googleplus': fields.char('Google+ Account'),
+ 'public_user': fields.function(_get_public_user, relation='res.users', type='many2one', string='Public User', store=True)
}
- public_user = None
def new_page(self, cr, uid, name, template='website.default_page', ispage=True, context=None):
context=context or {}
# completely arbitrary max_length
@@ -133,11 +137,8 @@ class website(osv.osv):
return False
def get_public_user(self, cr, uid, context=None):
- if not self.public_user:
- uid = openerp.SUPERUSER_ID
- ref = self.pool['ir.model.data'].get_object_reference(cr, uid, 'website', 'public_user')
- self.public_user = self.pool[ref[0]].browse(cr, uid, ref[1])
- return self.public_user
+ uid = openerp.SUPERUSER_ID
+ return self.pool['ir.model.data'].get_object_reference(cr, uid, 'website', 'public_user')[1]
def get_current_website(self, cr, uid, context=None):
# TODO: Select website, currently hard coded
@@ -147,7 +148,6 @@ class website(osv.osv):
def redirect(url):
return werkzeug.utils.redirect(url_for(url))
request.redirect = redirect
- is_public_user = request.uid == self.get_public_user(cr, uid, context).id
user = self.pool['res.users'].browse(cr, uid, uid, context=context)
website_publisher_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'base', 'group_website_publisher')[1]
@@ -156,10 +156,9 @@ class website(osv.osv):
lang = request.context['lang']
is_master_lang = lang == request.website.default_lang_id.code
request.context.update({
- 'is_public_user': is_public_user,
'is_master_lang': is_master_lang,
'editable': is_website_publisher,
- 'translatable': not is_public_user and not is_master_lang,
+ 'translatable': not is_master_lang,
})
def get_template(self, cr, uid, ids, template, context=None):
@@ -333,7 +332,7 @@ class website(osv.osv):
"""
router = request.httprequest.app.get_db_router(request.db)
# Force enumeration to be performed as public user
- uid = self.get_public_user(cr, uid, context=context).id
+ uid = self.get_public_user(cr, uid, context=context)[1].id
for rule in router.iter_rules():
if not self.rule_is_enumerable(rule):
continue
diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml
index dbfd17daf6e..86f212f2310 100644
--- a/addons/website_blog/views/website_blog_templates.xml
+++ b/addons/website_blog/views/website_blog_templates.xml
@@ -215,21 +215,20 @@
diff --git a/addons/website_crm_partner_assign/controllers/main.py b/addons/website_crm_partner_assign/controllers/main.py
index a0ede0ad703..2656ae47c96 100644
--- a/addons/website_crm_partner_assign/controllers/main.py
+++ b/addons/website_crm_partner_assign/controllers/main.py
@@ -25,8 +25,6 @@ class WebsiteCrmPartnerAssign(http.Controller):
# format displayed membership lines domain
base_partner_domain = [('is_company', '=', True)]
- if request.context['is_public_user']:
- base_partner_domain += [('website_published', '=', True)]
partner_domain = list(base_partner_domain)
if grade_id and grade_id != "all":
partner_domain += [('grade_id', '=', int(grade_id))] # try/catch int
@@ -93,10 +91,7 @@ class WebsiteCrmPartnerAssign(http.Controller):
@website.route(['/partners//'], type='http', auth="public", multilang=True)
def partners_ref(self, partner_id=0, **post):
partner_obj = request.registry['res.partner']
- if request.context['is_public_user']:
- partner_ids = partner_obj.search(request.cr, request.uid, [('website_published', '=', True), ('id', '=', partner_id)], context=request.context)
- else:
- partner_ids = partner_obj.search(request.cr, request.uid, [('id', '=', partner_id)], context=request.context)
+ partner_ids = partner_obj.search(request.cr, request.uid, [('id', '=', partner_id)], context=request.context)
if not partner_ids:
return self.members(post)
diff --git a/addons/website_google_map/controllers/main.py b/addons/website_google_map/controllers/main.py
index 786cae8e81d..b81823428e8 100644
--- a/addons/website_google_map/controllers/main.py
+++ b/addons/website_google_map/controllers/main.py
@@ -26,11 +26,6 @@ class google_map(http.Controller):
domain_public = domain + [('website_published', '=', True)]
partner_ids = partner_obj.search(request.cr, openerp.SUPERUSER_ID,
domain_public, context=request.context)
- if not request.context['is_public_user']:
- partner_ids += partner_obj.search(request.cr, request.uid, domain,
- context=request.context)
- partner_ids = list(set(partner_ids))
-
return partner_obj.google_map_json(request.cr, openerp.SUPERUSER_ID,
partner_ids, request.context)
@@ -42,14 +37,13 @@ class google_map(http.Controller):
latitude = post.get('latitude') and float(post['latitude'])
longitude = post.get('longitude') and float(post['longitude'])
- if not request.context['is_public_user'] and partner_id and (latitude or longitude):
- values = {
- 'partner_latitude': latitude,
- 'partner_longitude': longitude,
- 'date_localization': datetime.now().strftime('%Y-%m-%d'),
- }
- partner_obj.write(request.cr, request.uid, [partner_id], values,
- request.context)
+ values = {
+ 'partner_latitude': latitude,
+ 'partner_longitude': longitude,
+ 'date_localization': datetime.now().strftime('%Y-%m-%d'),
+ }
+ partner_obj.write(request.cr, request.uid, [partner_id], values,
+ request.context)
# vim:expandtab:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/website_mail/__openerp__.py b/addons/website_mail/__openerp__.py
index 9c327ed518d..55efcf01dbf 100644
--- a/addons/website_mail/__openerp__.py
+++ b/addons/website_mail/__openerp__.py
@@ -29,6 +29,7 @@
'depends': ['website', 'mail'],
'data': [
'views/website_mail.xml',
+ 'security/website_mail.xml',
],
'css': [
'static/src/css/website_mail.css',
diff --git a/addons/website_mail/controllers/main.py b/addons/website_mail/controllers/main.py
index f9a7f0718dc..88bf93fbda4 100644
--- a/addons/website_mail/controllers/main.py
+++ b/addons/website_mail/controllers/main.py
@@ -32,7 +32,7 @@ class WebsiteMail(http.Controller):
partner_obj = request.registry['res.partner']
user_obj = request.registry['res.users']
partner_ids = []
- if request.context['is_public_user'] and email and email != u'false': # post contains stringified booleans
+ if email and email != u'false': # post contains stringified booleans
partner_ids = partner_obj.search(request.cr, SUPERUSER_ID, [("email", "=", email)], context=request.context)
if not partner_ids:
partner_ids = [partner_obj.name_create(request.cr, SUPERUSER_ID, email, request.context)]
diff --git a/addons/website_mail/security/website_mail.xml b/addons/website_mail/security/website_mail.xml
new file mode 100644
index 00000000000..67c2d869372
--- /dev/null
+++ b/addons/website_mail/security/website_mail.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/addons/website_mail/tests/test_controllers.py b/addons/website_mail/tests/test_controllers.py
index 2168b96cd35..e716002be6f 100644
--- a/addons/website_mail/tests/test_controllers.py
+++ b/addons/website_mail/tests/test_controllers.py
@@ -31,9 +31,7 @@ class TestControllers(TestMail):
# print request
cr, uid = self.cr, self.uid
- # context = {
- # 'is_public_user': True,
- # }
+ # context = { }
# email = 'Marcel Dupuis '
# website_mail = WebsiteMail()
diff --git a/addons/website_mail/views/website_mail.xml b/addons/website_mail/views/website_mail.xml
index 6288f46157e..90fb802bc6b 100644
--- a/addons/website_mail/views/website_mail.xml
+++ b/addons/website_mail/views/website_mail.xml
@@ -6,7 +6,7 @@
-