[tryton-debian-vcs] tryton-server branch upstream-4.0 updated. upstream/4.0.8-1-g4605632

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Sun Jun 11 22:39:18 UTC 2017


The following commit has been merged in the upstream-4.0 branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-server.git;a=commitdiff;h=upstream/4.0.8-1-g4605632

commit 46056321e1c342e95551857c17826d1f1dc37606
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Sun Jun 11 22:25:25 2017 +0200

    Adding upstream version 4.0.9.
    
    Signed-off-by: Mathias Behrle <mathiasb at m9s.biz>

diff --git a/CHANGELOG b/CHANGELOG
index 67d955b..cd682e6 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 4.0.9 - 2017-06-05
+* Bug fixes (see mercurial logs for details)
+
 Version 4.0.8 - 2017-04-03
 * Bug fixes (see mercurial logs for details)
 * Sanitize path in file_open against suffix (CVE-2017-0360)
diff --git a/PKG-INFO b/PKG-INFO
index 95b80c3..eb94563 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: trytond
-Version: 4.0.8
+Version: 4.0.9
 Summary: Tryton server
 Home-page: http://www.tryton.org/
 Author: Tryton
diff --git a/setup.cfg b/setup.cfg
index 861a9f5..8bfd5a1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,5 +1,4 @@
 [egg_info]
 tag_build = 
 tag_date = 0
-tag_svn_revision = 0
 
diff --git a/trytond.egg-info/PKG-INFO b/trytond.egg-info/PKG-INFO
index 95b80c3..eb94563 100644
--- a/trytond.egg-info/PKG-INFO
+++ b/trytond.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: trytond
-Version: 4.0.8
+Version: 4.0.9
 Summary: Tryton server
 Home-page: http://www.tryton.org/
 Author: Tryton
diff --git a/trytond/__init__.py b/trytond/__init__.py
index 946b92a..c224b9b 100644
--- a/trytond/__init__.py
+++ b/trytond/__init__.py
@@ -5,7 +5,7 @@ import time
 import logging
 from email import charset
 
-__version__ = "4.0.8"
+__version__ = "4.0.9"
 logger = logging.getLogger(__name__)
 
 os.environ['TZ'] = 'UTC'
diff --git a/trytond/backend/sqlite/database.py b/trytond/backend/sqlite/database.py
index 8a3e916..9cbbbeb 100644
--- a/trytond/backend/sqlite/database.py
+++ b/trytond/backend/sqlite/database.py
@@ -22,7 +22,7 @@ except ImportError:
     from sqlite3 import OperationalError as DatabaseOperationalError
 from sql import Flavor, Table
 from sql.functions import (Function, Extract, Position, Substring,
-    Overlay, CharLength, CurrentTimestamp)
+    Overlay, CharLength, CurrentTimestamp, Trim)
 
 __all__ = ['Database', 'DatabaseIntegrityError', 'DatabaseOperationalError']
 
@@ -142,6 +142,27 @@ class SQLiteCurrentTimestamp(Function):
     _function = 'NOW'  # More precise
 
 
+class SQLiteTrim(Trim):
+
+    def __str__(self):
+        flavor = Flavor.get()
+        param = flavor.param
+
+        function = {
+            'BOTH': 'TRIM',
+            'LEADING': 'LTRIM',
+            'TRAILING': 'RTRIM',
+            }[self.position]
+
+        def format(arg):
+            if isinstance(arg, basestring):
+                return param
+            else:
+                return str(arg)
+        return function + '(%s, %s)' % (
+            format(self.string), format(self.characters))
+
+
 def sign(value):
     if value > 0:
         return 1
@@ -174,6 +195,7 @@ MAPPING = {
     Overlay: SQLiteOverlay,
     CharLength: SQLiteCharLength,
     CurrentTimestamp: SQLiteCurrentTimestamp,
+    Trim: SQLiteTrim,
     }
 
 
