[tryton-commits] changeset in trytond-gis:6.0 Set postgresql scheme to postgis DSN

2021-05-06 Thread Cédric Krier
changeset 669333b31d21 in trytond-gis:6.0
details: https://hg.tryton.org/trytond-gis?cmd=changeset=669333b31d21
description:
Set postgresql scheme to postgis DSN
(grafted from c83498eeebae115b38fce215501c49acd0d716f3)
diffstat:

 trytond_gis/postgis/database.py |  8 
 1 files changed, 8 insertions(+), 0 deletions(-)

diffs (25 lines):

diff -r bc5711db0883 -r 669333b31d21 trytond_gis/postgis/database.py
--- a/trytond_gis/postgis/database.py   Mon May 03 15:34:01 2021 +0200
+++ b/trytond_gis/postgis/database.py   Wed May 05 17:42:37 2021 +0200
@@ -7,6 +7,7 @@
 Binary)
 
 from trytond.backend.postgresql.database import Database as PGDatabase
+from trytond.config import parse_uri
 
 from trytond_gis import _GeoJSON
 
@@ -30,6 +31,13 @@
 cursor = db_connection.cursor()
 cursor.execute("CREATE EXTENSION postgis")
 
+@classmethod
+def _connection_params(cls, name):
+params = super()._connection_params(name)
+uri = parse_uri(params['dsn'])
+params['dsn'] = uri._replace(scheme='postgresql').geturl()
+return params
+
 def get_connection(self, autocommit=False, readonly=False):
 conn = super(Database, self).get_connection(autocommit, readonly)
 



[tryton-commits] changeset in trytond:5.0 Remove _request key from cache's context

2021-05-06 Thread Cédric Krier
changeset 4a127308095a in trytond:5.0
details: https://hg.tryton.org/trytond?cmd=changeset=4a127308095a
description:
Remove _request key from cache's context

issue10376
review351901002
(grafted from 32c2df0914f6702aa98adb0a6acbd744d93ec057)
diffstat:

 trytond/cache.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r bfcc5566fb1e -r 4a127308095a trytond/cache.py
--- a/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:14:54 2021 +0200
@@ -37,6 +37,7 @@
 if self.context:
 context = Transaction().context.copy()
 context.pop('client', None)
+context.pop('_request', None)
 return (key, Transaction().user, freeze(context))
 return key
 



[tryton-commits] changeset in trytond:5.6 Remove _request key from cache's context

2021-05-06 Thread Cédric Krier
changeset b8389dcee265 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=b8389dcee265
description:
Remove _request key from cache's context

issue10376
review351901002
(grafted from 32c2df0914f6702aa98adb0a6acbd744d93ec057)
diffstat:

 trytond/cache.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r d20478d9522f -r b8389dcee265 trytond/cache.py
--- a/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:14:54 2021 +0200
@@ -65,6 +65,7 @@
 if self.context:
 context = Transaction().context.copy()
 context.pop('client', None)
+context.pop('_request', None)
 return (key, Transaction().user, freeze(context))
 return key
 



[tryton-commits] changeset in trytond:5.8 Remove _request key from cache's context

2021-05-06 Thread Cédric Krier
changeset cd9445c730e1 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=cd9445c730e1
description:
Remove _request key from cache's context

issue10376
review351901002
(grafted from 32c2df0914f6702aa98adb0a6acbd744d93ec057)
diffstat:

 trytond/cache.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r b009b7d587f5 -r cd9445c730e1 trytond/cache.py
--- a/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:14:54 2021 +0200
@@ -65,6 +65,7 @@
 if self.context:
 context = Transaction().context.copy()
 context.pop('client', None)
+context.pop('_request', None)
 return (key, Transaction().user, freeze(context))
 return key
 



[tryton-commits] changeset in trytond:6.0 Remove _request key from cache's context

2021-05-06 Thread Cédric Krier
changeset e5f067522f25 in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=e5f067522f25
description:
Remove _request key from cache's context

issue10376
review351901002
(grafted from 32c2df0914f6702aa98adb0a6acbd744d93ec057)
diffstat:

 trytond/cache.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r 6ee56344a23f -r e5f067522f25 trytond/cache.py
--- a/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:14:54 2021 +0200
@@ -85,6 +85,7 @@
 if self.context:
 context = Transaction().context.copy()
 context.pop('client', None)
+context.pop('_request', None)
 return (key, Transaction().user, freeze(context))
 return key
 



[tryton-commits] changeset in trytond:5.0 Pop cache keys from a copy of the context

2021-05-06 Thread Cédric Krier
changeset bfcc5566fb1e in trytond:5.0
details: https://hg.tryton.org/trytond?cmd=changeset=bfcc5566fb1e
description:
Pop cache keys from a copy of the context

Otherwise it modifies the context for the all transaction.

issue10380
review358061003
(grafted from b0a5d11ac400a8d1381e2950d3362ac3c287b4a0)
diffstat:

 trytond/cache.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r aa90c3015889 -r bfcc5566fb1e trytond/cache.py
--- a/trytond/cache.py  Sun Apr 25 17:56:39 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
@@ -35,7 +35,7 @@
 
 def _key(self, key):
 if self.context:
-context = Transaction().context
+context = Transaction().context.copy()
 context.pop('client', None)
 return (key, Transaction().user, freeze(context))
 return key



[tryton-commits] changeset in trytond:5.6 Pop cache keys from a copy of the context

2021-05-06 Thread Cédric Krier
changeset d20478d9522f in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=d20478d9522f
description:
Pop cache keys from a copy of the context

Otherwise it modifies the context for the all transaction.

issue10380
review358061003
(grafted from b0a5d11ac400a8d1381e2950d3362ac3c287b4a0)
diffstat:

 trytond/cache.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 6e2270bccda8 -r d20478d9522f trytond/cache.py
--- a/trytond/cache.py  Tue Apr 27 10:38:24 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
@@ -63,7 +63,7 @@
 
 def _key(self, key):
 if self.context:
-context = Transaction().context
+context = Transaction().context.copy()
 context.pop('client', None)
 return (key, Transaction().user, freeze(context))
 return key



[tryton-commits] changeset in trytond:5.8 Pop cache keys from a copy of the context

2021-05-06 Thread Cédric Krier
changeset b009b7d587f5 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=b009b7d587f5
description:
Pop cache keys from a copy of the context

Otherwise it modifies the context for the all transaction.

issue10380
review358061003
(grafted from b0a5d11ac400a8d1381e2950d3362ac3c287b4a0)
diffstat:

 trytond/cache.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 6ea03f6feba7 -r b009b7d587f5 trytond/cache.py
--- a/trytond/cache.py  Tue Apr 27 10:38:24 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
@@ -63,7 +63,7 @@
 
 def _key(self, key):
 if self.context:
-context = Transaction().context
+context = Transaction().context.copy()
 context.pop('client', None)
 return (key, Transaction().user, freeze(context))
 return key



[tryton-commits] changeset in trytond:6.0 Pop cache keys from a copy of the context

2021-05-06 Thread Cédric Krier
changeset 6ee56344a23f in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=6ee56344a23f
description:
Pop cache keys from a copy of the context

Otherwise it modifies the context for the all transaction.

issue10380
review358061003
(grafted from b0a5d11ac400a8d1381e2950d3362ac3c287b4a0)
diffstat:

 trytond/cache.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 321488026eba -r 6ee56344a23f trytond/cache.py
--- a/trytond/cache.py  Wed May 05 23:10:30 2021 +0200
+++ b/trytond/cache.py  Wed May 05 23:12:49 2021 +0200
@@ -83,7 +83,7 @@
 
 def _key(self, key):
 if self.context:
-context = Transaction().context
+context = Transaction().context.copy()
 context.pop('client', None)
 return (key, Transaction().user, freeze(context))
 return key



[tryton-commits] changeset in trytond:6.0 Do not test empty res_model against Mod...

2021-05-06 Thread Cédric Krier
changeset 321488026eba in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=321488026eba
description:
Do not test empty res_model against ModelSingleton

res_model is not required so it can be empty.

issue10387
review348321002
(grafted from 8ba2630e8589de543bfebf4c3077347e6f41951e)
diffstat:

 trytond/ir/action.py |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r 651cf66e25ae -r 321488026eba trytond/ir/action.py
--- a/trytond/ir/action.py  Wed May 05 18:09:08 2021 +0200
+++ b/trytond/ir/action.py  Wed May 05 23:10:30 2021 +0200
@@ -129,7 +129,9 @@
 actions = Action.read(action_ids, columns)
 if type_ == 'ir.action.act_window':
 for values in actions:
-if issubclass(pool.get(values['res_model']), ModelSingleton):
+if (values['res_model']
+and issubclass(
+pool.get(values['res_model']), ModelSingleton)):
 values['res_id'] = 1
 return actions
 



[tryton-commits] changeset in trytond:6.0 Skip avatar test if PIL is not installed

2021-05-06 Thread Cédric Krier
changeset 651cf66e25ae in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=651cf66e25ae
description:
Skip avatar test if PIL is not installed
(grafted from 4d216b768a9c802ddd8c285c278dc9c2df50112c)
diffstat:

 trytond/tests/test_res.py |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (23 lines):

diff -r 31bfe25903c2 -r 651cf66e25ae trytond/tests/test_res.py
--- a/trytond/tests/test_res.py Wed May 05 12:03:41 2021 +0200
+++ b/trytond/tests/test_res.py Wed May 05 18:09:08 2021 +0200
@@ -2,6 +2,11 @@
 # this repository contains the full copyright notices and license terms.
 import unittest
 
+try:
+import PIL
+except ImportError:
+PIL = None
+
 from trytond.pool import Pool
 
 from .test_tryton import ModuleTestCase, with_transaction
@@ -11,6 +16,7 @@
 'Test res module'
 module = 'res'
 
+@unittest.skipUnless(PIL, "Avatars are not generated without PIL")
 @with_transaction()
 def test_user_avatar(self):
 pool = Pool()



[tryton-commits] changeset in trytond:6.0 Ignore pool refresh if _modules is None

2021-05-06 Thread Cédric Krier
changeset 31bfe25903c2 in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=31bfe25903c2
description:
Ignore pool refresh if _modules is None

issue10383
review332831002
(grafted from 0e4019dbbf2cf4e2827ede3127ed1d97dcb717b7)
diffstat:

 trytond/pool.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 26c540594fd6 -r 31bfe25903c2 trytond/pool.py
--- a/trytond/pool.py   Mon May 03 15:32:17 2021 +0200
+++ b/trytond/pool.py   Wed May 05 12:03:41 2021 +0200
@@ -272,7 +272,7 @@
 self.add(cls, type=type_)
 
 def refresh(self, modules):
-if set(self._modules) != modules:
+if self._modules is not None and set(self._modules) != modules:
 self.stop(self.database_name)
 
 



[tryton-commits] changeset in trytond:5.6 Skip lazy string translation when model...

2021-05-06 Thread Cédric Krier
changeset 6e2270bccda8 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=6e2270bccda8
description:
Skip lazy string translation when model is no more in the Pool

issue10351
(grafted from 5ba16bdb2a1c8acb8d21ffa0799e270d25af6bab)
diffstat:

 trytond/ir/translation.py |  12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 2d28681653c5 -r 6e2270bccda8 trytond/ir/translation.py
--- a/trytond/ir/translation.py Sun Apr 25 18:19:29 2021 +0200
+++ b/trytond/ir/translation.py Tue Apr 27 10:38:24 2021 +0200
@@ -330,15 +330,21 @@
 if translations[record.id] is None:
 with Transaction().set_context(language=lang):
 if ttype in {'field', 'help'}:
-field = getattr(
-pool.get(record.model.model), record.name)
+try:
+field = getattr(
+pool.get(record.model.model), record.name)
+except KeyError:
+continue
 translations[record.id] = ''
 if ttype == 'field':
 value = field.string
 else:
 value = field.help
 else:
-model = pool.get(record.model)
+try:
+model = pool.get(record.model)
+except KeyError:
+continue
 if not model.__doc__:
 continue
 value = model._get_name()



[tryton-commits] changeset in trytond:5.8 Skip lazy string translation when model...

2021-05-06 Thread Cédric Krier
changeset 6ea03f6feba7 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=6ea03f6feba7
description:
Skip lazy string translation when model is no more in the Pool

issue10351
(grafted from 5ba16bdb2a1c8acb8d21ffa0799e270d25af6bab)
diffstat:

 trytond/ir/translation.py |  12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 1c059b969f86 -r 6ea03f6feba7 trytond/ir/translation.py
--- a/trytond/ir/translation.py Sun Apr 25 18:19:29 2021 +0200
+++ b/trytond/ir/translation.py Tue Apr 27 10:38:24 2021 +0200
@@ -324,15 +324,21 @@
 if translations[record.id] is None:
 with Transaction().set_context(language=lang):
 if ttype in {'field', 'help'}:
-field = getattr(
-pool.get(record.model.model), record.name)
+try:
+field = getattr(
+pool.get(record.model.model), record.name)
+except KeyError:
+continue
 translations[record.id] = ''
 if ttype == 'field':
 value = field.string
 else:
 value = field.help
 else:
-model = pool.get(record.model)
+try:
+model = pool.get(record.model)
+except KeyError:
+continue
 if not model.__doc__:
 continue
 value = model._get_name()



[tryton-commits] changeset in trytond:5.6 Translate LazyString of ir.model and ir...

2021-05-06 Thread Cédric Krier
changeset 2d28681653c5 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=2d28681653c5
description:
Translate LazyString of ir.model and ir.model.field

issue10326
review321041002
(grafted from ecbcef79165c036261789c1caf0c10edf2efea6b)
diffstat:

 trytond/ir/translation.py |  22 -
 trytond/model/fields/field.py |  45 +++
 trytond/tests/test_ir.py  |  13 
 3 files changed, 79 insertions(+), 1 deletions(-)

diffs (117 lines):

diff -r 506360117958 -r 2d28681653c5 trytond/ir/translation.py
--- a/trytond/ir/translation.py Sun Apr 25 17:56:39 2021 +0200
+++ b/trytond/ir/translation.py Sun Apr 25 18:19:29 2021 +0200
@@ -19,7 +19,7 @@
 
 from trytond.exceptions import UserError
 from trytond.i18n import gettext
-from trytond.tools.string_ import LazyString
+from trytond.tools.string_ import LazyString, StringPartitioned
 from ..model import ModelView, ModelSQL, fields
 from ..wizard import Wizard, StateView, StateTransition, StateAction, \
 Button
@@ -327,6 +327,26 @@
 else:
 name = record.model + ',' + field_name
 translations[record.id] = cls.get_source(name, ttype, lang)
+if translations[record.id] is None:
+with Transaction().set_context(language=lang):
+if ttype in {'field', 'help'}:
+field = getattr(
+pool.get(record.model.model), record.name)
+translations[record.id] = ''
+if ttype == 'field':
+value = field.string
+else:
+value = field.help
+else:
+model = pool.get(record.model)
+if not model.__doc__:
+continue
+value = model._get_name()
+if isinstance(value, StringPartitioned):
+for source in value:
+translations[record.id] += source
+else:
+translations[record.id] = value
 return translations
 
 # Don't use cache for fuzzy translation
diff -r 506360117958 -r 2d28681653c5 trytond/model/fields/field.py
--- a/trytond/model/fields/field.py Sun Apr 25 17:56:39 2021 +0200
+++ b/trytond/model/fields/field.py Sun Apr 25 18:19:29 2021 +0200
@@ -496,6 +496,51 @@
 
 def _get_translation_join(self, Model, name,
 translation, model, table, from_, language):
