[tryton-debian-vcs] tryton-proteus branch debian updated. debian/3.0.0-3-4-g7272fa9

Mathias Behrle tryton-debian-vcs at alioth.debian.org
Tue Apr 22 13:11:59 UTC 2014


The following commit has been merged in the debian branch:
https://alioth.debian.org/plugins/scmgit/cgi-bin/gitweb.cgi/?p=tryton/tryton-proteus.git;a=commitdiff;h=debian/3.0.0-3-4-g7272fa9

commit 7272fa95264be8c84176eebbe0885035332d46e6
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Apr 22 15:00:33 2014 +0200

    Bumping minimal required Python version to 2.7.

diff --git a/debian/control b/debian/control
index 32099da..77b00b0 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,7 @@ Standards-Version: 3.9.5
 Homepage: http://www.tryton.org/
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=tryton/tryton-proteus.git
 Vcs-Git: git://anonscm.debian.org/tryton/tryton-proteus.git
-X-Python-Version: >= 2.6
+X-Python-Version: >= 2.7
 
 Package: tryton-proteus
 Architecture: all
commit e9c29e962b2f25bfab026385e3bb48fcee64bd75
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Apr 22 14:47:14 2014 +0200

    Updating copyright.

diff --git a/debian/copyright b/debian/copyright
index c288422..4b11c65 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,8 +1,8 @@
 Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
 
 Files: *
