summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2014-08-01 13:06:49 +0200
committerOlivier Dony <odo@openerp.com>2014-08-01 13:06:49 +0200
commitee4df1e397a7f1ada09f53c3b72d9dddfa9b3e22 (patch)
tree438b018b377a0c94be1d19e4c3928974b9d18f08
parent5ddc0305cd0bef77632ee50fb19ae7372ae5cb68 (diff)
parent8b15482e0037b2484e993ffaf9e5691662c99e28 (diff)
[MERGE] Forward-port saas-4 up to 8b15482
-rw-r--r--addons/account/account_analytic_line.py10
-rw-r--r--addons/account/account_invoice.py2
-rw-r--r--addons/crm/base_partner_merge.py13
-rw-r--r--addons/mail/mail_thread.py8
-rw-r--r--addons/mass_mailing/controllers/main.py3
-rw-r--r--addons/mass_mailing/models/mass_mailing.py11
-rw-r--r--addons/web/static/src/xml/base.xml2
-rw-r--r--addons/website_customer/controllers/main.py11
-rw-r--r--openerp/osv/orm.py13
9 files changed, 49 insertions, 24 deletions
diff --git a/addons/account/account_analytic_line.py b/addons/account/account_analytic_line.py
index e141f33b9d1..efc0bc6a580 100644
--- a/addons/account/account_analytic_line.py
+++ b/addons/account/account_analytic_line.py
@@ -74,13 +74,19 @@ class account_analytic_line(osv.osv):
product_obj = self.pool.get('product.product')
analytic_journal_obj =self.pool.get('account.analytic.journal')
product_price_type_obj = self.pool.get('product.price.type')
+ product_uom_obj = self.pool.get('product.uom')
j_id = analytic_journal_obj.browse(cr, uid, journal_id, context=context)
prod = product_obj.browse(cr, uid, prod_id, context=context)
result = 0.0
if prod_id:
- unit = prod.uom_id.id
+ unit_obj = False
+ if unit:
+ unit_obj = product_uom_obj.browse(cr, uid, unit, context=context)
+ if not unit_obj or prod.uom_id.category_id.id != unit_obj.category_id.id:
+ unit = prod.uom_id.id
if j_id.type == 'purchase':
- unit = prod.uom_po_id.id
+ if not unit_obj or prod.uom_po_id.category_id.id != unit_obj.category_id.id:
+ unit = prod.uom_po_id.id
if j_id.type <> 'sale':
a = prod.property_account_expense.id
if not a:
diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py
index 87c96fbdaf2..3885973415f 100644
--- a/addons/account/account_invoice.py
+++ b/addons/account/account_invoice.py
@@ -426,7 +426,7 @@ class account_invoice(osv.osv):
compose_form_id = ir_model_data.get_object_reference(cr, uid, 'mail', 'email_compose_message_wizard_form')[1]
except ValueError:
compose_form_id = False
- ctx = dict(context)
+ ctx = dict()
ctx.update({
'default_model': 'account.invoice',
'default_res_id': ids[0],
diff --git a/addons/crm/base_partner_merge.py b/addons/crm/base_partner_merge.py
index c07a32579f0..11cacc57ce6 100644
--- a/addons/crm/base_partner_merge.py
+++ b/addons/crm/base_partner_merge.py
@@ -378,11 +378,20 @@ class MergePartnerAutomatic(osv.TransientModel):
return {'type': 'ir.actions.act_window_close'}
def _generate_query(self, fields, maximum_group=100):
- group_fields = ', '.join(fields)
+ sql_fields = []
+ for field in fields:
+ if field in ['email', 'name']:
+ sql_fields.append('lower(%s)' % field)
+ elif field in ['vat']:
+ sql_fields.append("replace(%s, ' ', '')" % field)
+ else:
+ sql_fields.append(field)
+
+ group_fields = ', '.join(sql_fields)
filters = []
for field in fields:
- if field in ['email', 'name']:
+ if field in ['email', 'name', 'vat']:
filters.append((field, 'IS NOT', 'NULL'))
criteria = ' AND '.join('%s %s %s' % (field, operator, value)
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index d04221cd0f5..23c3255500c 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -906,7 +906,7 @@ class mail_thread(osv.AbstractModel):
# 1. message is a reply to an existing message (exact match of message_id)
ref_match = thread_references and tools.reference_re.search(thread_references)
- msg_references = thread_references.split()
+ msg_references = mail_header_msgid_re.findall(thread_references)
mail_message_ids = mail_msg_obj.search(cr, uid, [('message_id', 'in', msg_references)], context=context)
if ref_match and mail_message_ids:
original_msg = mail_msg_obj.browse(cr, SUPERUSER_ID, mail_message_ids[0], context=context)
@@ -949,7 +949,7 @@ class mail_thread(osv.AbstractModel):
email_from, email_to, message_id, model, thread_id, custom_values, uid)
return [route]
- # 2. Reply to a private message
+ # 3. Reply to a private message
if in_reply_to:
mail_message_ids = mail_msg_obj.search(cr, uid, [
('message_id', '=', in_reply_to),
@@ -966,7 +966,7 @@ class mail_thread(osv.AbstractModel):
email_from, email_to, message_id, mail_message.id, custom_values, uid)
return [route]
- # 3. Look for a matching mail.alias entry
+ # 4. Look for a matching mail.alias entry
# Delivered-To is a safe bet in most modern MTAs, but we have to fallback on To + Cc values
# for all the odd MTAs out there, as there is no standard header for the envelope's `rcpt_to` value.
rcpt_tos = \
@@ -1001,7 +1001,7 @@ class mail_thread(osv.AbstractModel):
routes.append(route)
return routes
- # 4. Fallback to the provided parameters, if they work
+ # 5. Fallback to the provided parameters, if they work
if not thread_id:
# Legacy: fallback to matching [ID] in the Subject
match = tools.res_re.search(decode_header(message, 'Subject'))
diff --git a/addons/mass_mailing/controllers/main.py b/addons/mass_mailing/controllers/main.py
index 5eed0e38615..bfe975059c5 100644
--- a/addons/mass_mailing/controllers/main.py
+++ b/addons/mass_mailing/controllers/main.py
@@ -67,8 +67,7 @@ class MassMailController(http.Controller):
contact_ids = Contacts.search(cr, SUPERUSER_ID, [('list_id', '=', int(list_id)), ('email', '=', email)], context=context)
if not contact_ids:
- contact_ng = Contacts.name_create(cr, SUPERUSER_ID, email, context=context)
- Contacts.write(cr, SUPERUSER_ID, [contact_ng[0]], {'list_id': int(list_id)}, context=context)
+ Contacts.add_to_list(cr, SUPERUSER_ID, email, int(list_id), context=context)
# add email to session
request.session['mass_mailing_email'] = email
return True
diff --git a/addons/mass_mailing/models/mass_mailing.py b/addons/mass_mailing/models/mass_mailing.py
index a1077a3fffa..001a15b2891 100644
--- a/addons/mass_mailing/models/mass_mailing.py
+++ b/addons/mass_mailing/models/mass_mailing.py
@@ -52,15 +52,24 @@ class MassMailingContact(osv.Model):
'list_id': _get_latest_list
}
- def name_create(self, cr, uid, name, context=None):
+ def get_name_email(self, name, context):
name, email = self.pool['res.partner']._parse_partner_name(name, context=context)
if name and not email:
email = name
if email and not name:
name = email
+ return name, email
+
+ def name_create(self, cr, uid, name, context=None):
+ name, email = self.get_name_email(name, context=context)
rec_id = self.create(cr, uid, {'name': name, 'email': email}, context=context)
return self.name_get(cr, uid, [rec_id], context)[0]
+ def add_to_list(self, cr, uid, name, list_id, context=None):
+ name, email = self.get_name_email(name, context=context)
+ rec_id = self.create(cr, uid, {'name': name, 'email': email, 'list_id': list_id}, context=context)
+ return self.name_get(cr, uid, [rec_id], context)[0]
+
def message_get_default_recipients(self, cr, uid, ids, context=None):
res = {}
for record in self.browse(cr, uid, ids, context=context):
diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml
index de544c7dff8..efd143669b2 100644
--- a/addons/web/static/src/xml/base.xml
+++ b/addons/web/static/src/xml/base.xml
@@ -40,7 +40,7 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 class="modal-title"><t t-raw="title"/></h3>
</div>
- <div class="modal-body" style="overflow-y: auto;">
+ <div class="modal-body">
</div>
</div>
</div>
diff --git a/addons/website_customer/controllers/main.py b/addons/website_customer/controllers/main.py
index fcb2d0d8ded..d4b996a0ab6 100644
--- a/addons/website_customer/controllers/main.py
+++ b/addons/website_customer/controllers/main.py
@@ -42,11 +42,12 @@ class WebsiteCustomer(http.Controller):
if country_id:
domain += [('country_id', '=', country_id)]
if not any(x['country_id'][0] == country_id for x in countries):
- country = country_obj.browse(cr, uid, country_id, context)
- countries.append({
- 'country_id_count': 0,
- 'country_id': (country_id, country.name)
- })
+ country = country_obj.read(cr, uid, country_id, ['name'], context)
+ if country:
+ countries.append({
+ 'country_id_count': 0,
+ 'country_id': (country_id, country['name'])
+ })
countries.sort(key=lambda d: d['country_id'][1])
countries.insert(0, {
diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py
index 1ab19d13392..79d460e9422 100644
--- a/openerp/osv/orm.py
+++ b/openerp/osv/orm.py
@@ -4643,18 +4643,19 @@ class BaseModel(object):
order_by = self._generate_order_by(order, query)
from_clause, where_clause, where_clause_params = query.get_sql()
- limit_str = limit and ' limit %d' % limit or ''
- offset_str = offset and ' offset %d' % offset or ''
where_str = where_clause and (" WHERE %s" % where_clause) or ''
- query_str = 'SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str
if count:
- # /!\ the main query must be executed as a subquery, otherwise
- # offset and limit apply to the result of count()!
- cr.execute('SELECT count(*) FROM (%s) AS count' % query_str, where_clause_params)
+ # Ignore order, limit and offset when just counting, they don't make sense and could
+ # hurt performance
+ query_str = 'SELECT count(1) FROM ' + from_clause + where_str
+ cr.execute(query_str, where_clause_params)
res = cr.fetchone()
return res[0]
+ limit_str = limit and ' limit %d' % limit or ''
+ offset_str = offset and ' offset %d' % offset or ''
+ query_str = 'SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str
cr.execute(query_str, where_clause_params)
res = cr.fetchall()