+if Model.__name__ == 'ir.model.field':
+pool = Pool()
+IrModel = pool.get('ir.model')
+ModelData = pool.get('ir.model.data')
+ModelField = pool.get('ir.model.field')
+Translation = pool.get('ir.translation')
+model = IrModel.__table__()
+model_data = ModelData.__table__()
+model_field = ModelField.__table__()
+msg_trans = Translation.__table__()
+if name == 'field_description':
+type_ = 'field'
+else:
+type_ = 'help'
+translation = translation.select(
+translation.id.as_('id'),
+translation.res_id.as_('res_id'),
+translation.value.as_('value'),
+translation.name.as_('name'),
+translation.lang.as_('lang'),
+translation.type.as_('type'),
+translation.fuzzy.as_('fuzzy'),
+)
+translation |= (msg_trans
+.join(model_data,
+condition=(msg_trans.res_id == model_data.db_id)
+& (model_data.model == 'ir.message')
+& (msg_trans.name == 'ir.message,text'))
+.join(model_field,
+condition=Concat(
+Concat(model_data.module, '.'),
+model_data.fs_id) == getattr(model_field, name))
+.join(model,
+condition=model_field.model == model.id)
+.select(
+msg_trans.id.as_('id'),
+Literal(-1).as_('res_id'),
+msg_trans.value.as_('value'),
+Concat(
+Concat(model.model, ','),
+model_field.name).as_('name'),
+msg_trans.lang.as_('lang'),
+Literal(type_).as_('type'),
+msg_trans.fuzzy.as_('fuzzy'),
+))
 if backend.name == 'postgresql' and _sql_version >= (1, 1, 0):
 query = translation.select(
 translation.res_id.as_('res_id'),
diff -r 506360117958 -r 2d28681653c5 

[tryton-commits] changeset in trytond:5.8 Translate LazyString of ir.model and ir...

2021-05-06 Thread Cédric Krier
changeset 1c059b969f86 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=1c059b969f86
description:
Translate LazyString of ir.model and ir.model.field

issue10326
review321041002
(grafted from ecbcef79165c036261789c1caf0c10edf2efea6b)
diffstat:

 trytond/ir/translation.py |  22 -
 trytond/model/fields/field.py |  45 +++
 trytond/tests/test_ir.py  |  13 
 3 files changed, 79 insertions(+), 1 deletions(-)

diffs (117 lines):

diff -r 958845538e81 -r 1c059b969f86 trytond/ir/translation.py
--- a/trytond/ir/translation.py Sun Apr 25 17:56:39 2021 +0200
+++ b/trytond/ir/translation.py Sun Apr 25 18:19:29 2021 +0200
@@ -25,7 +25,7 @@
 from trytond.pool import Pool
 from trytond.pyson import PYSONEncoder, Eval
 from trytond.tools import file_open, grouped_slice, cursor_dict
-from trytond.tools.string_ import LazyString
+from trytond.tools.string_ import LazyString, StringPartitioned
 from trytond.transaction import Transaction
 from trytond.wizard import (
 Wizard, StateView, StateTransition, StateAction, Button)
@@ -321,6 +321,26 @@
 else:
 name = record.model + ',' + field_name
 translations[record.id] = cls.get_source(name, ttype, lang)
+if translations[record.id] is None:
+with Transaction().set_context(language=lang):
+if ttype in {'field', 'help'}:
+field = getattr(
+pool.get(record.model.model), record.name)
+translations[record.id] = ''
+if ttype == 'field':
+value = field.string
+else:
+value = field.help
+else:
+model = pool.get(record.model)
+if not model.__doc__:
+continue
+value = model._get_name()
+if isinstance(value, StringPartitioned):
+for source in value:
+translations[record.id] += source
+else:
+translations[record.id] = value
 return translations
 
 # Don't use cache for fuzzy translation
diff -r 958845538e81 -r 1c059b969f86 trytond/model/fields/field.py
--- a/trytond/model/fields/field.py Sun Apr 25 17:56:39 2021 +0200
+++ b/trytond/model/fields/field.py Sun Apr 25 18:19:29 2021 +0200
@@ -496,6 +496,51 @@
 
 def _get_translation_join(self, Model, name,
 translation, model, table, from_, language):
+if Model.__name__ == 'ir.model.field':
+pool = Pool()
+IrModel = pool.get('ir.model')
+ModelData = pool.get('ir.model.data')
+ModelField = pool.get('ir.model.field')
+Translation = pool.get('ir.translation')
+model = IrModel.__table__()
+model_data = ModelData.__table__()
+model_field = ModelField.__table__()
+msg_trans = Translation.__table__()
+if name == 'field_description':
+type_ = 'field'
+else:
+type_ = 'help'
+translation = translation.select(
+translation.id.as_('id'),
+translation.res_id.as_('res_id'),
+translation.value.as_('value'),
+translation.name.as_('name'),
+translation.lang.as_('lang'),
+translation.type.as_('type'),
+translation.fuzzy.as_('fuzzy'),
+)
+translation |= (msg_trans
+.join(model_data,
+condition=(msg_trans.res_id == model_data.db_id)
+& (model_data.model == 'ir.message')
+& (msg_trans.name == 'ir.message,text'))
+.join(model_field,
+condition=Concat(
+Concat(model_data.module, '.'),
+model_data.fs_id) == getattr(model_field, name))
+.join(model,
+condition=model_field.model == model.id)
+.select(
+msg_trans.id.as_('id'),
+Literal(-1).as_('res_id'),
+msg_trans.value.as_('value'),
+Concat(
+Concat(model.model, ','),
+model_field.name).as_('name'),
+msg_trans.lang.as_('lang'),
+Literal(type_).as_('type'),
+msg_trans.fuzzy.as_('fuzzy'),
+))
 if backend.name == 'postgresql' and _sql_version >= (1, 1, 0):
 query = translation.select(
 

[tryton-commits] changeset in trytond:5.0 Include records without link with negat...

2021-05-06 Thread Cédric Krier
changeset aa90c3015889 in trytond:5.0
details: https://hg.tryton.org/trytond?cmd=changeset=aa90c3015889
description:
Include records without link with negative search on xxx2many

issue10178
review345981002
(grafted from c14f51b77b304a17ac9c58eb2157f86a704851cd)
diffstat:

 trytond/model/fields/many2many.py |   5 -
 trytond/model/fields/one2many.py  |   2 ++
 trytond/tests/test_field_many2many.py |  30 ++
 trytond/tests/test_field_one2many.py  |  30 ++
 4 files changed, 66 insertions(+), 1 deletions(-)

diffs (116 lines):

diff -r 70589238b98f -r aa90c3015889 trytond/model/fields/many2many.py
--- a/trytond/model/fields/many2many.py Fri Apr 02 21:53:44 2021 +0200
+++ b/trytond/model/fields/many2many.py Sun Apr 25 17:56:39 2021 +0200
@@ -436,4 +436,7 @@
 relation_domain, tables=relation_tables)
 query_table = convert_from(None, relation_tables)
 query = query_table.select(origin, where=expression)
-return table.id.in_(query)
+expression = table.id.in_(query)
+if operator.startswith('!') or operator.startswith('not '):
+expression |= ~table.id.in_(relation.select(origin))
+return expression
diff -r 70589238b98f -r aa90c3015889 trytond/model/fields/one2many.py
--- a/trytond/model/fields/one2many.py  Fri Apr 02 21:53:44 2021 +0200
+++ b/trytond/model/fields/one2many.py  Sun Apr 25 17:56:39 2021 +0200
@@ -326,4 +326,6 @@
 
 if operator == 'not where':
 expression = ~expression
+elif operator.startswith('!') or operator.startswith('not '):
+expression |= ~table.id.in_(target.select(origin))
 return expression
diff -r 70589238b98f -r aa90c3015889 trytond/tests/test_field_many2many.py
--- a/trytond/tests/test_field_many2many.py Fri Apr 02 21:53:44 2021 +0200
+++ b/trytond/tests/test_field_many2many.py Sun Apr 25 17:56:39 2021 +0200
@@ -39,6 +39,21 @@
 self.assertListEqual(many2manys, [many2many])
 
 @with_transaction()
+def test_search_equals_no_link(self):
+"Test search many2many equals without link"
+Many2Many = self.Many2Many()
+many2many, no_link = Many2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+many2manys = Many2Many.search([
+('targets', '=', "Target"),
+])
+
+self.assertListEqual(many2manys, [many2many])
+
+@with_transaction()
 def test_search_non_equals(self):
 "Test search many2many non equals"
 Many2Many = self.Many2Many()
@@ -85,6 +100,21 @@
 self.assertListEqual(many2manys, [many2many1])
 
 @with_transaction()
+def test_search_non_equals_no_link(self):
+"Test search many2many non equals without link"
+Many2Many = self.Many2Many()
+many2many, no_link = Many2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+many2manys = Many2Many.search([
+('targets', '!=', "Target"),
+])
+
+self.assertListEqual(many2manys, [no_link])
+
+@with_transaction()
 def test_search_in(self):
 "Test search many2many in"
 Many2Many = self.Many2Many()
diff -r 70589238b98f -r aa90c3015889 trytond/tests/test_field_one2many.py
--- a/trytond/tests/test_field_one2many.py  Fri Apr 02 21:53:44 2021 +0200
+++ b/trytond/tests/test_field_one2many.py  Sun Apr 25 17:56:39 2021 +0200
@@ -39,6 +39,21 @@
 self.assertListEqual(one2manys, [one2many])
 
 @with_transaction()
+def test_search_equals_no_link(self):
+"Test search one2many equals without link"
+One2Many = self.One2Many()
+one2many, no_link = One2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+one2manys = One2Many.search([
+('targets', '=', "Target"),
+])
+
+self.assertListEqual(one2manys, [one2many])
+
+@with_transaction()
 def test_search_non_equals(self):
 "Test search one2many non equals"
 One2Many = self.One2Many()
@@ -85,6 +100,21 @@
 self.assertListEqual(one2manys, [one2many1])
 
 @with_transaction()
+def test_search_non_equals_no_link(self):
+"Test search one2many non equals without link"
+One2Many = self.One2Many()
+one2many, no_link = One2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+one2manys = One2Many.search([
+('targets', '!=', "Target"),
+])
+
+self.assertListEqual(one2manys, [no_link])
+
+@with_transaction()
 def test_search_in(self):
 "Test search 

[tryton-commits] changeset in trytond:5.6 Include records without link with negat...

2021-05-06 Thread Cédric Krier
changeset 506360117958 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=506360117958
description:
Include records without link with negative search on xxx2many

issue10178
review345981002
(grafted from c14f51b77b304a17ac9c58eb2157f86a704851cd)
diffstat:

 trytond/model/fields/many2many.py |   5 -
 trytond/model/fields/one2many.py  |   2 ++
 trytond/tests/test_field_many2many.py |  30 ++
 trytond/tests/test_field_one2many.py  |  30 ++
 4 files changed, 66 insertions(+), 1 deletions(-)

diffs (121 lines):

diff -r 57d3aec52a0e -r 506360117958 trytond/model/fields/many2many.py
--- a/trytond/model/fields/many2many.py Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/model/fields/many2many.py Sun Apr 25 17:56:39 2021 +0200
@@ -453,7 +453,10 @@
 relation_domain, tables=relation_tables)
 query_table = convert_from(None, relation_tables)
 query = query_table.select(origin, where=expression)
-return table.id.in_(query)
+expression = table.id.in_(query)
+if operator.startswith('!') or operator.startswith('not '):
+expression |= ~table.id.in_(relation.select(origin))
+return expression
 
 def definition(self, model, language):
 encoder = PYSONEncoder()
diff -r 57d3aec52a0e -r 506360117958 trytond/model/fields/one2many.py
--- a/trytond/model/fields/one2many.py  Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/model/fields/one2many.py  Sun Apr 25 17:56:39 2021 +0200
@@ -342,6 +342,8 @@
 
 if operator == 'not where':
 expression = ~expression
+elif operator.startswith('!') or operator.startswith('not '):
+expression |= ~table.id.in_(target.select(origin))
 return expression
 
 def definition(self, model, language):
diff -r 57d3aec52a0e -r 506360117958 trytond/tests/test_field_many2many.py
--- a/trytond/tests/test_field_many2many.py Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/tests/test_field_many2many.py Sun Apr 25 17:56:39 2021 +0200
@@ -40,6 +40,21 @@
 self.assertListEqual(many2manys, [many2many])
 
 @with_transaction()
+def test_search_equals_no_link(self):
+"Test search many2many equals without link"
+Many2Many = self.Many2Many()
+many2many, no_link = Many2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+many2manys = Many2Many.search([
+('targets', '=', "Target"),
+])
+
+self.assertListEqual(many2manys, [many2many])
+
+@with_transaction()
 def test_search_non_equals(self):
 "Test search many2many non equals"
 Many2Many = self.Many2Many()
@@ -86,6 +101,21 @@
 self.assertListEqual(many2manys, [many2many1])
 
 @with_transaction()
+def test_search_non_equals_no_link(self):
+"Test search many2many non equals without link"
+Many2Many = self.Many2Many()
+many2many, no_link = Many2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+many2manys = Many2Many.search([
+('targets', '!=', "Target"),
+])
+
+self.assertListEqual(many2manys, [no_link])
+
+@with_transaction()
 def test_search_in(self):
 "Test search many2many in"
 Many2Many = self.Many2Many()
diff -r 57d3aec52a0e -r 506360117958 trytond/tests/test_field_one2many.py
--- a/trytond/tests/test_field_one2many.py  Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/tests/test_field_one2many.py  Sun Apr 25 17:56:39 2021 +0200
@@ -102,6 +102,21 @@
 self.assertListEqual(one2manys, [one2many])
 
 @with_transaction()
+def test_search_equals_no_link(self):
+"Test search one2many equals without link"
+One2Many = self.One2Many()
+one2many, no_link = One2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+one2manys = One2Many.search([
+('targets', '=', "Target"),
+])
+
+self.assertListEqual(one2manys, [one2many])
+
+@with_transaction()
 def test_search_non_equals(self):
 "Test search one2many non equals"
 One2Many = self.One2Many()
@@ -148,6 +163,21 @@
 self.assertListEqual(one2manys, [one2many1])
 
 @with_transaction()
+def test_search_non_equals_no_link(self):
+"Test search one2many non equals without link"
+One2Many = self.One2Many()
+one2many, no_link = One2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+one2manys = One2Many.search([
+('targets', '!=', "Target"),
+])
+
+

[tryton-commits] changeset in trytond:5.6 Set name clause on join condition inste...

2021-05-06 Thread Cédric Krier
changeset 57d3aec52a0e in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=57d3aec52a0e
description:
Set name clause on join condition instead of subquery

The name is a column from a table that is not available in the subquery.

issue10257
review346001004
(grafted from 661c377d1869f9d63e0f997d2a40b26f6fd0e738)
diffstat:

 trytond/model/fields/field.py |  34 ---
 trytond/tests/test_ir.py  |  52 +++
 2 files changed, 72 insertions(+), 14 deletions(-)

diffs (124 lines):

diff -r 7fb2bfb52117 -r 57d3aec52a0e trytond/model/fields/field.py
--- a/trytond/model/fields/field.py Wed Apr 21 23:47:30 2021 +0200
+++ b/trytond/model/fields/field.py Sat Apr 24 19:27:07 2021 +0200
@@ -496,11 +496,30 @@
 
 def _get_translation_join(self, Model, name,
 translation, model, table, from_, language):
+if backend.name == 'postgresql' and _sql_version >= (1, 1, 0):
+query = translation.select(
+translation.res_id.as_('res_id'),
+translation.value.as_('value'),
+translation.name.as_('name'),
+distinct=True,
+distinct_on=[translation.res_id, translation.name],
+order_by=[
+translation.res_id,
+translation.name,
+translation.id.desc])
+else:
+query = translation.select(
+translation.res_id.as_('res_id'),
+Min(translation.value).as_('value'),
+translation.name.as_('name'),
+group_by=[translation.res_id, translation.name])
 if Model.__name__ == 'ir.model':
 name_ = Concat(Concat(table.model, ','), name)
 type_ = 'model'
 res_id = -1
 elif Model.__name__ == 'ir.model.field':
+from_ = from_.join(model, 'LEFT',
+condition=model.id == table.model)
 name_ = Concat(Concat(model.model, ','), table.name)
 if name == 'field_description':
 type_ = 'field'
@@ -511,26 +530,13 @@
 name_ = '%s,%s' % (Model.__name__, name)
 type_ = 'model'
 res_id = table.id
-if backend.name == 'postgresql' and _sql_version >= (1, 1, 0):
-query = translation.select(
-translation.res_id.as_('res_id'),
-translation.value.as_('value'),
-distinct=True,
-distinct_on=[translation.res_id],
-order_by=[translation.res_id, translation.id.desc])
-else:
-query = translation.select(
-translation.res_id.as_('res_id'),
-Min(translation.value).as_('value'),
-group_by=[translation.res_id])
 query.where = (
 (translation.lang == language)
 & (translation.type == type_)
-& (translation.name == name_)
 & (translation.fuzzy == Literal(False))
 )
 return query, from_.join(query, 'LEFT',
-condition=(query.res_id == res_id))
+condition=(query.res_id == res_id) & (query.name == name_))
 
 def convert_domain(self, domain, tables, Model):
 from trytond.ir.lang import get_parent_language
diff -r 7fb2bfb52117 -r 57d3aec52a0e trytond/tests/test_ir.py
--- a/trytond/tests/test_ir.py  Wed Apr 21 23:47:30 2021 +0200
+++ b/trytond/tests/test_ir.py  Sat Apr 24 19:27:07 2021 +0200
@@ -14,6 +14,58 @@
 module = 'ir'
 
 @with_transaction()
+def test_model_search_name(self):
+"Test searching on name of model"
+pool = Pool()
+Model = pool.get('ir.model')
+
+record, = Model.search([
+('name', '=', "Language"),
+('module', '=', 'ir'),
+])
+self.assertEqual(record.name, "Language")
+
+@with_transaction()
+def test_model_search_order(self):
+"Test searching and ordering on name of model"
+pool = Pool()
+Model = pool.get('ir.model')
+
+records = Model.search([
+('name', 'in', ["Language", "Module"]),
+('module', '=', 'ir'),
+],
+order=[('name', 'ASC')])
+self.assertEqual([r.name for r in records], ["Language", "Module"])
+
+@with_transaction()
+def test_model_field_search_description(self):
+"Test searching on description of model field"
+pool = Pool()
+ModelField = pool.get('ir.model.field')
+
+field, = ModelField.search([
+('field_description', '=', "Name"),
+('model.model', '=', 'ir.lang'),
+('module', '=', 'ir'),
+])
+self.assertEqual(field.field_description, "Name")
+
+@with_transaction()
+def test_model_field_search_order_description(self):
+

[tryton-commits] changeset in trytond:5.8 Include records without link with negat...

2021-05-06 Thread Cédric Krier
changeset 958845538e81 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=958845538e81
description:
Include records without link with negative search on xxx2many

issue10178
review345981002
(grafted from c14f51b77b304a17ac9c58eb2157f86a704851cd)
diffstat:

 trytond/model/fields/many2many.py |   5 -
 trytond/model/fields/one2many.py  |   2 ++
 trytond/tests/test_field_many2many.py |  30 ++
 trytond/tests/test_field_one2many.py  |  30 ++
 4 files changed, 66 insertions(+), 1 deletions(-)

diffs (121 lines):

diff -r 788d40376b27 -r 958845538e81 trytond/model/fields/many2many.py
--- a/trytond/model/fields/many2many.py Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/model/fields/many2many.py Sun Apr 25 17:56:39 2021 +0200
@@ -453,7 +453,10 @@
 relation_domain, tables=relation_tables)
 query_table = convert_from(None, relation_tables)
 query = query_table.select(origin, where=expression)
-return table.id.in_(query)
+expression = table.id.in_(query)
+if operator.startswith('!') or operator.startswith('not '):
+expression |= ~table.id.in_(relation.select(origin))
+return expression
 
 def definition(self, model, language):
 encoder = PYSONEncoder()
diff -r 788d40376b27 -r 958845538e81 trytond/model/fields/one2many.py
--- a/trytond/model/fields/one2many.py  Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/model/fields/one2many.py  Sun Apr 25 17:56:39 2021 +0200
@@ -354,6 +354,8 @@
 
 if operator == 'not where':
 expression = ~expression
+elif operator.startswith('!') or operator.startswith('not '):
+expression |= ~table.id.in_(target.select(origin))
 return expression
 
 def definition(self, model, language):
diff -r 788d40376b27 -r 958845538e81 trytond/tests/test_field_many2many.py
--- a/trytond/tests/test_field_many2many.py Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/tests/test_field_many2many.py Sun Apr 25 17:56:39 2021 +0200
@@ -40,6 +40,21 @@
 self.assertListEqual(many2manys, [many2many])
 
 @with_transaction()
+def test_search_equals_no_link(self):
+"Test search many2many equals without link"
+Many2Many = self.Many2Many()
+many2many, no_link = Many2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+many2manys = Many2Many.search([
+('targets', '=', "Target"),
+])
+
+self.assertListEqual(many2manys, [many2many])
+
+@with_transaction()
 def test_search_non_equals(self):
 "Test search many2many non equals"
 Many2Many = self.Many2Many()
@@ -86,6 +101,21 @@
 self.assertListEqual(many2manys, [many2many1])
 
 @with_transaction()
+def test_search_non_equals_no_link(self):
+"Test search many2many non equals without link"
+Many2Many = self.Many2Many()
+many2many, no_link = Many2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+many2manys = Many2Many.search([
+('targets', '!=', "Target"),
+])
+
+self.assertListEqual(many2manys, [no_link])
+
+@with_transaction()
 def test_search_in(self):
 "Test search many2many in"
 Many2Many = self.Many2Many()
diff -r 788d40376b27 -r 958845538e81 trytond/tests/test_field_one2many.py
--- a/trytond/tests/test_field_one2many.py  Sat Apr 24 19:27:07 2021 +0200
+++ b/trytond/tests/test_field_one2many.py  Sun Apr 25 17:56:39 2021 +0200
@@ -102,6 +102,21 @@
 self.assertListEqual(one2manys, [one2many])
 
 @with_transaction()