-Copyright: 2010-2013 Cédric Krier
-           2010-2013 B2CK SPRL
+Copyright: 2010-2014 Cédric Krier
+           2010-2014 B2CK SPRL
 License: LGPL-3+
 
 Files: debian/*
commit feb506a9d0568a7b6ff3a4500b00999c59bc1e0b
Author: Mathias Behrle <mathiasb at m9s.biz>
Date:   Tue Apr 22 14:24:19 2014 +0200

    Merging upstream version 3.2.0.

diff --git a/CHANGELOG b/CHANGELOG
index 6579877..29ee561 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,10 @@
+Version 3.2.0 - 2014-04-21
+* Bug fixes (see mercurial logs for details)
+* Models cache depends also on user
+* Drop support of Python 2.6
+* Allow to pass field values to new method
+* Add click method for buttons
+
 Version 3.0.0 - 2013-10-21
 * Bug fixes (see mercurial logs for details)
 
diff --git a/COPYRIGHT b/COPYRIGHT
index 7e8c156..c655746 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,5 +1,5 @@
-Copyright (C) 2010-2013 Cédric Krier.
-Copyright (C) 2010-2013 B2CK SPRL.
+Copyright (C) 2010-2014 Cédric Krier.
+Copyright (C) 2010-2014 B2CK SPRL.
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
diff --git a/INSTALL b/INSTALL
index 9858055..fb3635e 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,8 +4,10 @@ Installing proteus
 Prerequisites
 -------------
 
- * Python 2.6 or later (http://www.python.org/)
- * trytond (http://www.tryton.org/)
+ * Python 2.7 or later (http://www.python.org/)
+ * python-dateutil (http://labix.org/python-dateutil)
+ * Optional: trytond (http://www.tryton.org/)
+ * Optional: simplejson (http://undefined.org/python/#simplejson)
  * Optional: cdecimal (http://www.bytereef.org/mpdecimal/index.html)
 
 Installation
diff --git a/PKG-INFO b/PKG-INFO
index 9a334cb..5bf2415 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: proteus
-Version: 3.0.0
+Version: 3.2.0
 Summary: Library to access Tryton server as a client
 Home-page: http://www.tryton.org/
 Author: Tryton
-Author-email: UNKNOWN
+Author-email: issue_tracker at tryton.org
 License: LGPL-3
-Download-URL: http://downloads.tryton.org/3.0/
+Download-URL: http://downloads.tryton.org/3.2/
 Description: proteus
         =======
         
@@ -39,8 +39,8 @@ Description: proteus
         Find the module, call the install button and run the install wizard.
         
             >>> Module = Model.get('ir.module.module')
-            >>> (party,) = Module.find([('name', '=', 'party')])
-            >>> Module.install([party.id], config.context)
+            >>> party_module, = Module.find([('name', '=', 'party')])
+            >>> party_module.click('install')
             >>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
         
         Creating a party
@@ -84,7 +84,7 @@ Description: proteus
         Addresses are store on party with a `One2Many` field. So the new address just
         needs to be appended to the list `addresses`.
         
-            >>> address = party.addresses.new()
+            >>> address = party.addresses.new(zip='42')
             >>> party.save()
             >>> party.addresses #doctest: +ELLIPSIS
             [proteus.Model.get('party.address')(...)]
@@ -134,7 +134,8 @@ Description: proteus
         
           http://www.tryton.org/
         
-Platform: UNKNOWN
+Keywords: tryton library cli
+Platform: any
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Environment :: Plugins
 Classifier: Framework :: Tryton
@@ -143,6 +144,5 @@ Classifier: Intended Audience :: Financial and Insurance Industry
 Classifier: Intended Audience :: Legal Industry
 Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
 Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Topic :: Office/Business
diff --git a/README b/README
index aa9f9a7..0b23a11 100644
--- a/README
+++ b/README
@@ -30,8 +30,8 @@ Installing a module
 Find the module, call the install button and run the install wizard.
 
     >>> Module = Model.get('ir.module.module')
-    >>> (party,) = Module.find([('name', '=', 'party')])
-    >>> Module.install([party.id], config.context)
+    >>> party_module, = Module.find([('name', '=', 'party')])
+    >>> party_module.click('install')
     >>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
 
 Creating a party
@@ -75,7 +75,7 @@ Creating an address for the party
 Addresses are store on party with a `One2Many` field. So the new address just
 needs to be appended to the list `addresses`.
 
-    >>> address = party.addresses.new()
+    >>> address = party.addresses.new(zip='42')
     >>> party.save()
     >>> party.addresses #doctest: +ELLIPSIS
     [proteus.Model.get('party.address')(...)]
diff --git a/proteus.egg-info/PKG-INFO b/proteus.egg-info/PKG-INFO
index 9a334cb..5bf2415 100644
--- a/proteus.egg-info/PKG-INFO
+++ b/proteus.egg-info/PKG-INFO
@@ -1,12 +1,12 @@
 Metadata-Version: 1.1
 Name: proteus
-Version: 3.0.0
+Version: 3.2.0
 Summary: Library to access Tryton server as a client
 Home-page: http://www.tryton.org/
 Author: Tryton
-Author-email: UNKNOWN
+Author-email: issue_tracker at tryton.org
 License: LGPL-3
-Download-URL: http://downloads.tryton.org/3.0/
+Download-URL: http://downloads.tryton.org/3.2/
 Description: proteus
         =======
         
@@ -39,8 +39,8 @@ Description: proteus
         Find the module, call the install button and run the install wizard.
         
             >>> Module = Model.get('ir.module.module')
-            >>> (party,) = Module.find([('name', '=', 'party')])
-            >>> Module.install([party.id], config.context)
+            >>> party_module, = Module.find([('name', '=', 'party')])
+            >>> party_module.click('install')
             >>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
         
         Creating a party
@@ -84,7 +84,7 @@ Description: proteus
         Addresses are store on party with a `One2Many` field. So the new address just
         needs to be appended to the list `addresses`.
         
-            >>> address = party.addresses.new()
+            >>> address = party.addresses.new(zip='42')
             >>> party.save()
             >>> party.addresses #doctest: +ELLIPSIS
             [proteus.Model.get('party.address')(...)]
@@ -134,7 +134,8 @@ Description: proteus
         
           http://www.tryton.org/
         
-Platform: UNKNOWN
+Keywords: tryton library cli
+Platform: any
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Environment :: Plugins
 Classifier: Framework :: Tryton
@@ -143,6 +144,5 @@ Classifier: Intended Audience :: Financial and Insurance Industry
 Classifier: Intended Audience :: Legal Industry
 Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
 Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Topic :: Office/Business
diff --git a/proteus.egg-info/SOURCES.txt b/proteus.egg-info/SOURCES.txt
index 9ca43b4..1eef609 100644
--- a/proteus.egg-info/SOURCES.txt
+++ b/proteus.egg-info/SOURCES.txt
@@ -13,6 +13,7 @@ proteus.egg-info/SOURCES.txt
 proteus.egg-info/dependency_links.txt
 proteus.egg-info/requires.txt
 proteus.egg-info/top_level.txt
+proteus.egg-info/zip-safe
 proteus/tests/__init__.py
 proteus/tests/test_config.py
 proteus/tests/test_context.py
diff --git a/proteus.egg-info/requires.txt b/proteus.egg-info/requires.txt
index 2275f28..e8c47c8 100644
--- a/proteus.egg-info/requires.txt
+++ b/proteus.egg-info/requires.txt
@@ -4,7 +4,7 @@ python-dateutil
 cdecimal
 
 [trytond]
-trytond >= 3.0, < 3.1
+trytond >= 3.2, < 3.3
 
 [simplejson]
 simplejson
\ No newline at end of file
diff --git a/proteus.egg-info/zip-safe b/proteus.egg-info/zip-safe
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/proteus.egg-info/zip-safe
@@ -0,0 +1 @@
+
diff --git a/proteus/__init__.py b/proteus/__init__.py
index 9843977..78fd625 100644
--- a/proteus/__init__.py
+++ b/proteus/__init__.py
@@ -3,7 +3,7 @@
 '''
 A library to access Tryton's models like a client.
 '''
-__version__ = "3.0.0"
+__version__ = "3.2.0"
 __all__ = ['Model', 'Wizard']
 import sys
 try:
@@ -143,6 +143,8 @@ class NumericDescriptor(FieldDescriptor):
 class ReferenceDescriptor(FieldDescriptor):
     def __get__(self, instance, owner):
         value = super(ReferenceDescriptor, self).__get__(instance, owner)
+        if instance._parent_name == self.name:
+            value = instance._parent
         if isinstance(value, basestring):
             model_name, id = value.split(',', 1)
             if model_name:
@@ -196,6 +198,8 @@ class Many2OneDescriptor(FieldDescriptor):
     def __get__(self, instance, owner):
         relation = Model.get(self.definition['relation'], instance._config)
         value = super(Many2OneDescriptor, self).__get__(instance, owner)
+        if instance._parent_name == self.name:
+            value = instance._parent
         if isinstance(value, (int, long)) and value is not False:
             value = relation(value)
         elif not value:
@@ -272,21 +276,27 @@ class One2OneValueDescriptor(Many2OneValueDescriptor):
 
 class One2ManyValueDescriptor(ValueDescriptor):
     def __get__(self, instance, owner):
-        value = [('add', [])]
+        value = []
         value_list = getattr(instance, self.name)
+        to_add = []
         to_create = []
+        to_write = []
         for record in value_list:
-            if record.id > 0:
+            if record.id >= 0:
                 if record._changed:
-                    value.append(('write', [record.id], record._get_values(
-                        fields=record._changed)))
-                value[0][1].append(record.id)
+                    to_write.extend(([record.id],
+                            record._get_values(fields=record._changed)))
+                to_add.append(record.id)
             else:
                 to_create.append(record._get_values())
+        if to_add:
+            value.append(('add', to_add))
         if to_create:
             value.append(('create', to_create))
+        if to_write:
+            value.append(('write',) + tuple(to_write))
         if value_list.record_removed:
-            value.append(('unlink', [x.id for x in value_list.record_removed]))
+            value.append(('remove', [x.id for x in value_list.record_removed]))
         if value_list.record_deleted:
             value.append(('delete', [x.id for x in value_list.record_deleted]))
         return value
@@ -340,7 +350,6 @@ class MetaModelFactory(object):
         'boolean': BooleanDescriptor,
         'char': CharDescriptor,
         'text': CharDescriptor,
-        'sha': CharDescriptor,
         'binary': BinaryDescriptor,
         'selection': CharDescriptor,  # TODO implement its own descriptor
         'integer': IntegerDescriptor,
@@ -380,7 +389,7 @@ class MetaModelFactory(object):
         self.config = config or proteus.config.get_config()
 
     def __call__(self):
-        models_key = 'c%s' % id(self.config)
+        models_key = 'c%su%s' % (id(self.config), self.config.user)
         if not hasattr(_MODELS, models_key):
             setattr(_MODELS, models_key, {})
 
@@ -530,11 +539,11 @@ class ModelList(list):
         raise NotImplementedError
     sort.__doc__ = list.sort.__doc__
 
-    def new(self):
+    def new(self, **kwargs):
         'Adds a new record to the ModelList and returns it'
         Relation = Model.get(self.model_name, self.parent._config)
         with Relation._config.set_context(self._get_context()):
-            new_record = Relation()
+            new_record = Relation(**kwargs)
         self.append(new_record)
         return new_record
 
@@ -608,7 +617,7 @@ class Model(object):
     def reset(cls, config=None, *names):
         'Reset class definition for Models named'
         config = config or proteus.config.get_config()
-        models_key = 'c%s' % id(config)
+        models_key = 'c%su%s' % (id(config), config.user)
         if not names:
             setattr(_MODELS, models_key, {})
         else:
@@ -679,6 +688,12 @@ class Model(object):
         self.reload()
         return True
 
+    def click(self, button):
+        'Click on button'
+        self.save()
+        self.reload()  # Force reload because save doesn't always
+        return getattr(self._proxy, button)([self.id], self._config.context)
+
     def _get_values(self, fields=None):
         'Return dictionary values'
         if fields is None:
@@ -756,11 +771,14 @@ class Model(object):
         return values
 
     def _get_on_change_value(self):
-        values = self._get_eval()
+        values = {'id': self.id}
         for field, definition in self._fields.iteritems():
-            if definition['type'] == 'one2many':
-                values[field] = [x._get_on_change_value()
-                    for x in getattr(self, field)]
+            if field in self._values and field != 'id':
+                if definition['type'] == 'one2many':
+                    values[field] = [x._get_on_change_value()
+                        for x in getattr(self, field)]
+                else:
+                    values[field] = getattr(self, '__%s_eval' % field)
         return values
 
     def _on_change_args(self, args):
@@ -773,10 +791,11 @@ class Model(object):
             scope = values
             for i in arg.split('.'):
                 if i not in scope:
-                    scope = False
                     break
                 scope = scope[i]
-            res[arg] = scope
+            else:
+                res[arg] = scope
+        res['id'] = self.id
         return res
 
     def _on_change_set(self, field, value):
@@ -792,7 +811,7 @@ class Model(object):
                 # remove without signal
                 list.remove(getattr(self, field), record)
             if value and value.get('add') or value.get('update'):
-                for vals in value.get('add', []):
+                for index, vals in value.get('add', []):
                     relation = Model.get(self._fields[field]['relation'],
                             self._config)
                     record = relation(_default=False)
@@ -802,7 +821,10 @@ class Model(object):
                         record._values[i] = j
                         record._changed.add(i)
                     # append without signal
-                    list.append(getattr(self, field), record)
+                    if index == -1:
+                        list.append(getattr(self, field), record)
+                    else:
+                        list.insert(getattr(self, field), index, record)
                 for vals in value.get('update', []):
                     if 'id' not in vals:
                         continue
@@ -874,7 +896,8 @@ class Model(object):
 class Wizard(object):
     'Wizard class for Tryton wizards'
 
-    def __init__(self, name, models=None, config=None, context=None):
+    def __init__(self, name, models=None, action=None, config=None,
+            context=None):
         if models:
             assert len(set(type(x) for x in models)) == 1
         super(Wizard, self).__init__()
@@ -888,6 +911,7 @@ class Wizard(object):
         self.session_id, self.start_state, self.end_state = result
         self.states = [self.start_state]
         self.models = models
+        self.action = action
         self.execute(self.start_state)
 
     def execute(self, state):
@@ -905,6 +929,10 @@ class Wizard(object):
                 ctx['active_id'] = None
                 ctx['active_ids'] = None
                 ctx['active_model'] = None
+            if self.action:
+                ctx['action_id'] = self.action.id
+            else:
+                ctx['action_id'] = None
 
             if self.form:
                 # Filter only modified values
diff --git a/proteus/config.py b/proteus/config.py
index 39a3148..ebef61d 100644
--- a/proteus/config.py
+++ b/proteus/config.py
@@ -40,6 +40,7 @@ def dump_time(self, value, write):
         'hour': value.hour,
         'minute': value.minute,
         'second': value.second,
+        'microsecond': value.microsecond,
         }
     self.dump_struct(value, write)
 
@@ -60,7 +61,8 @@ def end_struct(self, data):
         if dct['__class__'] == 'date':
             dct = datetime.date(dct['year'], dct['month'], dct['day'])
         elif dct['__class__'] == 'time':
-            dct = datetime.time(dct['hour'], dct['minute'], dct['second'])
+            dct = datetime.time(dct['hour'], dct['minute'], dct['second'],
+                dct['microsecond'])
         elif dct['__class__'] == 'Decimal':
             dct = Decimal(dct['decimal'])
     self._stack[mark:] = [dct]
@@ -178,7 +180,6 @@ class TrytondConfig(Config):
         super(TrytondConfig, self).__init__()
         from trytond.config import CONFIG
         CONFIG.update_etc(config_file)
-        CONFIG.set_timezone()
         if database_type is not None:
             CONFIG['db_type'] = database_type
         from trytond.pool import Pool
@@ -283,6 +284,7 @@ class XmlrpcConfig(Config):
         self.url = url
         self.server = xmlrpclib.ServerProxy(url, allow_none=1, use_datetime=1)
         # TODO add user
+        self.user = None
         self._context = self.server.model.res.user.get_preferences(True, {})
     __init__.__doc__ = object.__init__.__doc__
 
diff --git a/proteus/tests/test_model.py b/proteus/tests/test_model.py
index f4b90d7..0a87cfc 100644
--- a/proteus/tests/test_model.py
+++ b/proteus/tests/test_model.py
@@ -311,9 +311,9 @@ class TestModel(TestCase):
         test._on_change_set('groups', {'remove': [group_ids[0]]})
         self.assertEqual([x.id for x in test.groups], group_ids[1:])
 
-        test._on_change_set('groups', {'add': [{
-            'name': 'Bar',
-            }]})
+        test._on_change_set('groups', {'add': [(-1, {
+                            'name': 'Bar',
+                            })]})
         self.assert_([x for x in test.groups if x.name == 'Bar'])
 
         test.groups.extend(Group.find())
diff --git a/setup.py b/setup.py
index b63c3bb..4f6c48c 100644
--- a/setup.py
+++ b/setup.py
@@ -5,22 +5,43 @@ from setuptools import setup, find_packages
 import os
 import proteus
 
-major_version, minor_version, _ = proteus.__version__.split('.', 2)
+
+def read(fname):
+    return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+
+def get_require_version(name):
+    if minor_version % 2:
+        require = '%s >= %s.%s.dev0, < %s.%s'
+    else:
+        require = '%s >= %s.%s, < %s.%s'
+    require %= (name, major_version, minor_version,
+        major_version, minor_version + 1)
+    return require
+
+name = 'proteus'
+version = proteus.__version__
+major_version, minor_version, _ = version.split('.', 2)
 major_version = int(major_version)
 minor_version = int(minor_version)
 
+download_url = 'http://downloads.tryton.org/%s.%s/' % (
+    major_version, minor_version)
+if minor_version % 2:
+    version = '%s.%s.dev0' % (major_version, minor_version)
+    download_url = 'hg+http://hg.tryton.org/%s#egg=%s-%s' % (
+        name, name, version)
 
-def read(fname):
-    return open(os.path.join(os.path.dirname(__file__), fname)).read()
 
-setup(name='proteus',
-    version=proteus.__version__,
+setup(name=name,
+    version=version,
     description='Library to access Tryton server as a client',
     long_description=read('README'),
     author='Tryton',
+    author_email='issue_tracker at tryton.org',
     url='http://www.tryton.org/',
-    download_url=("http://downloads.tryton.org/" +
-        proteus.__version__.rsplit('.', 1)[0] + '/'),
+    download_url=download_url,
+    keywords='tryton library cli',
     packages=find_packages(),
     classifiers=[
         'Development Status :: 5 - Production/Stable',
@@ -32,21 +53,20 @@ setup(name='proteus',
         'License :: OSI Approved :: '
         'GNU Library or Lesser General Public License (LGPL)',
         'Operating System :: OS Independent',
-        'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Topic :: Office/Business',
         ],
+    platforms='any',
     license='LGPL-3',
     install_requires=[
         "python-dateutil",
         ],
     extras_require={
-        'trytond': ['trytond >= %s.%s, < %s.%s' %
-            (major_version, minor_version, major_version, minor_version + 1)],
+        'trytond': [get_require_version('trytond')],
         'simplejson': ['simplejson'],
         'cdecimal': ['cdecimal'],
         },
+    zip_safe=True,
     test_suite='proteus.tests',
-    tests_require=('trytond >= %s.%s, < %s.%s' %
-        (major_version, minor_version, major_version, minor_version + 1))
+    tests_require=[get_require_version('trytond')],
     )
-- 
tryton-proteus



More information about the tryton-debian-vcs mailing list