diff --git a/trytond/ir/translation.py b/trytond/ir/translation.py
index 45dee8a..497f7ae 100644
--- a/trytond/ir/translation.py
+++ b/trytond/ir/translation.py
@@ -431,7 +431,7 @@ class Translation(ModelSQL, ModelView):
         if not Transaction().context.get(
                 'fuzzy_translation', False):
             for obj_id in ids:
-                trans = cls._translation_cache.get((lang, ttype, name, obj_id),
+                trans = cls._translation_cache.get((name, ttype, lang, obj_id),
                     -1)
                 if trans != -1:
                     translations[obj_id] = trans
@@ -469,7 +469,7 @@ class Translation(ModelSQL, ModelView):
                     translations[res_id] = value
         for res_id in ids:
             if res_id not in translations:
-                cls._translation_cache.set((lang, ttype, name, res_id), False)
+                cls._translation_cache.set((name, ttype, lang, res_id), False)
                 translations[res_id] = False
         return translations
 
@@ -664,7 +664,7 @@ class Translation(ModelSQL, ModelView):
             lang = unicode(lang)
             if source is not None:
                 source = unicode(source)
-            trans = cls._translation_cache.get((lang, ttype, name, source), -1)
+            trans = cls._translation_cache.get((name, ttype, lang, source), -1)
             if trans != -1:
                 res[(name, ttype, lang, source)] = trans
             else:
diff --git a/trytond/model/fields/field.py b/trytond/model/fields/field.py
index aff2085..a86cedc 100644
--- a/trytond/model/fields/field.py
+++ b/trytond/model/fields/field.py
@@ -64,6 +64,21 @@ def size_validate(value):
                 'size must return integer'
 
 
+def _set_value(record, field):
+    try:
+        field, nested = field.split('.', 1)
+    except ValueError:
+        nested = None
+    if field.startswith('_parent_'):
+        field = field[8:]  # Strip '_parent_'
+    if not hasattr(record, field):
+        setattr(record, field, None)
+    elif nested:
+        parent = getattr(record, field)
+        if parent:
+            _set_value(parent, nested)
+
+
 def depends(*fields, **kwargs):
     methods = kwargs.pop('methods', None)
     assert not kwargs
@@ -81,11 +96,7 @@ def depends(*fields, **kwargs):
         @wraps(func)
         def wrapper(self, *args, **kwargs):
             for field in fields:
-                field = field.split('.')[0]
-                if field.startswith('_parent_'):
-                    field = field[8:]  # Strip '_parent_'
-                if not hasattr(self, field):
-                    setattr(self, field, None)
+                _set_value(self, field)
             return func(self, *args, **kwargs)
         return wrapper
     return decorator
diff --git a/trytond/model/fields/many2one.py b/trytond/model/fields/many2one.py
index f5bfaed..2a697c6 100644
--- a/trytond/model/fields/many2one.py
+++ b/trytond/model/fields/many2one.py
@@ -1,6 +1,8 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
-from sql import Query, Expression, Literal
+from sql import Query, Expression, Literal, Column
+from sql.aggregate import Max
+from sql.conditionals import Coalesce
 from sql.operators import Or
 
 from .field import Field, SQLType
@@ -248,13 +250,27 @@ class Many2One(Field):
         Target = self.get_target()
         table, _ = tables[None]
         target_tables = tables.get(self.name)
+        context = Transaction().context
         if target_tables is None:
-            if Target._history and Transaction().context.get('_datetime'):
+            if Target._history and context.get('_datetime'):
                 target = Target.__table_history__()
+                target_history = Target.__table_history__()
+                history_condition = Column(target, '__id').in_(
+                    target_history.select(
+                        Max(Column(target_history, '__id')),
+                        where=Coalesce(
+                            target_history.write_date,
+                            target_history.create_date)
+                        <= context['_datetime'],
+                        group_by=target_history.id))
             else:
                 target = Target.__table__()
+                history_condition = None
+            condition = target.id == self.sql_column(table)
+            if history_condition:
+                condition &= history_condition
             target_tables = {
-                None: (target, target.id == self.sql_column(table)),
+                None: (target, condition),
                 }
             tables[self.name] = target_tables
         return target_tables
-- 
tryton-server



More information about the tryton-debian-vcs mailing list