+def test_search_equals_no_link(self):
+"Test search one2many equals without link"
+One2Many = self.One2Many()
+one2many, no_link = One2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+one2manys = One2Many.search([
+('targets', '=', "Target"),
+])
+
+self.assertListEqual(one2manys, [one2many])
+
+@with_transaction()
 def test_search_non_equals(self):
 "Test search one2many non equals"
 One2Many = self.One2Many()
@@ -148,6 +163,21 @@
 self.assertListEqual(one2manys, [one2many1])
 
 @with_transaction()
+def test_search_non_equals_no_link(self):
+"Test search one2many non equals without link"
+One2Many = self.One2Many()
+one2many, no_link = One2Many.create([{
+'targets': [('create', [{'name': "Target"}])],
+}, {
+}])
+
+one2manys = One2Many.search([
+('targets', '!=', "Target"),
+])
+
+

[tryton-commits] changeset in trytond:5.8 Set name clause on join condition inste...

2021-05-06 Thread Cédric Krier
changeset 788d40376b27 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=788d40376b27
description:
Set name clause on join condition instead of subquery

The name is a column from a table that is not available in the subquery.

issue10257
review346001004
(grafted from 661c377d1869f9d63e0f997d2a40b26f6fd0e738)
diffstat:

 trytond/model/fields/field.py |  34 ---
 trytond/tests/test_ir.py  |  52 +++
 2 files changed, 72 insertions(+), 14 deletions(-)

diffs (124 lines):

diff -r 32f2b38cb7d0 -r 788d40376b27 trytond/model/fields/field.py
--- a/trytond/model/fields/field.py Wed Apr 21 23:47:30 2021 +0200
+++ b/trytond/model/fields/field.py Sat Apr 24 19:27:07 2021 +0200
@@ -496,11 +496,30 @@
 
 def _get_translation_join(self, Model, name,
 translation, model, table, from_, language):
+if backend.name == 'postgresql' and _sql_version >= (1, 1, 0):
+query = translation.select(
+translation.res_id.as_('res_id'),
+translation.value.as_('value'),
+translation.name.as_('name'),
+distinct=True,
+distinct_on=[translation.res_id, translation.name],
+order_by=[
+translation.res_id,
+translation.name,
+translation.id.desc])
+else:
+query = translation.select(
+translation.res_id.as_('res_id'),
+Min(translation.value).as_('value'),
+translation.name.as_('name'),
+group_by=[translation.res_id, translation.name])
 if Model.__name__ == 'ir.model':
 name_ = Concat(Concat(table.model, ','), name)
 type_ = 'model'
 res_id = -1
 elif Model.__name__ == 'ir.model.field':
+from_ = from_.join(model, 'LEFT',
+condition=model.id == table.model)
 name_ = Concat(Concat(model.model, ','), table.name)
 if name == 'field_description':
 type_ = 'field'
@@ -511,26 +530,13 @@
 name_ = '%s,%s' % (Model.__name__, name)
 type_ = 'model'
 res_id = table.id
-if backend.name == 'postgresql' and _sql_version >= (1, 1, 0):
-query = translation.select(
-translation.res_id.as_('res_id'),
-translation.value.as_('value'),
-distinct=True,
-distinct_on=[translation.res_id],
-order_by=[translation.res_id, translation.id.desc])
-else:
-query = translation.select(
-translation.res_id.as_('res_id'),
-Min(translation.value).as_('value'),
-group_by=[translation.res_id])
 query.where = (
 (translation.lang == language)
 & (translation.type == type_)
-& (translation.name == name_)
 & (translation.fuzzy == Literal(False))
 )
 return query, from_.join(query, 'LEFT',
-condition=(query.res_id == res_id))
+condition=(query.res_id == res_id) & (query.name == name_))
 
 def convert_domain(self, domain, tables, Model):
 from trytond.ir.lang import get_parent_language
diff -r 32f2b38cb7d0 -r 788d40376b27 trytond/tests/test_ir.py
--- a/trytond/tests/test_ir.py  Wed Apr 21 23:47:30 2021 +0200
+++ b/trytond/tests/test_ir.py  Sat Apr 24 19:27:07 2021 +0200
@@ -19,6 +19,58 @@
 module = 'ir'
 
 @with_transaction()
+def test_model_search_name(self):
+"Test searching on name of model"
+pool = Pool()
+Model = pool.get('ir.model')
+
+record, = Model.search([
+('name', '=', "Language"),
+('module', '=', 'ir'),
+])
+self.assertEqual(record.name, "Language")
+
+@with_transaction()
+def test_model_search_order(self):
+"Test searching and ordering on name of model"
+pool = Pool()
+Model = pool.get('ir.model')
+
+records = Model.search([
+('name', 'in', ["Language", "Module"]),
+('module', '=', 'ir'),
+],
+order=[('name', 'ASC')])
+self.assertEqual([r.name for r in records], ["Language", "Module"])
+
+@with_transaction()
+def test_model_field_search_description(self):
+"Test searching on description of model field"
+pool = Pool()
+ModelField = pool.get('ir.model.field')
+
+field, = ModelField.search([
+('field_description', '=', "Name"),
+('model.model', '=', 'ir.lang'),
+('module', '=', 'ir'),
+])
+self.assertEqual(field.field_description, "Name")
+
+@with_transaction()
+def test_model_field_search_order_description(self):
+

[tryton-commits] changeset in trytond:5.6 Use order definition of xxx2Many fields

2021-05-06 Thread Cédric Krier
changeset 7fb2bfb52117 in trytond:5.6
details: https://hg.tryton.org/trytond?cmd=changeset=7fb2bfb52117
description:
Use order definition of xxx2Many fields

When empty it must be the order of the target and it must not be 
encoded as it
can not be PYSON.

issue10297
review349721004
(grafted from 6df8df6c6c4d3fdfdf8b20d18ae3b2d01181ca4f)
diffstat:

 trytond/model/fields/many2many.py |  4 ++--
 trytond/model/fields/one2many.py  |  4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (27 lines):

diff -r 4205d80d5fa7 -r 7fb2bfb52117 trytond/model/fields/many2many.py
--- a/trytond/model/fields/many2many.py Wed May 05 22:41:35 2021 +0200
+++ b/trytond/model/fields/many2many.py Wed Apr 21 23:47:30 2021 +0200
@@ -468,8 +468,8 @@
 definition['search_context'] = encoder.encode(self.search_context)
 definition['search_order'] = encoder.encode(self.search_order)
 definition['sortable'] &= hasattr(model, 'order_' + self.name)
-definition['order'] = encoder.encode(
-getattr(model, '_order', None)
+definition['order'] = (
+getattr(self.get_target(), '_order', None)
 if self.order is None else self.order)
 if self.size is not None:
 definition['size'] = encoder.encode(self.size)
diff -r 4205d80d5fa7 -r 7fb2bfb52117 trytond/model/fields/one2many.py
--- a/trytond/model/fields/one2many.py  Wed May 05 22:41:35 2021 +0200
+++ b/trytond/model/fields/one2many.py  Wed Apr 21 23:47:30 2021 +0200
@@ -361,7 +361,7 @@
 if self.size is not None:
 definition['size'] = encoder.encode(self.size)
 definition['sortable'] &= hasattr(model, 'order_' + self.name)
-definition['order'] = encoder.encode(
-getattr(model, '_order', None)
+definition['order'] = (
+getattr(self.get_target(), '_order', None)
 if self.order is None else self.order)
 return definition



[tryton-commits] changeset in trytond:5.8 Use order definition of xxx2Many fields

2021-05-06 Thread Cédric Krier
changeset 32f2b38cb7d0 in trytond:5.8
details: https://hg.tryton.org/trytond?cmd=changeset=32f2b38cb7d0
description:
Use order definition of xxx2Many fields

When empty it must be the order of the target and it must not be 
encoded as it
can not be PYSON.

issue10297
review349721004
(grafted from 6df8df6c6c4d3fdfdf8b20d18ae3b2d01181ca4f)
diffstat:

 trytond/model/fields/many2many.py |  4 ++--
 trytond/model/fields/one2many.py  |  4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diffs (27 lines):

diff -r e52820878372 -r 32f2b38cb7d0 trytond/model/fields/many2many.py
--- a/trytond/model/fields/many2many.py Wed May 05 22:40:13 2021 +0200
+++ b/trytond/model/fields/many2many.py Wed Apr 21 23:47:30 2021 +0200
@@ -468,8 +468,8 @@
 definition['search_context'] = encoder.encode(self.search_context)
 definition['search_order'] = encoder.encode(self.search_order)
 definition['sortable'] &= hasattr(model, 'order_' + self.name)
-definition['order'] = encoder.encode(
-getattr(model, '_order', None)
+definition['order'] = (
+getattr(self.get_target(), '_order', None)
 if self.order is None else self.order)
 if self.size is not None:
 definition['size'] = encoder.encode(self.size)
diff -r e52820878372 -r 32f2b38cb7d0 trytond/model/fields/one2many.py
--- a/trytond/model/fields/one2many.py  Wed May 05 22:40:13 2021 +0200
+++ b/trytond/model/fields/one2many.py  Wed Apr 21 23:47:30 2021 +0200
@@ -373,7 +373,7 @@
 if self.size is not None:
 definition['size'] = encoder.encode(self.size)
 definition['sortable'] &= hasattr(model, 'order_' + self.name)
-definition['order'] = encoder.encode(
-getattr(model, '_order', None)
+definition['order'] = (
+getattr(self.get_target(), '_order', None)
 if self.order is None else self.order)
 return definition



[tryton-commits] changeset in tryton:5.0 Bundle GooCanvas 2.0 or 3.0

2021-05-06 Thread Cédric Krier
changeset e73e115a6dca in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=e73e115a6dca
description:
Bundle GooCanvas 2.0 or 3.0

issue10378
review348291002
(grafted from f81f804ef4f13cbc2c59b45fdec3e94d8da633e6)
diffstat:

 setup-freeze.py |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 080dbd67b0dd -r e73e115a6dca setup-freeze.py
--- a/setup-freeze.py   Sun May 02 11:04:35 2021 +0200
+++ b/setup-freeze.py   Wed May 05 23:09:25 2021 +0200
@@ -2,6 +2,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
+import glob
 import os
 import re
 import ssl
@@ -47,7 +48,7 @@
 'Gdk-3.0',
 'GdkPixbuf-2.0',
 'Gio-2.0',
-'GooCanvas-2.0',
+'GooCanvas-[2-3].0',
 'Gtk-3.0',
 'HarfBuzz-0.0',
 'Pango-1.0',
@@ -72,7 +73,10 @@
 temp = tempfile.mkdtemp()
 for ns in required_gi_namespaces:
 gir_name = '%s.gir' % ns
-gir_file = os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name)
+gir_file = glob.glob(
+os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name))[0]
+gir_name = os.path.basename(gir_file)
+ns = os.path.splitext(gir_name)[0]
 gir_tmp = os.path.join(temp, gir_name)
 with open(gir_file, 'r', encoding='utf-8') as src:
 with open(gir_tmp, 'w', encoding='utf-8') as dst:



[tryton-commits] changeset in tryton:5.6 Bundle GooCanvas 2.0 or 3.0

2021-05-06 Thread Cédric Krier
changeset 6274fc798adb in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=6274fc798adb
description:
Bundle GooCanvas 2.0 or 3.0

issue10378
review348291002
(grafted from f81f804ef4f13cbc2c59b45fdec3e94d8da633e6)
diffstat:

 setup-freeze.py |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 67a2342442c9 -r 6274fc798adb setup-freeze.py
--- a/setup-freeze.py   Sun May 02 11:04:35 2021 +0200
+++ b/setup-freeze.py   Wed May 05 23:09:25 2021 +0200
@@ -2,6 +2,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
+import glob
 import os
 import re
 import ssl
@@ -47,7 +48,7 @@
 'Gdk-3.0',
 'GdkPixbuf-2.0',
 'Gio-2.0',
-'GooCanvas-2.0',
+'GooCanvas-[2-3].0',
 'Gtk-3.0',
 'HarfBuzz-0.0',
 'Pango-1.0',
@@ -73,7 +74,10 @@
 temp = tempfile.mkdtemp()
 for ns in required_gi_namespaces:
 gir_name = '%s.gir' % ns
-gir_file = os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name)
+gir_file = glob.glob(
+os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name))[0]
+gir_name = os.path.basename(gir_file)
+ns = os.path.splitext(gir_name)[0]
 gir_tmp = os.path.join(temp, gir_name)
 with open(gir_file, 'r', encoding='utf-8') as src:
 with open(gir_tmp, 'w', encoding='utf-8') as dst:



[tryton-commits] changeset in tryton:5.8 Bundle GooCanvas 2.0 or 3.0

2021-05-06 Thread Cédric Krier
changeset da37aedd9c17 in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=da37aedd9c17
description:
Bundle GooCanvas 2.0 or 3.0

issue10378
review348291002
(grafted from f81f804ef4f13cbc2c59b45fdec3e94d8da633e6)
diffstat:

 setup-freeze.py |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 4c5b704cf6bc -r da37aedd9c17 setup-freeze.py
--- a/setup-freeze.py   Sun May 02 11:04:35 2021 +0200
+++ b/setup-freeze.py   Wed May 05 23:09:25 2021 +0200
@@ -2,6 +2,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
+import glob
 import os
 import re
 import ssl
@@ -47,7 +48,7 @@
 'Gdk-3.0',
 'GdkPixbuf-2.0',
 'Gio-2.0',
-'GooCanvas-2.0',
+'GooCanvas-[2-3].0',
 'Gtk-3.0',
 'HarfBuzz-0.0',
 'Pango-1.0',
@@ -73,7 +74,10 @@
 temp = tempfile.mkdtemp()
 for ns in required_gi_namespaces:
 gir_name = '%s.gir' % ns
-gir_file = os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name)
+gir_file = glob.glob(
+os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name))[0]
+gir_name = os.path.basename(gir_file)
+ns = os.path.splitext(gir_name)[0]
 gir_tmp = os.path.join(temp, gir_name)
 with open(gir_file, 'r', encoding='utf-8') as src:
 with open(gir_tmp, 'w', encoding='utf-8') as dst:



[tryton-commits] changeset in tryton:6.0 Bundle GooCanvas 2.0 or 3.0

2021-05-06 Thread Cédric Krier
changeset a3ce0cda198d in tryton:6.0
details: https://hg.tryton.org/tryton?cmd=changeset=a3ce0cda198d
description:
Bundle GooCanvas 2.0 or 3.0

issue10378
review348291002
(grafted from f81f804ef4f13cbc2c59b45fdec3e94d8da633e6)
diffstat:

 setup-freeze.py |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (32 lines):

diff -r 7ff889efa268 -r a3ce0cda198d setup-freeze.py
--- a/setup-freeze.py   Mon May 03 15:33:09 2021 +0200
+++ b/setup-freeze.py   Wed May 05 23:09:25 2021 +0200
@@ -2,6 +2,7 @@
 # This file is part of Tryton.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
 
+import glob
 import os
 import re
 import ssl
@@ -51,7 +52,7 @@
 'Gdk-3.0',
 'GdkPixbuf-2.0',
 'Gio-2.0',
-'GooCanvas-2.0',
+'GooCanvas-[2-3].0',
 'Gtk-3.0',
 'HarfBuzz-0.0',
 'Pango-1.0',
@@ -77,7 +78,10 @@
 temp = tempfile.mkdtemp()
 for ns in required_gi_namespaces:
 gir_name = '%s.gir' % ns
-gir_file = os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name)
+gir_file = glob.glob(
+os.path.join(sys.prefix, 'share', 'gir-1.0', gir_name))[0]
+gir_name = os.path.basename(gir_file)
+ns = os.path.splitext(gir_name)[0]
 gir_tmp = os.path.join(temp, gir_name)
 with open(gir_file, 'r', encoding='utf-8') as src:
 with open(gir_tmp, 'w', encoding='utf-8') as dst:



[tryton-commits] changeset in tryton:5.0 Ensure to exit after query canceled

2021-05-06 Thread Cédric Krier
changeset 080dbd67b0dd in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=080dbd67b0dd
description:
Ensure to exit after query canceled

issue10272
review365201003
(grafted from 1b45f5a4b823b434b35a4d9ff6817e680f066023)
diffstat:

 tryton/common/common.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r bba153625edc -r 080dbd67b0dd tryton/common/common.py
--- a/tryton/common/common.py   Sun May 02 10:59:12 2021 +0200
+++ b/tryton/common/common.py   Sun May 02 11:04:35 2021 +0200
@@ -978,6 +978,7 @@
 except TrytonError as exception:
 if exception.faultCode == 'QueryCanceled':
 Main().on_quit()
+sys.exit()
 raise
 finally:
 PLOCK.release()



[tryton-commits] changeset in tryton:5.6 Ensure to exit after query canceled

2021-05-06 Thread Cédric Krier
changeset 67a2342442c9 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=67a2342442c9
description:
Ensure to exit after query canceled

issue10272
review365201003
(grafted from 1b45f5a4b823b434b35a4d9ff6817e680f066023)
diffstat:

 tryton/common/common.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r e48a5ab0852f -r 67a2342442c9 tryton/common/common.py
--- a/tryton/common/common.py   Sun May 02 10:59:12 2021 +0200
+++ b/tryton/common/common.py   Sun May 02 11:04:35 2021 +0200
@@ -876,6 +876,7 @@
 except TrytonError as exception:
 if exception.faultCode == 'QueryCanceled':
 Main().on_quit()
+sys.exit()
 raise
 finally:
 PLOCK.release()



[tryton-commits] changeset in tryton:5.8 Ensure to exit after query canceled

2021-05-06 Thread Cédric Krier
changeset 4c5b704cf6bc in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=4c5b704cf6bc
description:
Ensure to exit after query canceled

issue10272
review365201003
(grafted from 1b45f5a4b823b434b35a4d9ff6817e680f066023)
diffstat:

 tryton/common/common.py |  1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diffs (11 lines):

diff -r 88c597f09372 -r 4c5b704cf6bc tryton/common/common.py
--- a/tryton/common/common.py   Sun May 02 10:59:12 2021 +0200
+++ b/tryton/common/common.py   Sun May 02 11:04:35 2021 +0200
@@ -898,6 +898,7 @@
 except TrytonError as exception:
 if exception.faultCode == 'QueryCanceled':
 Main().on_quit()
+sys.exit()
 raise
 finally:
 PLOCK.release()



[tryton-commits] changeset in tryton:5.0 Store only once record removed or deleted

2021-05-06 Thread Cédric Krier
changeset bba153625edc in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=bba153625edc
description:
Store only once record removed or deleted

issue10236
review351891002
(grafted from ab4e4fac8f3a7bf65c381b77e80720055580439d)
diffstat:

 tryton/gui/window/view_form/model/group.py |  20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (38 lines):

