[tryton-debian-vcs] tryton-server branch upstream-3.8 updated. upstream/3.8.11-1-g9edbc0d

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-3.8 branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-server.git;a=commitdiff;h=upstream/3.8.11-1-g9edbc0d

commit 9edbc0d83ce8d202d57c8ed52666d33e48372493
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Sun Jun 11 22:22:32 2017 +0200

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

diff --git a/CHANGELOG b/CHANGELOG
index 647df48..a4313b0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+Version 3.8.12 - 2017-06-05
+* Bug fixes (see mercurial logs for details)
+
 Version 3.8.11 - 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 a64e811..5c32dc3 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: trytond
-Version: 3.8.11
+Version: 3.8.12
 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 a64e811..5c32dc3 100644
--- a/trytond.egg-info/PKG-INFO
+++ b/trytond.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: trytond
-Version: 3.8.11
+Version: 3.8.12
 Summary: Tryton server
 Home-page: http://www.tryton.org/
 Author: Tryton
diff --git a/trytond/__init__.py b/trytond/__init__.py
index 6a7efe5..c010864 100644
--- a/trytond/__init__.py
+++ b/trytond/__init__.py
@@ -4,7 +4,7 @@ import os
 import time
 from email import charset
 
-__version__ = "3.8.11"
+__version__ = "3.8.12"
 
 os.environ['TZ'] = 'UTC'
 if hasattr(time, 'tzset'):
diff --git a/trytond/backend/sqlite/database.py b/trytond/backend/sqlite/database.py
index 91346b0..7e1cba1 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',
     'Cursor']
@@ -143,6 +143,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
@@ -159,6 +180,7 @@ MAPPING = {
     Overlay: SQLiteOverlay,
     CharLength: SQLiteCharLength,
     CurrentTimestamp: SQLiteCurrentTimestamp,
+    Trim: SQLiteTrim,
     }
 
 
diff --git a/trytond/ir/translation.py b/trytond/ir/translation.py
index 6bae60c..681b16d 100644
--- a/trytond/ir/translation.py
+++ b/trytond/ir/translation.py
@@ -424,7 +424,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
@@ -461,7 +461,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
 
@@ -655,7 +655,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 d09bdb0..f1811af 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 740ea5d..a086447 100644
--- a/trytond/model/fields/many2one.py
+++ b/trytond/model/fields/many2one.py
@@ -1,7 +1,9 @@
 # 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 types import NoneType
-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
@@ -226,13 +228,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