summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2016-04-01 18:49:06 +0200
committerChristophe Simonis <chs@odoo.com>2016-04-01 18:49:06 +0200
commitf4d1adc116f226e5ccdbda114248848d4eb9ebfc (patch)
tree552f0ed75d4d085c210d747eb80049d04cd739b9 /addons
parentd3c93a838bfa6b34c196737dbf8e22fbfa4ac29d (diff)
parent1e404b7b6950cb01b3070caf8259d1e7d179ec04 (diff)
[MERGE] forward port of branch saas-7 up to 1e404b7
Diffstat (limited to 'addons')
-rw-r--r--addons/crm/base_partner_merge.py6
-rw-r--r--addons/crm/i18n/crm.pot6
-rw-r--r--addons/google_drive/google_drive.py18
-rw-r--r--addons/project_issue/project_issue.py2
-rw-r--r--addons/rating/models/rating.py2
5 files changed, 32 insertions, 2 deletions
diff --git a/addons/crm/base_partner_merge.py b/addons/crm/base_partner_merge.py
index 2c203affb6b..8baf69a5a7a 100644
--- a/addons/crm/base_partner_merge.py
+++ b/addons/crm/base_partner_merge.py
@@ -302,6 +302,12 @@ class MergePartnerAutomatic(osv.TransientModel):
if len(partner_ids) > 3:
raise UserError(_("For safety reasons, you cannot merge more than 3 contacts together. You can re-open the wizard several times if needed."))
+ child_ids = set()
+ for partner_id in partner_ids:
+ child_ids = child_ids.union(set(proxy.search(cr, uid, [('id', 'child_of', [partner_id])])) - set([partner_id]))
+ if set(partner_ids).intersection(child_ids):
+ raise osv.except_osv(_('Error'), _("You cannot merge a contact with one of his parent."))
+
if openerp.SUPERUSER_ID != uid and len(set(partner.email for partner in proxy.browse(cr, uid, partner_ids, context=context))) > 1:
raise UserError(_("All contacts must have the same email. Only the Administrator can merge contacts with different emails."))
diff --git a/addons/crm/i18n/crm.pot b/addons/crm/i18n/crm.pot
index 16d54791d9f..ab7b2ae7015 100644
--- a/addons/crm/i18n/crm.pot
+++ b/addons/crm/i18n/crm.pot
@@ -3776,6 +3776,12 @@ msgid "You can also combine several rules into a sequence.<br/>\n"
msgstr ""
#. module: crm
+#: code:addons/crm/base_partner_merge.py:309
+#, python-format
+msgid "You cannot merge a contact with one of his parent."
+msgstr ""
+
+#. module: crm
#: model:ir.ui.view,arch_db:crm.crm_planner
msgid "You can change the pricing method at anytime. We\n"
" recommend you to select the easiest option that\n"
diff --git a/addons/google_drive/google_drive.py b/addons/google_drive/google_drive.py
index dd723c4f10d..3cd7da3612d 100644
--- a/addons/google_drive/google_drive.py
+++ b/addons/google_drive/google_drive.py
@@ -223,9 +223,25 @@ class config(osv.Model):
class base_config_settings(osv.TransientModel):
_inherit = "base.config.settings"
+ def _get_drive_uri(self, cr, uid, ids, field_name, arg, context=None):
+ return {
+ wizard_id: self.default_get(cr, uid, ['google_drive_uri']).get('google_drive_uri')
+ for wizard_id in ids
+ }
+
+ def _get_wizard_ids(self, cr, uid, ids, context=None):
+ result = []
+ if any(rec.key in ['google_drive_client_id', 'google_redirect_uri'] for rec in self.browse(cr, uid, ids, context=context)):
+ result.extend(self.pool['base.config.settings'].search(cr, uid, [], context=context))
+ return result
+
_columns = {
'google_drive_authorization_code': fields.char('Authorization Code'),
- 'google_drive_uri': fields.char('URI', readonly=True, help="The URL to generate the authorization code from Google"),
+ 'google_drive_uri': fields.function(_get_drive_uri, string='URI', help="The URL to generate the authorization code from Google", type="char", store={
+ 'ir.config_parameter': (_get_wizard_ids, None, 20),
+ }), # TODO: 1. in master, remove the store, there is no reason for this field to be stored. It's just a dynamic link.
+ # TODO: 2. when converted to the new API, the code to get the default value can be moved to the compute method directly, and the default value can be removed
+ # the only reason the default value is defined is because function fields are not computed in draft mode in the old API.
}
_defaults = {
'google_drive_uri': lambda s, cr, uid, c: s.pool['google.service']._get_google_token_uri(cr, uid, 'drive', scope=s.pool['google.drive.config'].get_google_scope(), context=c),
diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py
index 2699625bd79..c7c253f2074 100644
--- a/addons/project_issue/project_issue.py
+++ b/addons/project_issue/project_issue.py
@@ -124,7 +124,7 @@ class project_issue(osv.Model):
if project_id:
project = self.pool.get('project.project').browse(cr, uid, project_id, context=context)
if project and project.partner_id:
- return {'value': {'partner_id': project.partner_id.id}}
+ return {'value': {'partner_id': project.partner_id.id, 'email_from': project.partner_id.email}}
return {}
_columns = {
diff --git a/addons/rating/models/rating.py b/addons/rating/models/rating.py
index 2c379172f56..beff19da27c 100644
--- a/addons/rating/models/rating.py
+++ b/addons/rating/models/rating.py
@@ -47,6 +47,8 @@ class Rating(models.Model):
domain = [('access_token', '=', token)] if token else [('res_model', '=', res_model), ('res_id', '=', res_id)]
rating = self.search(domain, limit=1)
if rating:
+ if token:
+ rating = rating.sudo()
rating.write({'rating' : rate})
if hasattr(self.env[rating.res_model], 'message_post'):
record = self.env[rating.res_model].sudo().browse(rating.res_id)