diff -r 512adb5869a8 -r bba153625edc tryton/gui/window/view_form/model/group.py
--- a/tryton/gui/window/view_form/model/group.pyFri Apr 30 13:29:22 
2021 +0200
+++ b/tryton/gui/window/view_form/model/group.pySun May 02 10:59:12 
2021 +0200
@@ -394,23 +394,25 @@
 def remove(self, record, remove=False, modified=True, signal=True,
 force_remove=False):
 idx = self.index(record)
-if self[idx].id >= 0:
+if record.id >= 0:
 if remove:
-if self[idx] in self.record_deleted:
-self.record_deleted.remove(self[idx])
-self.record_removed.append(self[idx])
+if record in self.record_deleted:
+self.record_deleted.remove(record)
+if record not in self.record_removed:
+self.record_removed.append(record)
 else:
-if self[idx] in self.record_removed:
-self.record_removed.remove(self[idx])
-self.record_deleted.append(self[idx])
+if record in self.record_removed:
+self.record_removed.remove(record)
+if record not in self.record_deleted:
+self.record_deleted.append(record)
 if record.parent:
 record.parent.modified_fields.setdefault('id')
 record.parent.signal('record-modified')
 if modified:
 record.modified_fields.setdefault('id')
 record.signal('record-modified')
-if self[idx].id < 0 or force_remove:
-self._remove(self[idx])
+if record.id < 0 or force_remove:
+self._remove(record)
 
 if len(self):
 self.current_idx = min(idx, len(self) - 1)



[tryton-commits] changeset in tryton:5.6 Store only once record removed or deleted

2021-05-06 Thread Cédric Krier
changeset e48a5ab0852f in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=e48a5ab0852f
description:
Store only once record removed or deleted

issue10236
review351891002
(grafted from ab4e4fac8f3a7bf65c381b77e80720055580439d)
diffstat:

 tryton/gui/window/view_form/model/group.py |  20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (38 lines):

diff -r f5a250ad2b4f -r e48a5ab0852f tryton/gui/window/view_form/model/group.py
--- a/tryton/gui/window/view_form/model/group.pyFri Apr 30 13:29:22 
2021 +0200
+++ b/tryton/gui/window/view_form/model/group.pySun May 02 10:59:12 
2021 +0200
@@ -399,23 +399,25 @@
 def remove(self, record, remove=False, modified=True, signal=True,
 force_remove=False):
 idx = self.index(record)
-if self[idx].id >= 0:
+if record.id >= 0:
 if remove:
-if self[idx] in self.record_deleted:
-self.record_deleted.remove(self[idx])
-self.record_removed.append(self[idx])
+if record in self.record_deleted:
+self.record_deleted.remove(record)
+if record not in self.record_removed:
+self.record_removed.append(record)
 else:
-if self[idx] in self.record_removed:
-self.record_removed.remove(self[idx])
-self.record_deleted.append(self[idx])
+if record in self.record_removed:
+self.record_removed.remove(record)
+if record not in self.record_deleted:
+self.record_deleted.append(record)
 if record.parent:
 record.parent.modified_fields.setdefault('id')
 record.parent.signal('record-modified')
 if modified:
 record.modified_fields.setdefault('id')
 record.signal('record-modified')
-if self[idx].id < 0 or force_remove:
-self._remove(self[idx])
+if record.id < 0 or force_remove:
+self._remove(record)
 
 if len(self):
 self.current_idx = min(idx, len(self) - 1)



[tryton-commits] changeset in tryton:5.8 Store only once record removed or deleted

2021-05-06 Thread Cédric Krier
changeset 88c597f09372 in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=88c597f09372
description:
Store only once record removed or deleted

issue10236
review351891002
(grafted from ab4e4fac8f3a7bf65c381b77e80720055580439d)
diffstat:

 tryton/gui/window/view_form/model/group.py |  20 +++-
 1 files changed, 11 insertions(+), 9 deletions(-)

diffs (38 lines):

diff -r 82ef45f0c88e -r 88c597f09372 tryton/gui/window/view_form/model/group.py
--- a/tryton/gui/window/view_form/model/group.pyFri Apr 30 13:29:22 
2021 +0200
+++ b/tryton/gui/window/view_form/model/group.pySun May 02 10:59:12 
2021 +0200
@@ -403,23 +403,25 @@
 def remove(self, record, remove=False, modified=True, signal=True,
 force_remove=False):
 idx = self.index(record)
-if self[idx].id >= 0:
+if record.id >= 0:
 if remove:
-if self[idx] in self.record_deleted:
-self.record_deleted.remove(self[idx])
-self.record_removed.append(self[idx])
+if record in self.record_deleted:
+self.record_deleted.remove(record)
+if record not in self.record_removed:
+self.record_removed.append(record)
 else:
-if self[idx] in self.record_removed:
-self.record_removed.remove(self[idx])
-self.record_deleted.append(self[idx])
+if record in self.record_removed:
+self.record_removed.remove(record)
+if record not in self.record_deleted:
+self.record_deleted.append(record)
 if record.parent:
 record.parent.modified_fields.setdefault('id')
 record.parent.signal('record-modified')
 if modified:
 record.modified_fields.setdefault('id')
 record.signal('record-modified')
-if self[idx].id < 0 or force_remove:
-self._remove(self[idx])
+if record.id < 0 or force_remove:
+self._remove(record)
 
 if len(self):
 self.current_idx = min(idx, len(self) - 1)



[tryton-commits] changeset in tryton:5.0 Do not clear tree_states when loading ids

2021-05-06 Thread Cédric Krier
changeset 512adb5869a8 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=512adb5869a8
description:
Do not clear tree_states when loading ids

The tree state must be set after loading ids but we can rely on the 
stored
state.

issue10366
review361811002
(grafted from 3c66d5f1cc0002804cabed9fdcec4fb1198f1cf8)
diffstat:

 tryton/gui/window/view_form/screen/screen.py |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r 2348b69957e7 -r 512adb5869a8 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py  Wed Apr 28 22:26:52 
2021 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py  Fri Apr 30 13:29:22 
2021 +0200
@@ -887,7 +887,6 @@
 return json_domain
 
 def load(self, ids, set_cursor=True, modified=False):
-self.tree_states.clear()
 self.tree_states_done.clear()
 self.group.load(ids, modified=modified)
 self.current_view.reset()



[tryton-commits] changeset in tryton:5.6 Do not clear tree_states when loading ids

2021-05-06 Thread Cédric Krier
changeset f5a250ad2b4f in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=f5a250ad2b4f
description:
Do not clear tree_states when loading ids

The tree state must be set after loading ids but we can rely on the 
stored
state.

issue10366
review361811002
(grafted from 3c66d5f1cc0002804cabed9fdcec4fb1198f1cf8)
diffstat:

 tryton/gui/window/view_form/screen/screen.py |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r f587c4bee161 -r f5a250ad2b4f 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py  Wed Apr 28 22:26:52 
2021 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py  Fri Apr 30 13:29:22 
2021 +0200
@@ -892,7 +892,6 @@
 return json_domain
 
 def load(self, ids, set_cursor=True, modified=False):
-self.tree_states.clear()
 self.tree_states_done.clear()
 self.group.load(ids, modified=modified)
 self.current_view.reset()



[tryton-commits] changeset in tryton:5.8 Do not clear tree_states when loading ids

2021-05-06 Thread Cédric Krier
changeset 82ef45f0c88e in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=82ef45f0c88e
description:
Do not clear tree_states when loading ids

The tree state must be set after loading ids but we can rely on the 
stored
state.

issue10366
review361811002
(grafted from 3c66d5f1cc0002804cabed9fdcec4fb1198f1cf8)
diffstat:

 tryton/gui/window/view_form/screen/screen.py |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r 78c41c370f88 -r 82ef45f0c88e 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py  Wed Apr 28 22:26:52 
2021 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py  Fri Apr 30 13:29:22 
2021 +0200
@@ -909,7 +909,6 @@
 return json_domain
 
 def load(self, ids, set_cursor=True, modified=False, position=-1):
-self.tree_states.clear()
 self.tree_states_done.clear()
 self.group.load(ids, modified=modified, position=position)
 self.current_view.reset()



[tryton-commits] changeset in tryton:5.0 Ensure zero padding for year

2021-05-06 Thread Cédric Krier
changeset 2348b69957e7 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=2348b69957e7
description:
Ensure zero padding for year

It is needed to parse it back as a full year and not a year in current
century.

issue10343
review346051003
(grafted from d77748324d8d7fe285377f94605b9ad24ad8116d)
diffstat:

 tryton/common/datetime_.py |  16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r e9a14ac46061 -r 2348b69957e7 tryton/common/datetime_.py
--- a/tryton/common/datetime_.pyThu Apr 22 07:56:09 2021 +0200
+++ b/tryton/common/datetime_.pyWed Apr 28 22:26:52 2021 +0200
@@ -17,6 +17,14 @@
 _ = gettext.gettext
 
 
+def _fix_format(format_):
+if '%Y' in format_:
+if (datetime.date.min.strftime('%Y') != '0001'
+and datetime.date.min.strftime('%4Y') == '0001'):
+format_ = format_.replace('%Y', '%4Y')
+return format_
+
+
 def date_parse(text, format_='%x'):
 try:
 return datetime.datetime.strptime(text, format_)
@@ -186,7 +194,7 @@
 self.__date = value
 self.update_label()
 elif prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 self.update_label()
 
 def do_get_property(self, prop):
@@ -215,7 +223,7 @@
 
 def do_set_property(self, prop, value):
 if prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 return
 gtk.CellRendererText.set_property(self, prop, value)
 
@@ -336,7 +344,7 @@
 self.__time = value
 self.update_label()
 elif prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 self.update_label()
 self.update_model()
 
@@ -366,7 +374,7 @@
 
 def do_set_property(self, prop, value):
 if prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 return
 gtk.CellRendererText.set_property(self, prop, value)
 



[tryton-commits] changeset in tryton:5.6 Ensure zero padding for year

2021-05-06 Thread Cédric Krier
changeset f587c4bee161 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=f587c4bee161
description:
Ensure zero padding for year

It is needed to parse it back as a full year and not a year in current
century.

issue10343
review346051003
(grafted from d77748324d8d7fe285377f94605b9ad24ad8116d)
diffstat:

 tryton/common/datetime_.py |  16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 3368e556c73e -r f587c4bee161 tryton/common/datetime_.py
--- a/tryton/common/datetime_.pyFri Apr 23 11:53:48 2021 +0200
+++ b/tryton/common/datetime_.pyWed Apr 28 22:26:52 2021 +0200
@@ -15,6 +15,14 @@
 _ = gettext.gettext
 
 
+def _fix_format(format_):
+if '%Y' in format_:
+if (datetime.date.min.strftime('%Y') != '0001'
+and datetime.date.min.strftime('%4Y') == '0001'):
+format_ = format_.replace('%Y', '%4Y')
+return format_
+
+
 def date_parse(text, format_='%x'):
 try:
 return datetime.datetime.strptime(text, format_)
@@ -191,7 +199,7 @@
 self.update_label()
 self.emit('date-changed')
 elif prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 self.update_label()
 
 def do_get_property(self, prop):
@@ -222,7 +230,7 @@
 
 def do_set_property(self, prop, value):
 if prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 return
 Gtk.CellRendererText.set_property(self, prop, value)
 
@@ -362,7 +370,7 @@
 self.update_label()
 self.emit('time-changed')
 elif prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 self.update_label()
 self.update_model()
 
@@ -394,7 +402,7 @@
 
 def do_set_property(self, prop, value):
 if prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 return
 Gtk.CellRendererText.set_property(self, prop, value)
 



[tryton-commits] changeset in tryton:5.8 Ensure zero padding for year

2021-05-06 Thread Cédric Krier
changeset 78c41c370f88 in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=78c41c370f88
description:
Ensure zero padding for year

It is needed to parse it back as a full year and not a year in current
century.

issue10343
review346051003
(grafted from d77748324d8d7fe285377f94605b9ad24ad8116d)
diffstat:

 tryton/common/datetime_.py |  16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 9de1e575112f -r 78c41c370f88 tryton/common/datetime_.py
--- a/tryton/common/datetime_.pyFri Apr 23 11:53:48 2021 +0200
+++ b/tryton/common/datetime_.pyWed Apr 28 22:26:52 2021 +0200
@@ -15,6 +15,14 @@
 _ = gettext.gettext
 
 
+def _fix_format(format_):
+if '%Y' in format_:
+if (datetime.date.min.strftime('%Y') != '0001'
+and datetime.date.min.strftime('%4Y') == '0001'):
+format_ = format_.replace('%Y', '%4Y')
+return format_
+
+
 def date_parse(text, format_='%x'):
 try:
 return datetime.datetime.strptime(text, format_)
@@ -191,7 +199,7 @@
 self.update_label()
 self.emit('date-changed')
 elif prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 self.update_label()
 
 def do_get_property(self, prop):
@@ -222,7 +230,7 @@
 
 def do_set_property(self, prop, value):
 if prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 return
 Gtk.CellRendererText.set_property(self, prop, value)
 
@@ -362,7 +370,7 @@
 self.update_label()
 self.emit('time-changed')
 elif prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 self.update_label()
 self.update_model()
 
@@ -394,7 +402,7 @@
 
 def do_set_property(self, prop, value):
 if prop.name == 'format':
-self.__format = value
+self.__format = _fix_format(value)
 return
 Gtk.CellRendererText.set_property(self, prop, value)
 



[tryton-commits] changeset in tryton:5.6 Fix wrong call to gettext in compare window

2021-05-06 Thread Maxime Richez
changeset 3368e556c73e in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=3368e556c73e
description:
Fix wrong call to gettext in compare window

issue10320
review342181002
(grafted from b80b73ab09410fea132f09e854c78b86ede50a6d)
diffstat:

 tryton/common/common.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 462c2af68977 -r 3368e556c73e tryton/common/common.py
--- a/tryton/common/common.py   Thu Apr 22 23:51:22 2021 +0200
+++ b/tryton/common/common.py   Fri Apr 23 11:53:48 2021 +0200
@@ -707,7 +707,7 @@
 Window.create(
 model,
 res_id=id_,
-name=_("Compare: %s", name),
+name=_("Compare: %s") % name,
 domain=[('id', '=', id_)],
 context=context,
 mode=['form'])



[tryton-commits] changeset in tryton:5.8 Fix wrong call to gettext in compare window

2021-05-06 Thread Maxime Richez
changeset 9de1e575112f in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=9de1e575112f
description:
Fix wrong call to gettext in compare window

issue10320
review342181002
(grafted from b80b73ab09410fea132f09e854c78b86ede50a6d)
diffstat:

 tryton/common/common.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 9eccda2d16da -r 9de1e575112f tryton/common/common.py
--- a/tryton/common/common.py   Thu Apr 22 23:51:22 2021 +0200
+++ b/tryton/common/common.py   Fri Apr 23 11:53:48 2021 +0200
@@ -729,7 +729,7 @@
 Window.create(
 model,
 res_id=id_,
-name=_("Compare: %s", name),
+name=_("Compare: %s") % name,
 domain=[('id', '=', id_)],
 context=context,
 mode=['form'])



[tryton-commits] changeset in tryton:5.6 Limit entry width to a maximum of 120 chars

2021-05-06 Thread Cédric Krier
changeset 462c2af68977 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=462c2af68977
description:
Limit entry width to a maximum of 120 chars

This avoids creating horizontal scroll with fields with bigger size.

issue10285
review361661002
(grafted from 6b07ac3f3e93966d79c5965e51853f7a39bdea28)
diffstat:

 tryton/gui/window/view_form/view/form_gtk/char.py |  6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 758ba2be546a -r 462c2af68977 
tryton/gui/window/view_form/view/form_gtk/char.py
--- a/tryton/gui/window/view_form/view/form_gtk/char.py Thu Apr 22 23:47:17 
2021 +0200
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py Thu Apr 22 23:51:22 
2021 +0200
@@ -55,7 +55,8 @@
 entry.set_property('activates_default', True)
 if self.record:
 field_size = self.record.expr_eval(self.attrs.get('size'))
-entry.set_width_chars(field_size or self.default_width_chars)
+entry.set_width_chars(
+min(120, field_size or self.default_width_chars))
 entry.set_max_length(field_size or 0)
 return entry
 
@@ -120,7 +121,8 @@
 size_entry = self.entry
 if self.record:
 field_size = self.record.expr_eval(self.attrs.get('size'))
-size_entry.set_width_chars(field_size or self.default_width_chars)
+size_entry.set_width_chars(
+min(120, field_size or self.default_width_chars))
 size_entry.set_max_length(field_size or 0)
 else:
 size_entry.set_width_chars(self.default_width_chars)



[tryton-commits] changeset in tryton:5.8 Limit entry width to a maximum of 120 chars

2021-05-06 Thread Cédric Krier
changeset 9eccda2d16da in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=9eccda2d16da
description:
Limit entry width to a maximum of 120 chars

This avoids creating horizontal scroll with fields with bigger size.

issue10285
review361661002
(grafted from 6b07ac3f3e93966d79c5965e51853f7a39bdea28)
diffstat:

 tryton/gui/window/view_form/view/form_gtk/char.py |  6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r e430bbc9f2cc -r 9eccda2d16da 
tryton/gui/window/view_form/view/form_gtk/char.py
--- a/tryton/gui/window/view_form/view/form_gtk/char.py Thu Apr 22 23:47:17 
2021 +0200
+++ b/tryton/gui/window/view_form/view/form_gtk/char.py Thu Apr 22 23:51:22 
2021 +0200
@@ -55,7 +55,8 @@
 entry.set_property('activates_default', True)
 if self.record:
 field_size = self.record.expr_eval(self.attrs.get('size'))
-entry.set_width_chars(field_size or self.default_width_chars)
+entry.set_width_chars(
+min(120, field_size or self.default_width_chars))
 entry.set_max_length(field_size or 0)
 return entry
 
@@ -120,7 +121,8 @@
 size_entry = self.entry
 if self.record:
 field_size = self.record.expr_eval(self.attrs.get('size'))
-size_entry.set_width_chars(field_size or self.default_width_chars)
+size_entry.set_width_chars(
+min(120, field_size or self.default_width_chars))
 size_entry.set_max_length(field_size or 0)
 else:
 size_entry.set_width_chars(self.default_width_chars)



[tryton-commits] changeset in tryton:5.6 Test editable and activatable property t...

2021-05-06 Thread Cédric Krier
changeset 758ba2be546a in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=758ba2be546a
description:
Test editable and activatable property to find editable cells

issue9905
review320971002
(grafted from de087a40f176209c0561bc5d47b24d67d369533c)
diffstat:

 tryton/gui/window/view_form/view/list_gtk/editabletree.py |  11 +++
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (21 lines):

