From 32f51689742cdec79ad2bc41ac37bb53fbb6f199 Mon Sep 17 00:00:00 2001 From: Martin Trigaux Date: Mon, 15 Sep 2014 15:24:43 +0200 Subject: [PATCH 1/5] [FIX] orm: do not drop foreign keys of transient models During the update of a module, the existing foreign keys are dropped if they have a different ondelete_rule than the one specified on the field. The foreign keys for many2one transiant -> non-transiant are created with cascade rule by default (see `m2o_add_foreign_key_checked` method) so the check needs to be realised in the same conditions. --- openerp/osv/orm.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 9bf10df39d6..07ed496000c 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -3016,6 +3016,9 @@ class BaseModel(object): if len(constraints) == 1: # Is it the right constraint? cons, = constraints + if self.is_transient() and not dest_model.is_transient(): + # transient foreign keys are added as cascade by default + ondelete = ondelete or 'cascade' if cons['ondelete_rule'] != POSTGRES_CONFDELTYPES.get((ondelete or 'set null').upper(), 'a')\ or cons['foreign_table'] != dest_model._table: # Wrong FK: drop it and recreate From 74072441cccb1cadb747e358e1af4a42d1399b86 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 13 May 2014 10:15:01 +0200 Subject: [PATCH 2/5] [FIX] sale: backport of rev 709e22c32aca [FIX] sale: sale report view, wrong domain Quotations are sale.order with state draft and sent Sale orders are sale.order with state other than draft, sent and cancel --- addons/sale/report/sale_report_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/report/sale_report_view.xml b/addons/sale/report/sale_report_view.xml index 8f725a9eacb..7ddba9b60a7 100644 --- a/addons/sale/report/sale_report_view.xml +++ b/addons/sale/report/sale_report_view.xml @@ -48,8 +48,8 @@ - - + + From ce84d6107f08a065f4b90cb8dfb7f960e908f312 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 16 Sep 2014 17:55:14 +0200 Subject: [PATCH 3/5] [FIX] point_of_sale: set journal as pos payment method on setting journal in the payment methods of a pos config when none is set. --- addons/point_of_sale/point_of_sale.py | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index a6131bca31b..d969de76c9e 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -325,6 +325,7 @@ class pos_session(osv.osv): if not cashids: cashids = journal_proxy.search(cr, uid, [('journal_user','=',True)], context=context) + journal_proxy.write(cr, uid, cashids, {'journal_user': True}) jobj.write(cr, uid, [pos_config.id], {'journal_ids': [(6,0, cashids)]}) From 0a9c64c17de3208231d3ff982c034f25c608c6fb Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 16 Sep 2014 18:33:42 +0200 Subject: [PATCH 4/5] [FIX] auth_ldap: avoid to try twice the authentication to the ldap server See #1982 --- addons/auth_ldap/users_ldap.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/auth_ldap/users_ldap.py b/addons/auth_ldap/users_ldap.py index a09b6839ab9..e253874d33a 100644 --- a/addons/auth_ldap/users_ldap.py +++ b/addons/auth_ldap/users_ldap.py @@ -251,6 +251,10 @@ class users(osv.osv): return user_id registry = RegistryManager.get(db) with registry.cursor() as cr: + cr.execute("SELECT id, active FROM res_users WHERE lower(login)=%s", (login,)) + res = cr.fetchone() + if res: + return False ldap_obj = registry.get('res.company.ldap') for conf in ldap_obj.get_ldap_dicts(cr): entry = ldap_obj.authenticate(conf, login, password) From f5f76094a79f515b1fcddfea9b4b2e73c4189c26 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 17 Sep 2014 13:32:30 +0200 Subject: [PATCH 5/5] [FIX] orm write: do not try to store computed & stored fields for relational records deleted by *2many fields opw-613772 --- openerp/osv/orm.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openerp/osv/orm.py b/openerp/osv/orm.py index 07ed496000c..f934235d99d 100644 --- a/openerp/osv/orm.py +++ b/openerp/osv/orm.py @@ -55,6 +55,7 @@ import simplejson import time import traceback import types +from collections import defaultdict import psycopg2 from lxml import etree @@ -4166,6 +4167,7 @@ class BaseModel(object): """ readonly = None self.check_field_access_rights(cr, user, 'write', vals.keys()) + deleted_related = defaultdict(list) for field in vals.copy(): fobj = None if field in self._columns: @@ -4174,6 +4176,10 @@ class BaseModel(object): fobj = self._inherit_fields[field][2] if not fobj: continue + if fobj._type in ['one2many', 'many2many'] and vals[field]: + for wtuple in vals[field]: + if isinstance(wtuple, (tuple, list)) and wtuple[0] == 2: + deleted_related[fobj._obj].append(wtuple[1]) groups = fobj.write if groups: @@ -4380,7 +4386,8 @@ class BaseModel(object): for id in ids_to_update: if id not in done[key]: done[key][id] = True - todo.append(id) + if id not in deleted_related[object]: + todo.append(id) self.pool.get(object)._store_set_values(cr, user, todo, fields_to_recompute, context) self._workflow_trigger(cr, user, ids, 'trg_write', context=context)