diff --git a/.bzrignore b/.bzrignore
index 1f9c25fe409..1cb1e6f8388 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -1,3 +1,3 @@
-./bin/addons/*
-./bin/filestore*
-
+*.pyc
+.*.swp
+.bzrignore
diff --git a/bin/addons/base/res/partner/partner.py b/bin/addons/base/res/partner/partner.py
index cfe1cb41710..97c2ed45ac3 100644
--- a/bin/addons/base/res/partner/partner.py
+++ b/bin/addons/base/res/partner/partner.py
@@ -163,10 +163,6 @@ class res_partner(osv.osv):
'customer': lambda *a: 1,
'category_id': _default_category,
}
- _sql_constraints = [
- ('name_uniq', 'unique (name)', 'The name of the partner must be unique !')
- ]
-
def copy(self, cr, uid, id, default=None, context={}):
name = self.read(cr, uid, [id], ['name'])[0]['name']
default.update({'name': name+' (copy)'})
diff --git a/bin/addons/base/res/partner/wizard/wizard_spam.py b/bin/addons/base/res/partner/wizard/wizard_spam.py
index 435bc2a9e94..aa10b08c73e 100644
--- a/bin/addons/base/res/partner/wizard/wizard_spam.py
+++ b/bin/addons/base/res/partner/wizard/wizard_spam.py
@@ -30,7 +30,7 @@ email_send_form = '''
-
+
'''
email_send_fields = {
diff --git a/bin/osv/orm.py b/bin/osv/orm.py
index 6644142517c..a1aea09eaba 100644
--- a/bin/osv/orm.py
+++ b/bin/osv/orm.py
@@ -2285,60 +2285,42 @@ class orm(orm_template):
self.pool._init_parent[self._name]=True
else:
for id in ids:
+ # Find Position of the element
if vals[self._parent_name]:
cr.execute('select parent_left,parent_right,id from '+self._table+' where '+self._parent_name+'=%s order by '+(self._parent_order or self._order), (vals[self._parent_name],))
- pleft_old = pright_old = None
- result_p = cr.fetchall()
- for (pleft,pright,pid) in result_p:
- if pid == id:
- break
- pleft_old = pleft
- pright_old = pright
- if not pleft_old:
- cr.execute('select parent_left,parent_right from '+self._table+' where id=%s', (vals[self._parent_name],))
- pleft_old,pright_old = cr.fetchone()
- res = (pleft_old, pright_old)
else:
- cr.execute('SELECT parent_left,parent_right FROM '+self._table+' WHERE id IS NULL')
- res = cr.fetchone()
- if res:
- pleft,pright = res
- else:
- cr.execute('select max(parent_right),max(parent_right)+1 from '+self._table)
- pleft,pright = cr.fetchone()
- cr.execute('select parent_left,parent_right,id from '+self._table+' where id in ('+','.join(map(lambda x:'%s',ids))+')', ids)
- dest = pleft + 1
- for cleft,cright,cid in cr.fetchall():
- if cleft > pleft:
- treeshift = pleft - cleft + 1
- leftbound = pleft+1
- rightbound = cleft-1
- cwidth = cright-cleft+1
- leftrange = cright
- rightrange = pleft
+ cr.execute('select parent_left,parent_right,id from '+self._table+' where '+self._parent_name+' is null order by '+(self._parent_order or self._order))
+ result_p = cr.fetchall()
+ position = None
+ for (pleft,pright,pid) in result_p:
+ if pid == id:
+ break
+ position = pright+1
+
+ # It's the first node of the parent: position = parent_left+1
+ if not position:
+ if not vals[self._parent_name]:
+ position = 1
else:
- treeshift = pleft - cright
- leftbound = cright + 1
- rightbound = pleft
- cwidth = cleft-cright-1
- leftrange = pleft+1
- rightrange = cleft
- cr.execute('UPDATE '+self._table+'''
- SET
- parent_left = CASE
- WHEN parent_left BETWEEN %s AND %s THEN parent_left + %s
- WHEN parent_left BETWEEN %s AND %s THEN parent_left + %s
- ELSE parent_left
- END,
- parent_right = CASE
- WHEN parent_right BETWEEN %s AND %s THEN parent_right + %s
- WHEN parent_right BETWEEN %s AND %s THEN parent_right + %s
- ELSE parent_right
- END
- WHERE
- parent_left<%s OR parent_right>%s;
- ''', (leftbound,rightbound,cwidth,cleft,cright,treeshift,leftbound,rightbound,
- cwidth,cleft,cright,treeshift,leftrange,rightrange))
+ cr.execute('select parent_left from '+self._table+' where id=%s', (vals[self._parent_name],))
+ position = cr.fetchone()[0]+1
+
+ # We have the new position !
+ cr.execute('select parent_left,parent_right from '+self._table+' where id=%s', (id,))
+ pleft,pright = cr.fetchone()
+ distance = pright - pleft + 1
+
+ if position>pleft and position<=pright:
+ raise except_orm(_('UserError'), _('Recursivity Detected.'))
+
+ if pleft=%s', (distance, position))
+ cr.execute('update '+self._table+' set parent_right=parent_right+%s where parent_right>=%s', (distance, position))
+ cr.execute('update '+self._table+' set parent_left=parent_left+%s, parent_right=parent_right+%s where parent_left>=%s and parent_left<%s', (position-pleft,position-pleft, pleft, pright))
+ else:
+ cr.execute('update '+self._table+' set parent_left=parent_left+%s where parent_left>=%s', (distance, position))
+ cr.execute('update '+self._table+' set parent_right=parent_right+%s where parent_right>=%s', (distance, position))
+ cr.execute('update '+self._table+' set parent_left=parent_left-%s, parent_right=parent_right-%s where parent_left>=%s and parent_left<%s', (pleft-position+distance,pleft-position+distance, pleft+distance, pright+distance))
result = self._store_get_values(cr, user, ids, vals.keys(), context)
for order, object, ids, fields in result:
diff --git a/bin/service/security.py b/bin/service/security.py
index 449740a99ff..040d71be6e1 100644
--- a/bin/service/security.py
+++ b/bin/service/security.py
@@ -40,11 +40,10 @@ def check_super(passwd):
return True
else:
raise Exception('AccessDenied')
-
+
def check(db, uid, passwd):
if _uid_cache.get(db, {}).get(uid) == passwd:
return True
-
cr = pooler.get_db(db).cursor()
cr.execute('select count(*) from res_users where id=%s and password=%s', (int(uid), passwd))
res = cr.fetchone()[0]
diff --git a/bin/tools/misc.py b/bin/tools/misc.py
index eb6ac0e702d..28f529a76b0 100644
--- a/bin/tools/misc.py
+++ b/bin/tools/misc.py
@@ -304,6 +304,7 @@ def reverse_enumerate(l):
#----------------------------------------------------------
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, reply_to=False, attach=None, tinycrm=False, ssl=False, debug=False, subtype='plain'):
"""Send an email."""
+ print 'sending', email_from, email_to, subject, body
import smtplib
from email.MIMEText import MIMEText
from email.MIMEBase import MIMEBase