diff -r 0b8391683069 -r 758ba2be546a 
tryton/gui/window/view_form/view/list_gtk/editabletree.py
--- a/tryton/gui/window/view_form/view/list_gtk/editabletree.py Thu Apr 22 
07:56:09 2021 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/editabletree.py Thu Apr 22 
23:47:17 2021 +0200
@@ -13,10 +13,13 @@
 
 def focusable_cells(column, editable=True):
 for cell in column.get_cells():
-if not editable or isinstance(cell, (
-Gtk.CellRendererText,
-Gtk.CellRendererCombo,
-Gtk.CellRendererToggle)):
+if (not editable
+or (isinstance(cell, (
+Gtk.CellRendererText,
+Gtk.CellRendererCombo))
+and cell.get_property('editable'))
+or (isinstance(cell, Gtk.CellRendererToggle)
+and cell.get_property('activatable'))):
 yield cell
 
 



[tryton-commits] changeset in tryton:5.8 Test editable and activatable property t...

2021-05-06 Thread Cédric Krier
changeset e430bbc9f2cc in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=e430bbc9f2cc
description:
Test editable and activatable property to find editable cells

issue9905
review320971002
(grafted from de087a40f176209c0561bc5d47b24d67d369533c)
diffstat:

 tryton/gui/window/view_form/view/list_gtk/editabletree.py |  11 +++
 1 files changed, 7 insertions(+), 4 deletions(-)

diffs (21 lines):

diff -r b2171388987d -r e430bbc9f2cc 
tryton/gui/window/view_form/view/list_gtk/editabletree.py
--- a/tryton/gui/window/view_form/view/list_gtk/editabletree.py Thu Apr 22 
07:56:09 2021 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/editabletree.py Thu Apr 22 
23:47:17 2021 +0200
@@ -13,10 +13,13 @@
 
 def focusable_cells(column, editable=True):
 for cell in column.get_cells():
-if not editable or isinstance(cell, (
-Gtk.CellRendererText,
-Gtk.CellRendererCombo,
-Gtk.CellRendererToggle)):
+if (not editable
+or (isinstance(cell, (
+Gtk.CellRendererText,
+Gtk.CellRendererCombo))
+and cell.get_property('editable'))
+or (isinstance(cell, Gtk.CellRendererToggle)
+and cell.get_property('activatable'))):
 yield cell
 
 



[tryton-commits] changeset in tryton:5.0 Add missing decimal separator on label f...

2021-05-06 Thread Sergi Almacellas Abellana
changeset e9a14ac46061 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=e9a14ac46061
description:
Add missing decimal separator on label format

issue10312
review320981008
(grafted from caf5ace2ac2b430a03e5df601cd553c91e4011b8)
diffstat:

 tryton/gui/window/view_form/view/graph_gtk/line.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 132df53d9f62 -r e9a14ac46061 
tryton/gui/window/view_form/view/graph_gtk/line.py
--- a/tryton/gui/window/view_form/view/graph_gtk/line.pyThu Apr 22 
00:07:18 2021 +0200
+++ b/tryton/gui/window/view_form/view/graph_gtk/line.pyThu Apr 22 
07:56:09 2021 +0200
@@ -202,7 +202,7 @@
 label += common.timedelta.format(point.yval, converter)
 else:
 label += locale.localize(
-'{:2f}'.format(point.yval), True)
+'{:.2f}'.format(point.yval), True)
 label += '\n'
 label += str(self.labels[point.xname])
 self.popup.set_text(label)



[tryton-commits] changeset in tryton:5.6 Add missing decimal separator on label f...

2021-05-06 Thread Sergi Almacellas Abellana
changeset 0b8391683069 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=0b8391683069
description:
Add missing decimal separator on label format

issue10312
review320981008
(grafted from caf5ace2ac2b430a03e5df601cd553c91e4011b8)
diffstat:

 tryton/gui/window/view_form/view/graph_gtk/line.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r ce2b6deb8fb1 -r 0b8391683069 
tryton/gui/window/view_form/view/graph_gtk/line.py
--- a/tryton/gui/window/view_form/view/graph_gtk/line.pyThu Apr 22 
00:07:18 2021 +0200
+++ b/tryton/gui/window/view_form/view/graph_gtk/line.pyThu Apr 22 
07:56:09 2021 +0200
@@ -202,7 +202,7 @@
 label += common.timedelta.format(point.yval, converter)
 else:
 label += locale.localize(
-'{:2f}'.format(point.yval), True)
+'{:.2f}'.format(point.yval), True)
 label += '\n'
 label += str(self.labels[point.xname])
 self.popup.set_text(label)



[tryton-commits] changeset in tryton:5.8 Add missing decimal separator on label f...

2021-05-06 Thread Sergi Almacellas Abellana
changeset b2171388987d in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=b2171388987d
description:
Add missing decimal separator on label format

issue10312
review320981008
(grafted from caf5ace2ac2b430a03e5df601cd553c91e4011b8)
diffstat:

 tryton/gui/window/view_form/view/graph_gtk/line.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 9abf0bade454 -r b2171388987d 
tryton/gui/window/view_form/view/graph_gtk/line.py
--- a/tryton/gui/window/view_form/view/graph_gtk/line.pyThu Apr 22 
00:07:18 2021 +0200
+++ b/tryton/gui/window/view_form/view/graph_gtk/line.pyThu Apr 22 
07:56:09 2021 +0200
@@ -202,7 +202,7 @@
 label += common.timedelta.format(point.yval, converter)
 else:
 label += locale.localize(
-'{:2f}'.format(point.yval), True)
+'{:.2f}'.format(point.yval), True)
 label += '\n'
 label += str(self.labels[point.xname])
 self.popup.set_text(label)



[tryton-commits] changeset in tryton:5.0 Use change value as initial value for Wi...

2021-05-06 Thread Cédric Krier
changeset 132df53d9f62 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=132df53d9f62
description:
Use change value as initial value for Window Form

The parent field must stay as eval value as it is not reset.

issue10185
review365111002
(grafted from 3e61649647523a6199f46e355b071c5c80c5b0e5)
diffstat:

 tryton/gui/window/win_form.py |  7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (17 lines):

diff -r 66594bba998b -r 132df53d9f62 tryton/gui/window/win_form.py
--- a/tryton/gui/window/win_form.py Wed May 05 22:44:12 2021 +0200
+++ b/tryton/gui/window/win_form.py Thu Apr 22 00:07:18 2021 +0200
@@ -69,7 +69,12 @@
 label, icon = _("Delete"), 'tryton-delete'
 else:
 label, icon = _("Cancel"), 'tryton-cancel'
-self._initial_value = self.screen.current_record.get_eval()
+record = self.screen.current_record
+self._initial_value = record.get_on_change_value()
+if record.parent and record.parent_name in record.group.fields:
+parent_field = record.group.fields[record.parent_name]
+self._initial_value[record.parent_name] = (
+parent_field.get_eval(record))
 self.but_cancel = self.win.add_button(
 set_underline(label), gtk.RESPONSE_CANCEL)
 self.but_cancel.set_image(common.IconFactory.get_image(



[tryton-commits] changeset in tryton:5.6 Use change value as initial value for Wi...

2021-05-06 Thread Cédric Krier
changeset ce2b6deb8fb1 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=ce2b6deb8fb1
description:
Use change value as initial value for Window Form

The parent field must stay as eval value as it is not reset.

issue10185
review365111002
(grafted from 3e61649647523a6199f46e355b071c5c80c5b0e5)
diffstat:

 tryton/gui/window/win_form.py |  7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (17 lines):

diff -r 3c474969ead5 -r ce2b6deb8fb1 tryton/gui/window/win_form.py
--- a/tryton/gui/window/win_form.py Wed Apr 21 23:51:15 2021 +0200
+++ b/tryton/gui/window/win_form.py Thu Apr 22 00:07:18 2021 +0200
@@ -66,7 +66,12 @@
 label, icon = _("Delete"), 'tryton-delete'
 else:
 label, icon = _("Cancel"), 'tryton-cancel'
-self._initial_value = self.screen.current_record.get_eval()
+record = self.screen.current_record
+self._initial_value = record.get_on_change_value()
+if record.parent and record.parent_name in record.group.fields:
+parent_field = record.group.fields[record.parent_name]
+self._initial_value[record.parent_name] = (
+parent_field.get_eval(record))
 self.but_cancel = self.win.add_button(
 set_underline(label), Gtk.ResponseType.CANCEL)
 self.but_cancel.set_image(common.IconFactory.get_image(



[tryton-commits] changeset in tryton:5.8 Use change value as initial value for Wi...

2021-05-06 Thread Cédric Krier
changeset 9abf0bade454 in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=9abf0bade454
description:
Use change value as initial value for Window Form

The parent field must stay as eval value as it is not reset.

issue10185
review365111002
(grafted from 3e61649647523a6199f46e355b071c5c80c5b0e5)
diffstat:

 tryton/gui/window/win_form.py |  7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (17 lines):

diff -r a1073a6f4238 -r 9abf0bade454 tryton/gui/window/win_form.py
--- a/tryton/gui/window/win_form.py Wed Apr 21 23:51:15 2021 +0200
+++ b/tryton/gui/window/win_form.py Thu Apr 22 00:07:18 2021 +0200
@@ -68,7 +68,12 @@
 label, icon = _("Delete"), 'tryton-delete'
 else:
 label, icon = _("Cancel"), 'tryton-cancel'
-self._initial_value = self.screen.current_record.get_eval()
+record = self.screen.current_record
+self._initial_value = record.get_on_change_value()
+if record.parent and record.parent_name in record.group.fields:
+parent_field = record.group.fields[record.parent_name]
+self._initial_value[record.parent_name] = (
+parent_field.get_eval(record))
 self.but_cancel = self.win.add_button(
 set_underline(label), Gtk.ResponseType.CANCEL)
 self.but_cancel.set_image(common.IconFactory.get_image(



[tryton-commits] changeset in tryton:5.6 Fall-back to default order to define new...

2021-05-06 Thread Cédric Krier
changeset 3c474969ead5 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=3c474969ead5
description:
Fall-back to default order to define new position

When there is no order on the screen, we must use the default order 
because it
contains the order of the relation field.

issue10298
review340621002
(grafted from 3d33c402995f549e9051b46da9fce3ab089c6529)
diffstat:

 tryton/gui/window/view_form/screen/screen.py |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 7b3af50986a8 -r 3c474969ead5 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py  Wed Apr 21 23:47:30 
2021 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py  Wed Apr 21 23:51:15 
2021 +0200
@@ -617,8 +617,12 @@
 
 @property
 def new_position(self):
-if self.order:
-for oexpr, otype in self.order:
+if self.order is not None:
+order = self.order
+else:
+order = self.default_order
+if order:
+for oexpr, otype in order:
 if oexpr == 'id' and otype:
 if otype.startswith('DESC'):
 return 0



[tryton-commits] changeset in tryton:5.8 Fall-back to default order to define new...

2021-05-06 Thread Cédric Krier
changeset a1073a6f4238 in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=a1073a6f4238
description:
Fall-back to default order to define new position

When there is no order on the screen, we must use the default order 
because it
contains the order of the relation field.

issue10298
review340621002
(grafted from 3d33c402995f549e9051b46da9fce3ab089c6529)
diffstat:

 tryton/gui/window/view_form/screen/screen.py |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r 39bebd2c9bcd -r a1073a6f4238 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py  Wed Apr 21 23:47:30 
2021 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py  Wed Apr 21 23:51:15 
2021 +0200
@@ -634,8 +634,12 @@
 
 @property
 def new_position(self):
-if self.order:
-for oexpr, otype in self.order:
+if self.order is not None:
+order = self.order
+else:
+order = self.default_order
+if order:
+for oexpr, otype in order:
 if oexpr == 'id' and otype:
 if otype.startswith('DESC'):
 return 0



[tryton-commits] changeset in tryton:5.6 Use order definition of xxx2Many fields

2021-05-06 Thread Cédric Krier
changeset 7b3af50986a8 in tryton:5.6
details: https://hg.tryton.org/tryton?cmd=changeset=7b3af50986a8
description:
Use order definition of xxx2Many fields

When empty it must be the order of the target and it must not be 
encoded as it
can not be PYSON.

issue10297
review349721004
(grafted from 22adac0c1beebb662f032ab70f086424cd495831)
diffstat:

 tryton/gui/window/view_form/view/__init__.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 001ab7554b8c -r 7b3af50986a8 
tryton/gui/window/view_form/view/__init__.py
--- a/tryton/gui/window/view_form/view/__init__.py  Wed May 05 22:43:45 
2021 +0200
+++ b/tryton/gui/window/view_form/view/__init__.py  Wed Apr 21 23:47:30 
2021 +0200
@@ -117,7 +117,7 @@
 'relation_field', 'views', 'invisible', 'add_remove',
 'sort', 'context', 'size', 'filename', 'autocomplete',
 'translate', 'create', 'delete', 'selection_change_with',
-'schema_model', 'required']:
+'schema_model', 'required', 'order']:
 if name in field:
 node_attrs.setdefault(name, field[name])
 return node_attrs



[tryton-commits] changeset in tryton:5.8 Use order definition of xxx2Many fields

2021-05-06 Thread Cédric Krier
changeset 39bebd2c9bcd in tryton:5.8
details: https://hg.tryton.org/tryton?cmd=changeset=39bebd2c9bcd
description:
Use order definition of xxx2Many fields

When empty it must be the order of the target and it must not be 
encoded as it
can not be PYSON.

issue10297
review349721004
(grafted from 22adac0c1beebb662f032ab70f086424cd495831)
diffstat:

 tryton/gui/window/view_form/view/__init__.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r f94767723d23 -r 39bebd2c9bcd 
tryton/gui/window/view_form/view/__init__.py
--- a/tryton/gui/window/view_form/view/__init__.py  Wed May 05 22:42:47 
2021 +0200
+++ b/tryton/gui/window/view_form/view/__init__.py  Wed Apr 21 23:47:30 
2021 +0200
@@ -117,7 +117,7 @@
 'relation_field', 'views', 'invisible', 'add_remove',
 'sort', 'context', 'size', 'filename', 'autocomplete',
 'translate', 'create', 'delete', 'selection_change_with',
-'schema_model', 'required']:
+'schema_model', 'required', 'order']:
 if name in field:
 node_attrs.setdefault(name, field[name])
 return node_attrs



[tryton-commits] changeset in sao:5.0 Store only once record removed or deleted

2021-05-06 Thread Cédric Krier
changeset 059dc0ba04c4 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=059dc0ba04c4
description:
Store only once record removed or deleted

issue10236
review351891002
(grafted from c10a8104cf4147260091529263020480df86d61a)
diffstat:

 src/model.js |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 82eb4aeb7bb9 -r 059dc0ba04c4 src/model.js
--- a/src/model.js  Fri Apr 30 13:46:02 2021 +0200
+++ b/src/model.js  Sun May 02 10:59:12 2021 +0200
@@ -193,13 +193,17 @@
 this.record_deleted.splice(
 this.record_deleted.indexOf(record), 1);
 }
-this.record_removed.push(record);
+if (!~this.record_removed.indexOf(record)) {
+this.record_removed.push(record);
+}
 } else {
 if (~this.record_removed.indexOf(record)) {
 this.record_removed.splice(
 this.record_removed.indexOf(record), 1);
 }
-this.record_deleted.push(record);
+if (!~this.record_deleted.indexOf(record)) {
+this.record_deleted.push(record);
+}
 }
 }
 if (record.group.parent) {



[tryton-commits] changeset in sao:5.6 Store only once record removed or deleted

2021-05-06 Thread Cédric Krier
changeset 231ce36f6de2 in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=231ce36f6de2
description:
Store only once record removed or deleted

issue10236
review351891002
(grafted from c10a8104cf4147260091529263020480df86d61a)
diffstat:

 src/model.js |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r a945da853e62 -r 231ce36f6de2 src/model.js
--- a/src/model.js  Fri Apr 30 13:46:02 2021 +0200
+++ b/src/model.js  Sun May 02 10:59:12 2021 +0200
@@ -196,13 +196,17 @@
 this.record_deleted.splice(
 this.record_deleted.indexOf(record), 1);
 }
-this.record_removed.push(record);
+if (!~this.record_removed.indexOf(record)) {
+this.record_removed.push(record);
+}
 } else {
 if (~this.record_removed.indexOf(record)) {
 this.record_removed.splice(
 this.record_removed.indexOf(record), 1);
 }
-this.record_deleted.push(record);
+if (!~this.record_deleted.indexOf(record)) {
+this.record_deleted.push(record);
+}
 }
 }
 if (record.group.parent) {



[tryton-commits] changeset in sao:5.8 Store only once record removed or deleted

2021-05-06 Thread Cédric Krier
changeset e138cbaec9ce in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=e138cbaec9ce
description:
Store only once record removed or deleted

issue10236
review351891002
(grafted from c10a8104cf4147260091529263020480df86d61a)
diffstat:

 src/model.js |  8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r e0809a4611f1 -r e138cbaec9ce src/model.js
--- a/src/model.js  Fri Apr 30 13:46:02 2021 +0200
+++ b/src/model.js  Sun May 02 10:59:12 2021 +0200
@@ -200,13 +200,17 @@
 this.record_deleted.splice(
 this.record_deleted.indexOf(record), 1);
 }
-this.record_removed.push(record);
+if (!~this.record_removed.indexOf(record)) {
+this.record_removed.push(record);
+}
 } else {
 if (~this.record_removed.indexOf(record)) {
 this.record_removed.splice(
 this.record_removed.indexOf(record), 1);
 }
-this.record_deleted.push(record);
+if (!~this.record_deleted.indexOf(record)) {
+this.record_deleted.push(record);
+}
 }
 }
 if (record.group.parent) {



[tryton-commits] changeset in sao:5.0 Set _readonly attribute on all widgets

2021-05-06 Thread Cédric Krier
changeset 82eb4aeb7bb9 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=82eb4aeb7bb9
description:
Set _readonly attribute on all widgets

issue10239
review358011003
(grafted from f53aad05ec58133294fd2bcb0af11595478e2a26)
diffstat:

 src/view/form.js |  17 +
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (118 lines):

diff -r a4b2234ca214 -r 82eb4aeb7bb9 src/view/form.js
--- a/src/view/form.js  Fri Apr 30 13:29:22 2021 +0200
+++ b/src/view/form.js  Fri Apr 30 13:46:02 2021 +0200
@@ -1102,7 +1102,6 @@
 },
 set_readonly: function(readonly) {
 this._readonly = readonly;
-this.el.prop('disabled', readonly);
 },
 set_required: function(required) {
 },
@@ -1410,6 +1409,7 @@
 field.set_client(record, this.input.val());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Char._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 },
 focus: function() {
@@ -1563,6 +1563,7 @@
 field.set_client(record, this.get_value(record, field));
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Date._super.set_readonly.call(this, readonly);
 this.date.find('button').prop('disabled', readonly);
 this.date.find('input').prop('readonly', readonly);
 }
@@ -1628,6 +1629,7 @@
 field.set_client(record, this.input.val());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.TimeDelta._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 }
 });
@@ -1797,6 +1799,7 @@
 field.set_client(record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Selection._super.set_readonly.call(this, readonly);
 this.select.prop('disabled', readonly);
 }
 });
@@ -1836,6 +1839,7 @@
 field.set_client(record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Boolean._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 }
 });
@@ -1888,6 +1892,7 @@
 field.set_client(record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Text._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 },
 translate_widget: function() {
@@ -2111,6 +2116,7 @@
 });
 },
 set_readonly: function(readonly) {
+Sao.View.Form.RichText._super.set_readonly.call(this, readonly);
 this.input.prop('contenteditable', !readonly);
 if (this.toolbar) {
 this.toolbar.find('button,input,select')
@@ -2296,6 +2302,7 @@
 this.entry.focus();
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Many2One._super.set_readonly.call(this, readonly);
 this._readonly = readonly;
 this._set_button_sensitive();
 },
@@ -2906,7 +2913,7 @@
 this.but_switch.prop('disabled', this.screen.number_of_views() <= 
0);
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.One2Many._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 this._set_label_state();
 },
@@ -3330,7 +3337,7 @@
 }.bind(this));
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.Many2Many._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 this._set_label_state();
 },
@@ -3709,6 +3716,7 @@
 }
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Binary._super.set_readonly.call(this, readonly);
 this.but_select.prop('disabled', readonly);
 this.but_clear.prop('disabled', readonly);
 if (this.text) {
@@ -3788,6 +3796,7 @@
 this.update_img();
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Image._super.set_readonly.call(this, readonly);
 this.but_select.prop('disable', readonly);
 this.but_clear.prop('disable', readonly);
 },
@@ -4078,7 +4087,7 @@
 return value;
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.Dict._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 for (var key in this.fields) {
 var widget = this.fields[key];



[tryton-commits] changeset in sao:5.6 Set _readonly attribute on all widgets

2021-05-06 Thread Cédric Krier
changeset a945da853e62 in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=a945da853e62
description:
Set _readonly attribute on all widgets

issue10239
review358011003
(grafted from f53aad05ec58133294fd2bcb0af11595478e2a26)
diffstat:

 src/view/form.js |  17 +
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (118 lines):

diff -r a3c189f9b3aa -r a945da853e62 src/view/form.js
--- a/src/view/form.js  Fri Apr 30 13:29:22 2021 +0200
+++ b/src/view/form.js  Fri Apr 30 13:46:02 2021 +0200
@@ -1185,7 +1185,6 @@
 },
 set_readonly: function(readonly) {
 this._readonly = readonly;
-this.el.prop('disabled', readonly);
 },
 set_required: function(required) {
 },
@@ -1505,6 +1504,7 @@
 return this.input.val();
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Char._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 },
 focus: function() {
@@ -1668,6 +1668,7 @@
 this.field.set_client(this.record, this.get_value());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Date._super.set_readonly.call(this, readonly);
 this.date.find('button').prop('disabled', readonly);
 this.date.find('input').prop('readonly', readonly);
 }
@@ -1742,6 +1743,7 @@
 this.field.set_client(this.record, this.input.val());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.TimeDelta._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 }
 });
@@ -1984,6 +1986,7 @@
 this.field.set_client(this.record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Selection._super.set_readonly.call(this, readonly);
 this.select.prop('disabled', readonly);
 }
 });
@@ -2023,6 +2026,7 @@
 this.field.set_client(this.record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Boolean._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 }
 });
@@ -2084,6 +2088,7 @@
 this.field.set_client(this.record, this.get_value());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Text._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 },
 translate_widget: function() {
@@ -2316,6 +2321,7 @@
 return false;
 },
 set_readonly: function(readonly) {
+Sao.View.Form.RichText._super.set_readonly.call(this, readonly);
 this.input.prop('contenteditable', !readonly);
 if (this.toolbar) {
 this.toolbar.find('button,input,select')
@@ -2505,6 +2511,7 @@
 this.entry.focus();
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Many2One._super.set_readonly.call(this, readonly);
 this._readonly = readonly;
 this._set_button_sensitive();
 },
@@ -3142,7 +3149,7 @@
 return this.screen.current_view.modified;
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.One2Many._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 this._set_label_state();
 },
@@ -3597,7 +3604,7 @@
 }.bind(this));
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.Many2Many._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 this._set_label_state();
 },
@@ -3986,6 +3993,7 @@
 }
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Binary._super.set_readonly.call(this, readonly);
 this.but_select.prop('disabled', readonly);
 this.but_clear.prop('disabled', readonly);
 if (this.text) {
@@ -4064,6 +4072,7 @@
 }
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Image._super.set_readonly.call(this, readonly);
 this.but_select.prop('disable', readonly);
 this.but_clear.prop('disable', readonly);
 },
@@ -4422,7 +4431,7 @@
 return false;
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.Dict._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 for (var key in this.fields) {
 var widget = this.fields[key];



[tryton-commits] changeset in sao:5.8 Set _readonly attribute on all widgets

2021-05-06 Thread Cédric Krier
changeset e0809a4611f1 in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=e0809a4611f1
description:
Set _readonly attribute on all widgets

issue10239
review358011003
(grafted from f53aad05ec58133294fd2bcb0af11595478e2a26)
diffstat:

 src/view/form.js |  17 +
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (118 lines):

diff -r 4d64152e3bda -r e0809a4611f1 src/view/form.js
--- a/src/view/form.js  Fri Apr 30 13:29:22 2021 +0200
+++ b/src/view/form.js  Fri Apr 30 13:46:02 2021 +0200
@@ -1187,7 +1187,6 @@
 },
 set_readonly: function(readonly) {
 this._readonly = readonly;
-this.el.prop('disabled', readonly);
 },
 set_required: function(required) {
 },
@@ -1508,6 +1507,7 @@
 return this.input.val();
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Char._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 },
 focus: function() {
@@ -1669,6 +1669,7 @@
 this.field.set_client(this.record, this.get_value());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Date._super.set_readonly.call(this, readonly);
 this.date.find('button').prop('disabled', readonly);
 this.date.find('input').prop('readonly', readonly);
 }
@@ -1744,6 +1745,7 @@
 this.field.set_client(this.record, this.input.val());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.TimeDelta._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 }
 });
@@ -2017,6 +2019,7 @@
 this.field.set_client(this.record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Selection._super.set_readonly.call(this, readonly);
 this.select.prop('disabled', readonly);
 }
 });
@@ -2057,6 +2060,7 @@
 this.field.set_client(this.record, value);
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Boolean._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 }
 });
@@ -2119,6 +2123,7 @@
 this.field.set_client(this.record, this.get_value());
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Text._super.set_readonly.call(this, readonly);
 this.input.prop('readonly', readonly);
 },
 translate_widget: function() {
@@ -2215,6 +2220,7 @@
 return false;
 },
 set_readonly: function(readonly) {
+Sao.View.Form.RichText._super.set_readonly.call(this, readonly);
 this.input.prop('contenteditable', !readonly);
 if (this.toolbar) {
 this.toolbar.find('button,input,select')
@@ -2408,6 +2414,7 @@
 this.entry.focus();
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Many2One._super.set_readonly.call(this, readonly);
 this._readonly = readonly;
 this._set_button_sensitive();
 },
@@ -3046,7 +3053,7 @@
 return this.screen.current_view.modified;
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.One2Many._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 this._set_label_state();
 },
@@ -3506,7 +3513,7 @@
 }.bind(this));
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.Many2Many._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 this._set_label_state();
 },
@@ -3888,6 +3895,7 @@
 }
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Binary._super.set_readonly.call(this, readonly);
 this.but_select.prop('disabled', readonly);
 this.but_clear.prop('disabled', readonly);
 if (this.text) {
@@ -3966,6 +3974,7 @@
 }
 },
 set_readonly: function(readonly) {
+Sao.View.Form.Image._super.set_readonly.call(this, readonly);
 this.but_select.prop('disable', readonly);
 this.but_clear.prop('disable', readonly);
 },
@@ -4325,7 +4334,7 @@
 return false;
 },
 set_readonly: function(readonly) {
-this._readonly = readonly;
+Sao.View.Form.Dict._super.set_readonly.call(this, readonly);
 this._set_button_sensitive();
 for (var key in this.fields) {
 var widget = this.fields[key];



[tryton-commits] changeset in sao:5.0 Do not clear tree_states when loading ids

2021-05-06 Thread Cédric Krier
changeset a4b2234ca214 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=a4b2234ca214
description:
Do not clear tree_states when loading ids

The tree state must be set after loading ids but we can rely on the 
stored
state.

issue10366
review361811002
(grafted from 70649b570880ea83410d5c243a26b709e13bebbf)
diffstat:

 src/screen.js |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r e4c528f1c6b4 -r a4b2234ca214 src/screen.js
--- a/src/screen.js Thu Apr 22 00:07:18 2021 +0200
+++ b/src/screen.js Fri Apr 30 13:29:22 2021 +0200
@@ -1128,7 +1128,6 @@
 if (set_cursor === undefined) {
 set_cursor = true;
 }
-this.tree_states = {};
 this.tree_states_done = [];
 this.group.load(ids, modified);
 if (ids.length && this.current_view.view_type != 'calendar') {



[tryton-commits] changeset in sao:5.6 Do not clear tree_states when loading ids

2021-05-06 Thread Cédric Krier
changeset a3c189f9b3aa in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=a3c189f9b3aa
description:
Do not clear tree_states when loading ids

The tree state must be set after loading ids but we can rely on the 
stored
state.

issue10366
review361811002
(grafted from 70649b570880ea83410d5c243a26b709e13bebbf)
diffstat:

 src/screen.js |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r 74479c33d2ff -r a3c189f9b3aa src/screen.js
--- a/src/screen.js Thu Apr 22 00:07:18 2021 +0200
+++ b/src/screen.js Fri Apr 30 13:29:22 2021 +0200
@@ -1225,7 +1225,6 @@
 if (set_cursor === undefined) {
 set_cursor = true;
 }
-this.tree_states = {};
 this.tree_states_done = [];
 this.group.load(ids, modified);
 if (ids.length && this.current_view.view_type != 'calendar') {



[tryton-commits] changeset in sao:5.8 Do not clear tree_states when loading ids

2021-05-06 Thread Cédric Krier
changeset 4d64152e3bda in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=4d64152e3bda
description:
Do not clear tree_states when loading ids

The tree state must be set after loading ids but we can rely on the 
stored
state.

issue10366
review361811002
(grafted from 70649b570880ea83410d5c243a26b709e13bebbf)
diffstat:

 src/screen.js |  1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diffs (11 lines):

diff -r f11c3afc34f1 -r 4d64152e3bda src/screen.js
--- a/src/screen.js Thu Apr 22 00:07:18 2021 +0200
+++ b/src/screen.js Fri Apr 30 13:29:22 2021 +0200
@@ -1251,7 +1251,6 @@
 if (set_cursor === undefined) {
 set_cursor = true;
 }
-this.tree_states = {};
 this.tree_states_done = [];
 this.group.load(ids, modified);
 if (ids.length && this.current_view.view_type != 'calendar') {



[tryton-commits] changeset in sao:5.0 Use change value as initial value for Windo...

2021-05-06 Thread Cédric Krier
changeset e4c528f1c6b4 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=e4c528f1c6b4
description:
Use change value as initial value for Window Form

The parent field must stay as eval value as it is not reset.

issue10185
review365111002
(grafted from 58ef4f28588ea0bedf946a45efb553862e0a75a7)
diffstat:

 src/window.js |  10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (20 lines):

diff -r 880d9fa240f0 -r e4c528f1c6b4 src/window.js
--- a/src/window.js Thu Apr 22 00:05:24 2021 +0200
+++ b/src/window.js Thu Apr 22 00:07:18 2021 +0200
@@ -81,7 +81,15 @@
 button_text = Sao.i18n.gettext('Delete');
 } else {
 button_text = Sao.i18n.gettext('Cancel');
-this._initial_value = 
this.screen.current_record.get_eval();
+var record = this.screen.current_record;
+this._initial_value = record.get_on_change_value();
+if (record.group.parent &&
+record.model.fields[record.group.parent_name]) {
+var parent_field = record.model.fields[
+record.group.parent_name];
+this._initial_value[record.group.parent_name] = (
+parent_field.get_eval(record));
+}
 }
 
 dialog.footer.append(jQuery('', {



[tryton-commits] changeset in sao:5.6 Use change value as initial value for Windo...

2021-05-06 Thread Cédric Krier
changeset 74479c33d2ff in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=74479c33d2ff
description:
Use change value as initial value for Window Form

The parent field must stay as eval value as it is not reset.

issue10185
review365111002
(grafted from 58ef4f28588ea0bedf946a45efb553862e0a75a7)
diffstat:

 src/window.js |  10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (20 lines):

diff -r d3a273b93a1f -r 74479c33d2ff src/window.js
--- a/src/window.js Thu Apr 22 00:05:24 2021 +0200
+++ b/src/window.js Thu Apr 22 00:07:18 2021 +0200
@@ -81,7 +81,15 @@
 button_text = Sao.i18n.gettext('Delete');
 } else {
 button_text = Sao.i18n.gettext('Cancel');
-this._initial_value = 
this.screen.current_record.get_eval();
+var record = this.screen.current_record;
+this._initial_value = record.get_on_change_value();
+if (record.group.parent &&
+record.model.fields[record.group.parent_name]) {
+var parent_field = record.model.fields[
+record.group.parent_name];
+this._initial_value[record.group.parent_name] = (
+parent_field.get_eval(record));
+}
 }
 
 dialog.footer.append(jQuery('', {



[tryton-commits] changeset in sao:5.6 Display screen after reload on Window Form ...

2021-05-06 Thread Cédric Krier
changeset d3a273b93a1f in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=d3a273b93a1f
description:
Display screen after reload on Window Form cancel

The callback must also be called once every promises are resolved.

issue10304
review330771002
(grafted from bfc5dfdf1434f597ac44b0cba38207f32a0b069b)
diffstat:

 src/window.js |  6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r e8ab7339c478 -r d3a273b93a1f src/window.js
--- a/src/window.js Wed Apr 21 23:51:15 2021 +0200
+++ b/src/window.js Thu Apr 22 00:05:24 2021 +0200
@@ -411,7 +411,9 @@
 this._initial_value);
 } else if (record.has_changed()) {
 record.cancel();
-cancel_prm = record.reload();
+cancel_prm = record.reload().then(function() {
+this.screen.display();
+}.bind(this));
 }
 if (added) {
 record._changed.id = added;
@@ -419,7 +421,7 @@
 } else {
 result = response_id != 'RESPONSE_CANCEL';
 }
-(cancel_prm || jQuery.when()).done(function() {
+(cancel_prm || jQuery.when()).then(function() {
 this.callback(result);
 this.destroy();
 }.bind(this));



[tryton-commits] changeset in sao:5.8 Use change value as initial value for Windo...

2021-05-06 Thread Cédric Krier
changeset f11c3afc34f1 in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=f11c3afc34f1
description:
Use change value as initial value for Window Form

The parent field must stay as eval value as it is not reset.

issue10185
review365111002
(grafted from 58ef4f28588ea0bedf946a45efb553862e0a75a7)
diffstat:

 src/window.js |  10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diffs (20 lines):

diff -r 3881067c82c0 -r f11c3afc34f1 src/window.js
--- a/src/window.js Thu Apr 22 00:05:24 2021 +0200
+++ b/src/window.js Thu Apr 22 00:07:18 2021 +0200
@@ -131,7 +131,15 @@
 button_text = Sao.i18n.gettext('Delete');
 } else {
 button_text = Sao.i18n.gettext('Cancel');
-this._initial_value = 
this.screen.current_record.get_eval();
+var record = this.screen.current_record;
+this._initial_value = record.get_on_change_value();
+if (record.group.parent &&
+record.model.fields[record.group.parent_name]) {
+var parent_field = record.model.fields[
+record.group.parent_name];
+this._initial_value[record.group.parent_name] = (
+parent_field.get_eval(record));
+}
 }
 
 dialog.footer.append(jQuery('', {



[tryton-commits] changeset in sao:5.0 Display screen after reload on Window Form ...

2021-05-06 Thread Cédric Krier
changeset 880d9fa240f0 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=880d9fa240f0
description:
Display screen after reload on Window Form cancel

The callback must also be called once every promises are resolved.

issue10304
review330771002
(grafted from bfc5dfdf1434f597ac44b0cba38207f32a0b069b)
diffstat:

 src/window.js |  6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 688876084b37 -r 880d9fa240f0 src/window.js
--- a/src/window.js Sun Apr 18 17:52:45 2021 +0200
+++ b/src/window.js Thu Apr 22 00:05:24 2021 +0200
@@ -411,7 +411,9 @@
 this._initial_value);
 } else if (record.has_changed()) {
 record.cancel();
-cancel_prm = record.reload();
+cancel_prm = record.reload().then(function() {
+this.screen.display();
+}.bind(this));
 }
 if (added) {
 record._changed.id = added;
@@ -419,7 +421,7 @@
 } else {
 result = response_id != 'RESPONSE_CANCEL';
 }
-(cancel_prm || jQuery.when()).done(function() {
+(cancel_prm || jQuery.when()).then(function() {
 this.callback(result);
 this.destroy();
 }.bind(this));



[tryton-commits] changeset in sao:5.8 Use order definition of xxx2Many fields

2021-05-06 Thread Cédric Krier
changeset 805866f2cd51 in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=805866f2cd51
description:
Use order definition of xxx2Many fields

When empty it must be the order of the target and it must not be 
encoded as it
can not be PYSON.

issue10297
review349721004
(grafted from 17540249b098401bb4c294296c2b62b8015563fc)
diffstat:

 src/view.js |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (13 lines):

diff -r 17dd421deec8 -r 805866f2cd51 src/view.js
--- a/src/view.js   Sun Apr 18 17:52:45 2021 +0200
+++ b/src/view.js   Wed Apr 21 23:47:30 2021 +0200
@@ -144,7 +144,8 @@
 'relation_field', 'views', 'invisible', 'add_remove',
 'sort', 'context', 'size', 'filename', 'autocomplete',
 'translate', 'create', 'delete', 'selection_change_with',
-'schema_model', 'required'].forEach(function(name) {
+'schema_model', 'required', 'order',
+].forEach(function(name) {
 if ((name in field) && (!(name in node_attrs))) {
 node_attrs[name] = field[name];
 }



[tryton-commits] changeset in sao:5.8 Display screen after reload on Window Form ...

2021-05-06 Thread Cédric Krier
changeset 3881067c82c0 in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=3881067c82c0
description:
Display screen after reload on Window Form cancel

The callback must also be called once every promises are resolved.

issue10304
review330771002
(grafted from bfc5dfdf1434f597ac44b0cba38207f32a0b069b)
diffstat:

 src/window.js |  6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 416fc7392e87 -r 3881067c82c0 src/window.js
--- a/src/window.js Wed Apr 21 23:51:15 2021 +0200
+++ b/src/window.js Thu Apr 22 00:05:24 2021 +0200
@@ -462,7 +462,9 @@
 this._initial_value);
 } else if (record.has_changed()) {
 record.cancel();
-cancel_prm = record.reload();
+cancel_prm = record.reload().then(function() {
+this.screen.display();
+}.bind(this));
 }
 if (added) {
 record._changed.id = added;
@@ -470,7 +472,7 @@
 } else {
 result = response_id != 'RESPONSE_CANCEL';
 }
-(cancel_prm || jQuery.when()).done(function() {
+(cancel_prm || jQuery.when()).then(function() {
 this.callback(result);
 this.destroy();
 }.bind(this));



[tryton-commits] changeset in sao:5.6 Fall-back to default order to define new po...

2021-05-06 Thread Cédric Krier
changeset e8ab7339c478 in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=e8ab7339c478
description:
Fall-back to default order to define new position

When there is no order on the screen, we must use the default order 
because it
contains the order of the relation field.

issue10298
review340621002
(grafted from 8649ac63e0f2c7a6569cb5c31cb60e558527f50a)
diffstat:

 src/screen.js |  14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (24 lines):

diff -r 8f3d2f6969ff -r e8ab7339c478 src/screen.js
--- a/src/screen.js Wed Apr 21 23:47:30 2021 +0200
+++ b/src/screen.js Wed Apr 21 23:51:15 2021 +0200
@@ -1404,10 +1404,16 @@
 }.bind(this));
 },
 get new_position() {
-if (this.order) {
-for (var j = 0; j < this.order.length; j++) {
-var oexpr = this.order[j][0],
-otype = this.order[j][1];
+var order;
+if (this.order !== null) {
+order = this.order;
+} else {
+order = this.default_order;
+}
+if (order) {
+for (var j = 0; j < order.length; j++) {
+var oexpr = order[j][0],
+otype = order[j][1];
 if ((oexpr == 'id') && otype) {
 if (otype.startsWith('DESC')) {
 return 0;



[tryton-commits] changeset in sao:5.8 Fall-back to default order to define new po...

2021-05-06 Thread Cédric Krier
changeset 416fc7392e87 in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=416fc7392e87
description:
Fall-back to default order to define new position

When there is no order on the screen, we must use the default order 
because it
contains the order of the relation field.

issue10298
review340621002
(grafted from 8649ac63e0f2c7a6569cb5c31cb60e558527f50a)
diffstat:

 src/screen.js |  14 ++
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (24 lines):

diff -r 805866f2cd51 -r 416fc7392e87 src/screen.js
--- a/src/screen.js Wed Apr 21 23:47:30 2021 +0200
+++ b/src/screen.js Wed Apr 21 23:51:15 2021 +0200
@@ -1436,10 +1436,16 @@
 }.bind(this));
 },
 get new_position() {
-if (this.order) {
-for (var j = 0; j < this.order.length; j++) {
-var oexpr = this.order[j][0],
-otype = this.order[j][1];
+var order;
+if (this.order !== null) {
+order = this.order;
+} else {
+order = this.default_order;
+}
+if (order) {
+for (var j = 0; j < order.length; j++) {
+var oexpr = order[j][0],
+otype = order[j][1];
 if ((oexpr == 'id') && otype) {
 if (otype.startsWith('DESC')) {
 return 0;



[tryton-commits] changeset in sao:5.6 Use order definition of xxx2Many fields

2021-05-06 Thread Cédric Krier
changeset 8f3d2f6969ff in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=8f3d2f6969ff
description:
Use order definition of xxx2Many fields

When empty it must be the order of the target and it must not be 
encoded as it
can not be PYSON.

issue10297
review349721004
(grafted from 17540249b098401bb4c294296c2b62b8015563fc)
diffstat:

 src/view.js |  3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diffs (13 lines):

diff -r b074653fb030 -r 8f3d2f6969ff src/view.js
--- a/src/view.js   Sun Apr 18 17:52:45 2021 +0200
+++ b/src/view.js   Wed Apr 21 23:47:30 2021 +0200
@@ -144,7 +144,8 @@
 'relation_field', 'views', 'invisible', 'add_remove',
 'sort', 'context', 'size', 'filename', 'autocomplete',
 'translate', 'create', 'delete', 'selection_change_with',
-'schema_model', 'required'].forEach(function(name) {
+'schema_model', 'required', 'order',
+].forEach(function(name) {
 if ((name in field) && (!(name in node_attrs))) {
 node_attrs[name] = field[name];
 }



[tryton-commits] changeset in sao:5.0 Ceil microsecond

2021-05-06 Thread Cédric Krier
changeset 688876084b37 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=688876084b37
description:
Ceil microsecond

This is needed to always read the right history record.

issue10060
review340591002
(grafted from cb82c70d7090fdef4374e5a3d03e12e60bf0af5a)
diffstat:

 src/rpc.js |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r 23072f07207d -r 688876084b37 src/rpc.js
--- a/src/rpc.jsWed May 05 22:47:27 2021 +0200
+++ b/src/rpc.jsSun Apr 18 17:52:45 2021 +0200
@@ -142,7 +142,7 @@
value = Sao.DateTime(value.year,
value.month - 1, value.day, value.hour,
value.minute, value.second,
-   value.microsecond / 1000, true);
+   Math.ceil(value.microsecond / 1000), true);
break;
case 'date':
value = Sao.Date(value.year,
@@ -150,7 +150,7 @@
break;
case 'time':
value = Sao.Time(value.hour, value.minute,
-   value.second, value.microsecond / 1000);
+   value.second, Math.ceil(value.microsecond / 1000));
break;
 case 'timedelta':
value = Sao.TimeDelta(null, value.seconds);



[tryton-commits] changeset in sao:5.6 Ceil microsecond

2021-05-06 Thread Cédric Krier
changeset b074653fb030 in sao:5.6
details: https://hg.tryton.org/sao?cmd=changeset=b074653fb030
description:
Ceil microsecond

This is needed to always read the right history record.

issue10060
review340591002
(grafted from cb82c70d7090fdef4374e5a3d03e12e60bf0af5a)
diffstat:

 src/rpc.js |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r 1372129f8d3e -r b074653fb030 src/rpc.js
--- a/src/rpc.jsWed May 05 22:46:24 2021 +0200
+++ b/src/rpc.jsSun Apr 18 17:52:45 2021 +0200
@@ -181,7 +181,7 @@
value = Sao.DateTime(value.year,
value.month - 1, value.day, value.hour,
value.minute, value.second,
-   value.microsecond / 1000, true);
+   Math.ceil(value.microsecond / 1000), true);
break;
case 'date':
value = Sao.Date(value.year,
@@ -189,7 +189,7 @@
break;
case 'time':
value = Sao.Time(value.hour, value.minute,
-   value.second, value.microsecond / 1000);
+   value.second, Math.ceil(value.microsecond / 1000));
break;
 case 'timedelta':
value = Sao.TimeDelta(null, value.seconds);



[tryton-commits] changeset in sao:5.8 Ceil microsecond

2021-05-06 Thread Cédric Krier
changeset 17dd421deec8 in sao:5.8
details: https://hg.tryton.org/sao?cmd=changeset=17dd421deec8
description:
Ceil microsecond

This is needed to always read the right history record.

issue10060
review340591002
(grafted from cb82c70d7090fdef4374e5a3d03e12e60bf0af5a)
diffstat:

 src/rpc.js |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff -r a70d4a6ece62 -r 17dd421deec8 src/rpc.js
--- a/src/rpc.jsWed May 05 22:45:56 2021 +0200
+++ b/src/rpc.jsSun Apr 18 17:52:45 2021 +0200
@@ -181,7 +181,7 @@
value = Sao.DateTime(value.year,
value.month - 1, value.day, value.hour,
value.minute, value.second,
-   value.microsecond / 1000, true);
+   Math.ceil(value.microsecond / 1000), true);
break;
case 'date':
value = Sao.Date(value.year,
@@ -189,7 +189,7 @@
break;
case 'time':
value = Sao.Time(value.hour, value.minute,
-   value.second, value.microsecond / 1000);
+   value.second, Math.ceil(value.microsecond / 1000));
break;
 case 'timedelta':
value = Sao.TimeDelta(null, value.seconds);



[tryton-commits] changeset in proteus:6.0 Rename zip into postal_code

2021-05-06 Thread Cédric Krier
changeset 73d1d1f0490a in proteus:6.0
details: https://hg.tryton.org/proteus?cmd=changeset=73d1d1f0490a
description:
Rename zip into postal_code
(grafted from 4c2db8d802dd4d6615b958135d0176064f448ca7)
diffstat:

 doc/index.rst |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (24 lines):

diff -r 9d54b1468250 -r 73d1d1f0490a doc/index.rst
--- a/doc/index.rst Mon May 03 15:32:42 2021 +0200
+++ b/doc/index.rst Wed May 05 16:00:40 2021 +0200
@@ -67,7 +67,7 @@
 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(zip='42')
+>>> address = party.addresses.new(postal_code='42')
 >>> party.save()
 >>> party.addresses #doctest: +ELLIPSIS
 [proteus.Model.get('party.address')(...)]
@@ -108,9 +108,9 @@
 Addresses are ordered by sequence which means they can be stored following a
 specific order. The `set_sequence` method stores the current order.
 
->>> address = party.addresses.new(zip='69')
+>>> address = party.addresses.new(postal_code='69')
 >>> party.save()
->>> address = party.addresses.new(zip='23')
+>>> address = party.addresses.new(postal_code='23')
 >>> party.save()
 
 Now changing the order.



[tryton-commits] changeset in modules/stock_split:5.0 Always round remainder even...

2021-05-06 Thread Cédric Krier
changeset 4d1c8f8291ce in modules/stock_split:5.0
details: 
https://hg.tryton.org/modules/stock_split?cmd=changeset=4d1c8f8291ce
description:
Always round remainder even if it is less than quantity

issue10227
review338211002
(grafted from 9026b26fa55cc3a11b09df83516d3f3586fab587)
diffstat:

 stock.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r 369d8a399861 -r 4d1c8f8291ce stock.py
--- a/stock.py  Sat Apr 04 18:06:13 2020 +0200
+++ b/stock.py  Fri Apr 30 13:32:26 2021 +0200
@@ -62,9 +62,9 @@
 'uom': uom.id,
 }))
 remainder -= quantity
-remainder = uom.round(remainder)
 if count:
 count -= 1
+remainder = uom.round(remainder)
 assert remainder >= 0
 if remainder:
 with Transaction().set_context(_stock_move_split=True):



[tryton-commits] changeset in modules/stock_split:5.6 Always round remainder even...

2021-05-06 Thread Cédric Krier
changeset d16ac082679b in modules/stock_split:5.6
details: 
https://hg.tryton.org/modules/stock_split?cmd=changeset=d16ac082679b
description:
Always round remainder even if it is less than quantity

issue10227
review338211002
(grafted from 9026b26fa55cc3a11b09df83516d3f3586fab587)
diffstat:

 stock.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r f71210b8d7b7 -r d16ac082679b stock.py
--- a/stock.py  Fri Jan 01 17:18:03 2021 +0100
+++ b/stock.py  Fri Apr 30 13:32:26 2021 +0200
@@ -58,9 +58,9 @@
 'uom': uom.id,
 }))
 remainder -= quantity
-remainder = uom.round(remainder)
 if count:
 count -= 1
+remainder = uom.round(remainder)
 assert remainder >= 0
 if remainder:
 with Transaction().set_context(_stock_move_split=True):



[tryton-commits] changeset in modules/stock_split:5.8 Always round remainder even...

2021-05-06 Thread Cédric Krier
changeset 8ce2edfe786b in modules/stock_split:5.8
details: 
https://hg.tryton.org/modules/stock_split?cmd=changeset=8ce2edfe786b
description:
Always round remainder even if it is less than quantity

issue10227
review338211002
(grafted from 9026b26fa55cc3a11b09df83516d3f3586fab587)
diffstat:

 stock.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (14 lines):

diff -r b2abda207be9 -r 8ce2edfe786b stock.py
--- a/stock.py  Fri Jan 01 16:42:23 2021 +0100
+++ b/stock.py  Fri Apr 30 13:32:26 2021 +0200
@@ -58,9 +58,9 @@
 'uom': uom.id,
 }))
 remainder -= quantity
-remainder = uom.round(remainder)
 if count:
 count -= 1
+remainder = uom.round(remainder)
 assert remainder >= 0
 if remainder:
 with Transaction().set_context(_stock_move_split=True):



[tryton-commits] changeset in modules/stock_secondary_unit:5.6 Avoid recursion er...

2021-05-06 Thread Sergi Almacellas Abellana
changeset e233eecf9260 in modules/stock_secondary_unit:5.6
details: 
https://hg.tryton.org/modules/stock_secondary_unit?cmd=changeset=e233eecf9260
description:
Avoid recursion error when stock origin is set to itself

issue10205
review336071005
(grafted from 91987f6862830217d1298f390b888cb12cc2e85a)
diffstat:

 stock.py |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 41349615c3cc -r e233eecf9260 stock.py
--- a/stock.py  Fri Jan 01 17:17:43 2021 +0100
+++ b/stock.py  Mon Apr 26 13:07:54 2021 +0200
@@ -113,7 +113,7 @@
 if self.secondary_unit:
 # Stay valid even if origin has been deleted
 category = self.secondary_unit.category.id
-if isinstance(self.origin, self.__class__):
+if isinstance(self.origin, self.__class__) and self.origin != self:
 if self.origin.product_secondary_uom_category:
 category = self.origin.product_secondary_uom_category.id
 return category
@@ -124,12 +124,12 @@
 
 @property
 def secondary_uom_factor(self):
-if isinstance(self.origin, self.__class__):
+if isinstance(self.origin, self.__class__) and self.origin != self:
 return self.origin.secondary_uom_factor
 
 @property
 def secondary_uom_rate(self):
-if isinstance(self.origin, self.__class__):
+if isinstance(self.origin, self.__class__) and self.origin != self:
 return self.origin.secondary_uom_rate
 
 



[tryton-commits] changeset in modules/stock_secondary_unit:5.8 Avoid recursion er...

2021-05-06 Thread Sergi Almacellas Abellana
changeset ad239401b6eb in modules/stock_secondary_unit:5.8
details: 
https://hg.tryton.org/modules/stock_secondary_unit?cmd=changeset=ad239401b6eb
description:
Avoid recursion error when stock origin is set to itself

issue10205
review336071005
(grafted from 91987f6862830217d1298f390b888cb12cc2e85a)
diffstat:

 stock.py |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 5ce4b1f73cfe -r ad239401b6eb stock.py
--- a/stock.py  Fri Jan 01 16:42:02 2021 +0100
+++ b/stock.py  Mon Apr 26 13:07:54 2021 +0200
@@ -114,7 +114,7 @@
 if self.secondary_unit:
 # Stay valid even if origin has been deleted
 category = self.secondary_unit.category.id
-if isinstance(self.origin, self.__class__):
+if isinstance(self.origin, self.__class__) and self.origin != self:
 if self.origin.product_secondary_uom_category:
 category = self.origin.product_secondary_uom_category.id
 return category
@@ -125,12 +125,12 @@
 
 @property
 def secondary_uom_factor(self):
-if isinstance(self.origin, self.__class__):
+if isinstance(self.origin, self.__class__) and self.origin != self:
 return self.origin.secondary_uom_factor
 
 @property
 def secondary_uom_rate(self):
-if isinstance(self.origin, self.__class__):
+if isinstance(self.origin, self.__class__) and self.origin != self:
 return self.origin.secondary_uom_rate
 
 



[tryton-commits] changeset in modules/stock_quantity_issue:6.0 Add missing py39 t...

2021-05-06 Thread Cédric Krier
changeset 06a8656a7fb6 in modules/stock_quantity_issue:6.0
details: 
https://hg.tryton.org/modules/stock_quantity_issue?cmd=changeset=06a8656a7fb6
description:
Add missing py39 to tox
(grafted from a366ffeb51bdb24b05eca8103c1c96ea1385c7fc)
diffstat:

 tox.ini |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (16 lines):

diff -r 045d18ec70dd -r 06a8656a7fb6 tox.ini
--- a/tox.ini   Mon May 03 16:45:11 2021 +0200
+++ b/tox.ini   Wed May 05 12:03:03 2021 +0200
@@ -1,10 +1,10 @@
 [tox]
-envlist = {py36,py37,py38}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
+envlist = {py36,py37,py38,py39}-{sqlite,postgresql},pypy3-{sqlite,postgresql}
 
 [testenv]
 commands = {envpython} setup.py test
 deps =
-{py36,py37,py38}-postgresql: psycopg2 >= 2.5
+{py36,py37,py38,py39}-postgresql: psycopg2 >= 2.5
 pypy3-postgresql: psycopg2cffi >= 2.5
 py36-sqlite: sqlitebck
 setenv =



[tryton-commits] changeset in modules/stock_package_shipping_dpd:5.0 Save the mod...

2021-05-06 Thread Cédric Krier
changeset e3c9cc28a9ee in modules/stock_package_shipping_dpd:5.0
details: 
https://hg.tryton.org/modules/stock_package_shipping_dpd?cmd=changeset=e3c9cc28a9ee
description:
Save the modified packages

The root_packages on the shipment may be a new list of instances if 
meanwhile
the local cache of the shipment instance has been cleared by reaching 
its size
limit.

issue10319
review346001002
(grafted from 6a2de5c5109715d99c4dd36c28ec9753b08d5779)
diffstat:

 stock.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r d798b4fa35d1 -r e3c9cc28a9ee stock.py
--- a/stock.py  Fri Apr 16 19:10:27 2021 +0200
+++ b/stock.py  Fri Apr 23 20:32:00 2021 +0200
@@ -149,7 +149,7 @@
 for package, label, parcel in zip_longest(packages, labels, parcels):
 package.shipping_label = fields.Binary.cast(label.getvalue())
 package.shipping_reference = parcel.parcelLabelNumber
-Package.save(shipment.root_packages)
+Package.save(packages)
 shipment.save()
 
 return 'end'



[tryton-commits] changeset in modules/stock_package_shipping_dpd:5.6 Save the mod...

2021-05-06 Thread Cédric Krier
changeset 1d9dfc8c24c5 in modules/stock_package_shipping_dpd:5.6
details: 
https://hg.tryton.org/modules/stock_package_shipping_dpd?cmd=changeset=1d9dfc8c24c5
description:
Save the modified packages

The root_packages on the shipment may be a new list of instances if 
meanwhile
the local cache of the shipment instance has been cleared by reaching 
its size
limit.

issue10319
review346001002
(grafted from 6a2de5c5109715d99c4dd36c28ec9753b08d5779)
diffstat:

 stock.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 3584066a0e93 -r 1d9dfc8c24c5 stock.py
--- a/stock.py  Fri Apr 16 19:08:57 2021 +0200
+++ b/stock.py  Fri Apr 23 20:32:00 2021 +0200
@@ -138,7 +138,7 @@
 for package, label, parcel in zip_longest(packages, labels, parcels):
 package.shipping_label = fields.Binary.cast(label.getvalue())
 package.shipping_reference = parcel.parcelLabelNumber
-Package.save(shipment.root_packages)
+Package.save(packages)
 shipment.save()
 
 return 'end'



[tryton-commits] changeset in modules/stock_package_shipping_dpd:5.8 Save the mod...

2021-05-06 Thread Cédric Krier
changeset 4d54eb87455c in modules/stock_package_shipping_dpd:5.8
details: 
https://hg.tryton.org/modules/stock_package_shipping_dpd?cmd=changeset=4d54eb87455c
description:
Save the modified packages

The root_packages on the shipment may be a new list of instances if 
meanwhile
the local cache of the shipment instance has been cleared by reaching 
its size
limit.

issue10319
review346001002
(grafted from 6a2de5c5109715d99c4dd36c28ec9753b08d5779)
diffstat:

 stock.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 9797a3f3db5e -r 4d54eb87455c stock.py
--- a/stock.py  Fri Apr 16 19:08:18 2021 +0200
+++ b/stock.py  Fri Apr 23 20:32:00 2021 +0200
@@ -133,7 +133,7 @@
 for package, label, parcel in zip_longest(packages, labels, parcels):
 package.shipping_label = fields.Binary.cast(label.getvalue())
 package.shipping_reference = parcel.parcelLabelNumber
-Package.save(shipment.root_packages)
+Package.save(packages)
 shipment.save()
 
 return 'end'



[tryton-commits] changeset in modules/stock_package_shipping:5.0 Allow editing sh...

2021-05-06 Thread Cédric Krier
changeset 1a00972a45b6 in modules/stock_package_shipping:5.0
details: 
https://hg.tryton.org/modules/stock_package_shipping?cmd=changeset=1a00972a45b6
description:
Allow editing shipment reference

This is needed when we need to recreate the shipping if the carrier 
APIs did
not work correctly.

issue10310
review345991002
(grafted from 4882b62f21196c0ea7b8956176aa5ebaffd730aa)
diffstat:

 stock.py |  2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diffs (12 lines):

diff -r b65190efddfb -r 1a00972a45b6 stock.py
--- a/stock.py  Sat Apr 04 18:05:16 2020 +0200
+++ b/stock.py  Fri Apr 23 20:27:58 2021 +0200
@@ -117,8 +117,6 @@
 @classmethod
 def __setup__(cls):
 super(ShipmentOut, cls).__setup__()
-# The shipment reference will be set by the shipping service
-cls.reference.readonly = True
 cls._buttons.update({
 'create_shipping': {
 'invisible': (Eval('reference', False)



[tryton-commits] changeset in modules/stock_package_shipping:5.6 Allow editing sh...

2021-05-06 Thread Cédric Krier
changeset 0b962a3a2b3f in modules/stock_package_shipping:5.6
details: 
https://hg.tryton.org/modules/stock_package_shipping?cmd=changeset=0b962a3a2b3f
description:
Allow editing shipment reference

This is needed when we need to recreate the shipping if the carrier 
APIs did
not work correctly.

issue10310
review345991002
(grafted from 4882b62f21196c0ea7b8956176aa5ebaffd730aa)
diffstat:

 stock.py |  2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diffs (12 lines):

diff -r e8a07421fbe6 -r 0b962a3a2b3f stock.py
--- a/stock.py  Fri Jan 01 17:17:00 2021 +0100
+++ b/stock.py  Fri Apr 23 20:27:58 2021 +0200
@@ -119,8 +119,6 @@
 @classmethod
 def __setup__(cls):
 super(ShipmentOut, cls).__setup__()
-# The shipment reference will be set by the shipping service
-cls.reference.readonly = True
 cls._buttons.update({
 'create_shipping': {
 'invisible': (Eval('reference', False)



[tryton-commits] changeset in modules/stock_package_shipping:5.8 Allow editing sh...

2021-05-06 Thread Cédric Krier
changeset 6597a2e712fe in modules/stock_package_shipping:5.8
details: 
https://hg.tryton.org/modules/stock_package_shipping?cmd=changeset=6597a2e712fe
description:
Allow editing shipment reference

This is needed when we need to recreate the shipping if the carrier 
APIs did
not work correctly.

issue10310
review345991002
(grafted from 4882b62f21196c0ea7b8956176aa5ebaffd730aa)
diffstat:

 stock.py |  2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diffs (12 lines):

diff -r 4478ae1fd149 -r 6597a2e712fe stock.py
--- a/stock.py  Fri Jan 01 16:41:19 2021 +0100
+++ b/stock.py  Fri Apr 23 20:27:58 2021 +0200
@@ -119,8 +119,6 @@
 @classmethod
 def __setup__(cls):
 super(ShipmentOut, cls).__setup__()
-# The shipment reference will be set by the shipping service
-cls.reference.readonly = True
 cls._buttons.update({
 'create_shipping': {
 'invisible': (Eval('reference', False)



[tryton-commits] changeset in modules/purchase_secondary_unit:5.6 Invert factor a...

2021-05-06 Thread Maxime Richez
changeset 27feeb1372f9 in modules/purchase_secondary_unit:5.6
details: 
https://hg.tryton.org/modules/purchase_secondary_unit?cmd=changeset=27feeb1372f9
description:
Invert factor and rate to compute request quantity

issue10311
review361721003
(grafted from 4781a923d45ef6d90c61e3be9194123e98c1c7a9)
diffstat:

 purchase.py |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (13 lines):

diff -r 41dcc5b88150 -r 27feeb1372f9 purchase.py
--- a/purchase.py   Fri Jan 01 17:10:14 2021 +0100
+++ b/purchase.py   Tue Apr 20 01:11:16 2021 +0200
@@ -218,7 +218,7 @@
 Uom.compute_qty(
 request.uom, request.quantity,
 product.purchase_uom, round=True,
-factor=product.purchase_secondary_uom_normal_factor,
-rate=product.purchase_secondary_uom_normal_rate),
+factor=product.purchase_secondary_uom_normal_rate,
+rate=product.purchase_secondary_uom_normal_factor),
 product.purchase_uom)
 return request



[tryton-commits] changeset in modules/purchase_secondary_unit:5.8 Invert factor a...

2021-05-06 Thread Maxime Richez
changeset c57ae08c846b in modules/purchase_secondary_unit:5.8
details: 
https://hg.tryton.org/modules/purchase_secondary_unit?cmd=changeset=c57ae08c846b
description:
Invert factor and rate to compute request quantity

issue10311
review361721003
(grafted from 4781a923d45ef6d90c61e3be9194123e98c1c7a9)
diffstat:

 purchase.py |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (13 lines):

diff -r 77569a96b0d5 -r c57ae08c846b purchase.py
--- a/purchase.py   Fri Jan 01 16:34:15 2021 +0100
+++ b/purchase.py   Tue Apr 20 01:11:16 2021 +0200
@@ -218,7 +218,7 @@
 Uom.compute_qty(
 request.uom, request.quantity,
 product.purchase_uom, round=True,
-factor=product.purchase_secondary_uom_normal_factor,
-rate=product.purchase_secondary_uom_normal_rate),
+factor=product.purchase_secondary_uom_normal_rate,
+rate=product.purchase_secondary_uom_normal_factor),
 product.purchase_uom)
 return request



[tryton-commits] changeset in modules/purchase_requisition:5.8 Test if currency i...

2021-05-06 Thread Maxime Richez
changeset 9eceb4507450 in modules/purchase_requisition:5.8
details: 
https://hg.tryton.org/modules/purchase_requisition?cmd=changeset=9eceb4507450
description:
Test if currency is filled on request to return id for line

issue10321
review359541002
(grafted from 93df69e6fcf28057526e7f39786b02158a1530fc)
diffstat:

 purchase.py |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff -r 6deb4391379e -r 9eceb4507450 purchase.py
--- a/purchase.py   Fri Apr 16 19:27:07 2021 +0200
+++ b/purchase.py   Thu Apr 22 23:54:20 2021 +0200
@@ -513,7 +513,7 @@
 
 @fields.depends('requisition', '_parent_requisition.currency')
 def on_change_with_currency(self, name=None):
-if self.requisition:
+if self.requisition and self.requisition.currency:
 return self.requisition.currency.id
 
 @classmethod



[tryton-commits] changeset in modules/purchase_request_quotation:5.0 Include all ...

2021-05-06 Thread Sergi Almacellas Abellana
changeset 1398635001e7 in modules/purchase_request_quotation:5.0
details: 
https://hg.tryton.org/modules/purchase_request_quotation?cmd=changeset=1398635001e7
description:
Include all requests in update_state call

issue10270
review330871002
(grafted from 6276a9d95fb0af4ec08a402778683e7a24bdc356)
diffstat:

 purchase.py |  10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r b8b7114b58b0 -r 1398635001e7 purchase.py
--- a/purchase.py   Fri Apr 02 22:02:35 2021 +0200
+++ b/purchase.py   Mon Apr 26 13:06:26 2021 +0200
@@ -519,13 +519,15 @@
 
 requests = Request.browse(Transaction().context['active_ids'])
 
-reqs = [r for r in requests if r.state in ['draft', 'quotation']]
+requests = [
+r for r in requests if r.state in ['draft', 'quotation']]
 for supplier in self.ask_suppliers.suppliers:
 quotation = Quotation()
 quotation.supplier = supplier
 quotation.supplier_address = supplier.address_get()
-reqs = [r for r in reqs if self.filter_request(r, supplier)]
-sorted_reqs = sorted(reqs, key=lambda r: r.company)
+sub_requests = [
+r for r in requests if self.filter_request(r, supplier)]
+sorted_reqs = sorted(sub_requests, key=lambda r: r.company)
 for key, grouped_requests in groupby(sorted_reqs,
 key=self._group_request_key):
 for f, v in key:
@@ -538,7 +540,7 @@
 QuotationLine.save(lines)
 Quotation.save(quotations)
 
-Request.update_state(reqs)
+Request.update_state(requests)
 self.succeed.number_quotations = len(quotations)
 return 'succeed'
 



[tryton-commits] changeset in modules/purchase_request_quotation:5.6 Include all ...

2021-05-06 Thread Sergi Almacellas Abellana
changeset ca618b343fde in modules/purchase_request_quotation:5.6
details: 
https://hg.tryton.org/modules/purchase_request_quotation?cmd=changeset=ca618b343fde
description:
Include all requests in update_state call

issue10270
review330871002
(grafted from 6276a9d95fb0af4ec08a402778683e7a24bdc356)
diffstat:

 purchase.py |  10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (31 lines):

diff -r 3d0743cf27e5 -r ca618b343fde purchase.py
--- a/purchase.py   Fri Apr 02 22:02:10 2021 +0200
+++ b/purchase.py   Mon Apr 26 13:06:26 2021 +0200
@@ -508,13 +508,15 @@
 
 requests = Request.browse(Transaction().context['active_ids'])
 
-reqs = [r for r in requests if r.state in ['draft', 'quotation']]
+requests = [
+r for r in requests if r.state in ['draft', 'quotation']]
 for supplier in self.ask_suppliers.suppliers:
 quotation = Quotation()
 quotation.supplier = supplier
 quotation.supplier_address = supplier.address_get()
-reqs = [r for r in reqs if self.filter_request(r, supplier)]
-sorted_reqs = sorted(reqs, key=lambda r: r.company)
+sub_requests = [
+r for r in requests if self.filter_request(r, supplier)]
+sorted_reqs = sorted(sub_requests, key=lambda r: r.company)
 for key, grouped_requests in groupby(sorted_reqs,
 key=self._group_request_key):
 for f, v in key:
@@ -527,7 +529,7 @@
 QuotationLine.save(lines)
 Quotation.save(quotations)
 
-Request.update_state(reqs)
+Request.update_state(requests)
 self.succeed.number_quotations = len(quotations)
 return 'succeed'
 



[tryton-commits] changeset in modules/purchase_request_quotation:5.8 Include all ...

2021-05-06 Thread Sergi Almacellas Abellana
changeset 476fed669840 in modules/purchase_request_quotation:5.8
details: 
https://hg.tryton.org/modules/purchase_request_quotation?cmd=changeset=476fed669840
description:
Include all requests in update_state call

issue10270
review330871002
(grafted from 6276a9d95fb0af4ec08a402778683e7a24bdc356)
diffstat:

 purchase.py |  10 ++
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r a99138fe00fd -r 476fed669840 purchase.py
--- a/purchase.py   Sun Apr 25 11:25:31 2021 +0200
+++ b/purchase.py   Mon Apr 26 13:06:26 2021 +0200
@@ -499,14 +499,16 @@
 quotations = []
 lines = []
 
-reqs = [r for r in self.records if r.state in ['draft', 'quotation']]
+requests = [
+r for r in self.records if r.state in ['draft', 'quotation']]
 for supplier in self.ask_suppliers.suppliers:
 quotation = Quotation()
 quotation.supplier = supplier
 quotation.supplier_address = supplier.address_get()
-reqs = [r for r in reqs if self.filter_request(r, supplier)]
+sub_requests = [
+r for r in requests if self.filter_request(r, supplier)]
 sorted_reqs = sorted(
-reqs, key=sortable_values(self._group_request_key))
+sub_requests, key=sortable_values(self._group_request_key))
 for key, grouped_requests in groupby(sorted_reqs,
 key=self._group_request_key):
 for f, v in key:
@@ -519,7 +521,7 @@
 QuotationLine.save(lines)
 Quotation.save(quotations)
 
-self.model.update_state(reqs)
+self.model.update_state(requests)
 self.succeed.number_quotations = len(quotations)
 return 'succeed'
 



[tryton-commits] changeset in modules/purchase_request_quotation:5.8 Sort request...

2021-05-06 Thread Sergi Almacellas Abellana
changeset a99138fe00fd in modules/purchase_request_quotation:5.8
details: 
https://hg.tryton.org/modules/purchase_request_quotation?cmd=changeset=a99138fe00fd
description:
Sort requests using the same key as group by

issue10341
review357951002
(grafted from e2a0eacd020ef13ff577f4afb9c3a2ec78fccf5c)
diffstat:

 purchase.py |  4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diffs (21 lines):

diff -r d5df1880f770 -r a99138fe00fd purchase.py
--- a/purchase.py   Fri Apr 02 22:01:45 2021 +0200
+++ b/purchase.py   Sun Apr 25 11:25:31 2021 +0200
@@ -11,6 +11,7 @@
 from trytond.modules.product import price_digits
 from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Eval, Bool, If
+from trytond.tools import sortable_values
 from trytond.transaction import Transaction
 from trytond.wizard import Wizard, StateView, StateTransition, Button
 
@@ -504,7 +505,8 @@
 quotation.supplier = supplier
 quotation.supplier_address = supplier.address_get()
 reqs = [r for r in reqs if self.filter_request(r, supplier)]
-sorted_reqs = sorted(reqs, key=lambda r: r.company)
+sorted_reqs = sorted(
+reqs, key=sortable_values(self._group_request_key))
 for key, grouped_requests in groupby(sorted_reqs,
 key=self._group_request_key):
 for f, v in key:



[tryton-commits] changeset in modules/party:5.0 Use AND-ed clause when searching ...

2021-05-06 Thread Cédric Krier
changeset d83394404044 in modules/party:5.0
details: https://hg.tryton.org/modules/party?cmd=changeset=d83394404044
description:
Use AND-ed clause when searching contact mechanism with negate operator

issue10309
review334201002
(grafted from 04d89a6a8e573612c0d3c3355365175f3adc22ee)
diffstat:

 contact_mechanism.py |  6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (16 lines):

diff -r 7f4a292e6242 -r d83394404044 contact_mechanism.py
--- a/contact_mechanism.py  Sat Apr 04 17:54:29 2020 +0200
+++ b/contact_mechanism.py  Thu Apr 22 23:50:08 2021 +0200
@@ -197,7 +197,11 @@
 
 @classmethod
 def search_rec_name(cls, name, clause):
-return ['OR',
+if clause[1].startswith('!') or clause[1].startswith('not '):
+bool_op = 'AND'
+else:
+bool_op = 'OR'
+return [bool_op,
 ('value',) + tuple(clause[1:]),
 ('value_compact',) + tuple(clause[1:]),
 ]



[tryton-commits] changeset in modules/party:5.6 Use AND-ed clause when searching ...

2021-05-06 Thread Cédric Krier
changeset 6b123130d402 in modules/party:5.6
details: https://hg.tryton.org/modules/party?cmd=changeset=6b123130d402
description:
Use AND-ed clause when searching contact mechanism with negate operator

issue10309
review334201002
(grafted from 04d89a6a8e573612c0d3c3355365175f3adc22ee)
diffstat:

 contact_mechanism.py |  6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (16 lines):

diff -r 9c337cff813d -r 6b123130d402 contact_mechanism.py
--- a/contact_mechanism.py  Fri Jan 01 17:04:32 2021 +0100
+++ b/contact_mechanism.py  Thu Apr 22 23:50:08 2021 +0200
@@ -202,7 +202,11 @@
 
 @classmethod
 def search_rec_name(cls, name, clause):
-return ['OR',
+if clause[1].startswith('!') or clause[1].startswith('not '):
+bool_op = 'AND'
+else:
+bool_op = 'OR'
+return [bool_op,
 ('value',) + tuple(clause[1:]),
 ('value_compact',) + tuple(clause[1:]),
 ]



[tryton-commits] changeset in modules/party:5.8 Use AND-ed clause when searching ...

2021-05-06 Thread Cédric Krier
changeset 4f0c3dd1a91d in modules/party:5.8
details: https://hg.tryton.org/modules/party?cmd=changeset=4f0c3dd1a91d
description:
Use AND-ed clause when searching contact mechanism with negate operator

issue10309
review334201002
(grafted from 04d89a6a8e573612c0d3c3355365175f3adc22ee)
diffstat:

 contact_mechanism.py |  6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (16 lines):

diff -r eeb70c2aa705 -r 4f0c3dd1a91d contact_mechanism.py
--- a/contact_mechanism.py  Fri Jan 01 16:28:47 2021 +0100
+++ b/contact_mechanism.py  Thu Apr 22 23:50:08 2021 +0200
@@ -202,7 +202,11 @@
 
 @classmethod
 def search_rec_name(cls, name, clause):
-return ['OR',
+if clause[1].startswith('!') or clause[1].startswith('not '):
+bool_op = 'AND'
+else:
+bool_op = 'OR'
+return [bool_op,
 ('value',) + tuple(clause[1:]),
 ('value_compact',) + tuple(clause[1:]),
 ]



  1   2   >