[tryton-commits] changeset in tryton:5.0 Do not filter selection for multiselecti...

2022-11-14 Thread Nicolas Évrard
changeset 58ab04ddf2d0 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=58ab04ddf2d0
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from 88bbfbf90edf44c2740c33218212b8d053768e09)
diffstat:

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

diffs (17 lines):

diff -r 97bbe23ef811 -r 58ab04ddf2d0 tryton/common/selection.py
--- a/tryton/common/selection.pySat Nov 12 10:14:17 2022 +0100
+++ b/tryton/common/selection.pyTue Nov 08 21:54:01 2022 +0100
@@ -97,9 +97,12 @@
 return value[0] in allowed_models or not allowed_models
 return test
 
-if field.attrs['type'] == 'reference':
+type_ = field.attrs['type']
+if type_ == 'reference':
 allowed_models = field.get_models(record)
 evaluator = _model_evaluator(allowed_models)
+elif type_ == 'multiselection':
+return
 else:
 evaluator = _value_evaluator
 self.selection = list(filter(evaluator, self.selection))



[tryton-commits] changeset in tryton:6.0 Do not filter selection for multiselecti...

2022-11-14 Thread Nicolas Évrard
changeset 4a853cd9f7a0 in tryton:6.0
details: https://hg.tryton.org/tryton?cmd=changeset=4a853cd9f7a0
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from 88bbfbf90edf44c2740c33218212b8d053768e09)
diffstat:

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

diffs (17 lines):

diff -r 20ffc82079c5 -r 4a853cd9f7a0 tryton/common/selection.py
--- a/tryton/common/selection.pySat Nov 05 17:12:09 2022 +0100
+++ b/tryton/common/selection.pyTue Nov 08 21:54:01 2022 +0100
@@ -107,9 +107,12 @@
 return value[0] in allowed_models or not allowed_models
 return test
 
-if field.attrs['type'] == 'reference':
+type_ = field.attrs['type']
+if type_ == 'reference':
 allowed_models = field.get_models(record)
 evaluator = _model_evaluator(allowed_models)
+elif type_ == 'multiselection':
+return
 else:
 evaluator = _value_evaluator
 self.selection = list(filter(evaluator, self.selection))



[tryton-commits] changeset in tryton:6.2 Do not filter selection for multiselecti...

2022-11-14 Thread Nicolas Évrard
changeset b530fd28a51b in tryton:6.2
details: https://hg.tryton.org/tryton?cmd=changeset=b530fd28a51b
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from 88bbfbf90edf44c2740c33218212b8d053768e09)
diffstat:

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

diffs (17 lines):

diff -r af77a8c0977c -r b530fd28a51b tryton/common/selection.py
--- a/tryton/common/selection.pySat Nov 05 09:51:17 2022 +0100
+++ b/tryton/common/selection.pyTue Nov 08 21:54:01 2022 +0100
@@ -107,9 +107,12 @@
 return value[0] in allowed_models or not allowed_models
 return test
 
-if field.attrs['type'] == 'reference':
+type_ = field.attrs['type']
+if type_ == 'reference':
 allowed_models = field.get_models(record)
 evaluator = _model_evaluator(allowed_models)
+elif type_ == 'multiselection':
+return
 else:
 evaluator = _value_evaluator
 self.selection = list(filter(evaluator, self.selection))



[tryton-commits] changeset in tryton:6.4 Do not filter selection for multiselecti...

2022-11-14 Thread Nicolas Évrard
changeset f0353c800752 in tryton:6.4
details: https://hg.tryton.org/tryton?cmd=changeset=f0353c800752
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from 88bbfbf90edf44c2740c33218212b8d053768e09)
diffstat:

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

diffs (17 lines):

diff -r af74555e13bd -r f0353c800752 tryton/common/selection.py
--- a/tryton/common/selection.pySat Nov 05 09:51:17 2022 +0100
+++ b/tryton/common/selection.pyTue Nov 08 21:54:01 2022 +0100
@@ -106,9 +106,12 @@
 return value[0] in allowed_models or not allowed_models
 return test
 
-if field.attrs['type'] == 'reference':
+type_ = field.attrs['type']
+if type_ == 'reference':
 allowed_models = field.get_models(record)
 evaluator = _model_evaluator(allowed_models)
+elif type_ == 'multiselection':
+return
 else:
 evaluator = _value_evaluator
 self.selection = list(filter(evaluator, self.selection))



[tryton-commits] changeset in tryton:6.6 Do not filter selection for multiselecti...

2022-11-14 Thread Nicolas Évrard
changeset b7d3e9322184 in tryton:6.6
details: https://hg.tryton.org/tryton?cmd=changeset=b7d3e9322184
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from 88bbfbf90edf44c2740c33218212b8d053768e09)
diffstat:

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

diffs (17 lines):

diff -r 5d5d5f14c4b4 -r b7d3e9322184 tryton/common/selection.py
--- a/tryton/common/selection.pySat Nov 05 09:51:17 2022 +0100
+++ b/tryton/common/selection.pyTue Nov 08 21:54:01 2022 +0100
@@ -106,9 +106,12 @@
 return value[0] in allowed_models or not allowed_models
 return test
 
-if field.attrs['type'] == 'reference':
+type_ = field.attrs['type']
+if type_ == 'reference':
 allowed_models = field.get_models(record)
 evaluator = _model_evaluator(allowed_models)
+elif type_ == 'multiselection':
+return
 else:
 evaluator = _value_evaluator
 self.selection = list(filter(evaluator, self.selection))



[tryton-commits] changeset in sao:5.0 Do not filter selection for multiselection ...

2022-11-14 Thread Nicolas Évrard
changeset 49903770e507 in sao:5.0
details: https://hg.tryton.org/sao?cmd=changeset=49903770e507
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from fc7cf7156c3c07599e7152c242c27ad5f233175a)
diffstat:

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

diffs (17 lines):

diff -r 7bfb591ee0a8 -r 49903770e507 src/common.js
--- a/src/common.js Sat Nov 05 17:14:27 2022 +0100
+++ b/src/common.js Tue Nov 08 21:54:01 2022 +0100
@@ -730,9 +730,12 @@
 };
 
 var evaluator;
-if (field.description.type == 'reference') {
+var type_ = field.description.type;
+if (type_ == 'reference') {
 var allowed_models = field.get_models(record);
 evaluator = _model_evaluator(allowed_models);
+} else if (type_ == 'multiselection') {
+return;
 } else {
 evaluator = _value_evaluator;
 }



[tryton-commits] changeset in sao:6.0 Do not filter selection for multiselection ...

2022-11-14 Thread Nicolas Évrard
changeset ca9208f62f1b in sao:6.0
details: https://hg.tryton.org/sao?cmd=changeset=ca9208f62f1b
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from fc7cf7156c3c07599e7152c242c27ad5f233175a)
diffstat:

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

diffs (17 lines):

diff -r d126d5ec -r ca9208f62f1b src/common.js
--- a/src/common.js Sat Nov 05 17:14:05 2022 +0100
+++ b/src/common.js Tue Nov 08 21:54:01 2022 +0100
@@ -778,9 +778,12 @@
 };
 
 var evaluator;
-if (field.description.type == 'reference') {
+var type_ = field.description.type;
+if (type_ == 'reference') {
 var allowed_models = field.get_models(record);
 evaluator = _model_evaluator(allowed_models);
+} else if (type_ == 'multiselection') {
+return;
 } else {
 evaluator = _value_evaluator;
 }



[tryton-commits] changeset in sao:6.2 Do not filter selection for multiselection ...

2022-11-14 Thread Nicolas Évrard
changeset d6d91e76df77 in sao:6.2
details: https://hg.tryton.org/sao?cmd=changeset=d6d91e76df77
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from fc7cf7156c3c07599e7152c242c27ad5f233175a)
diffstat:

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

diffs (17 lines):

diff -r 09aae59e7675 -r d6d91e76df77 src/common.js
--- a/src/common.js Sat Nov 05 17:13:35 2022 +0100
+++ b/src/common.js Tue Nov 08 21:54:01 2022 +0100
@@ -805,9 +805,12 @@
 };
 
 var evaluator;
-if (field.description.type == 'reference') {
+var type_ = field.description.type;
+if (type_ == 'reference') {
 var allowed_models = field.get_models(record);
 evaluator = _model_evaluator(allowed_models);
+} else if (type_ == 'multiselection') {
+return;
 } else {
 evaluator = _value_evaluator;
 }



[tryton-commits] changeset in sao:6.4 Do not filter selection for multiselection ...

2022-11-14 Thread Nicolas Évrard
changeset 5c4d5f9b9774 in sao:6.4
details: https://hg.tryton.org/sao?cmd=changeset=5c4d5f9b9774
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from fc7cf7156c3c07599e7152c242c27ad5f233175a)
diffstat:

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

diffs (17 lines):

diff -r 744cabb6df61 -r 5c4d5f9b9774 src/common.js
--- a/src/common.js Sat Nov 05 17:13:07 2022 +0100
+++ b/src/common.js Tue Nov 08 21:54:01 2022 +0100
@@ -829,9 +829,12 @@
 };
 
 var evaluator;
-if (field.description.type == 'reference') {
+var type_ = field.description.type;
+if (type_ == 'reference') {
 var allowed_models = field.get_models(record);
 evaluator = _model_evaluator(allowed_models);
+} else if (type_ == 'multiselection') {
+return;
 } else {
 evaluator = _value_evaluator;
 }



[tryton-commits] changeset in sao:6.6 Do not filter selection for multiselection ...

2022-11-14 Thread Nicolas Évrard
changeset 7ab28d5aaa8c in sao:6.6
details: https://hg.tryton.org/sao?cmd=changeset=7ab28d5aaa8c
description:
Do not filter selection for multiselection fields

issue11857
review437551003
(grafted from fc7cf7156c3c07599e7152c242c27ad5f233175a)
diffstat:

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

diffs (17 lines):

diff -r 1b8985b3253e -r 7ab28d5aaa8c src/common.js
--- a/src/common.js Mon Oct 31 16:40:12 2022 +0100
+++ b/src/common.js Tue Nov 08 21:54:01 2022 +0100
@@ -829,9 +829,12 @@
 };
 
 var evaluator;
-if (field.description.type == 'reference') {
+var type_ = field.description.type;
+if (type_ == 'reference') {
 var allowed_models = field.get_models(record);
 evaluator = _model_evaluator(allowed_models);
+} else if (type_ == 'multiselection') {
+return;
 } else {
 evaluator = _value_evaluator;
 }



[tryton-commits] changeset in tryton:default Do not filter selection for multisel...

2022-11-08 Thread Nicolas Évrard
changeset 88bbfbf90edf in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=88bbfbf90edf
description:
Do not filter selection for multiselection fields

issue11857
review437551003
diffstat:

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

diffs (17 lines):

diff -r b048eaced523 -r 88bbfbf90edf tryton/common/selection.py
--- a/tryton/common/selection.pySat Nov 05 09:59:44 2022 +0100
+++ b/tryton/common/selection.pyTue Nov 08 21:54:01 2022 +0100
@@ -106,9 +106,12 @@
 return value[0] in allowed_models or not allowed_models
 return test
 
-if field.attrs['type'] == 'reference':
+type_ = field.attrs['type']
+if type_ == 'reference':
 allowed_models = field.get_models(record)
 evaluator = _model_evaluator(allowed_models)
+elif type_ == 'multiselection':
+return
 else:
 evaluator = _value_evaluator
 self.selection = list(filter(evaluator, self.selection))



[tryton-commits] changeset in sao:default Do not filter selection for multiselect...

2022-11-08 Thread Nicolas Évrard
changeset fc7cf7156c3c in sao:default
details: https://hg.tryton.org/sao?cmd=changeset=fc7cf7156c3c
description:
Do not filter selection for multiselection fields

issue11857
review437551003
diffstat:

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

diffs (17 lines):

diff -r 95d91b89bc0e -r fc7cf7156c3c src/common.js
--- a/src/common.js Sat Nov 05 09:59:44 2022 +0100
+++ b/src/common.js Tue Nov 08 21:54:01 2022 +0100
@@ -829,9 +829,12 @@
 };
 
 var evaluator;
-if (field.description.type == 'reference') {
+var type_ = field.description.type;
+if (type_ == 'reference') {
 var allowed_models = field.get_models(record);
 evaluator = _model_evaluator(allowed_models);
+} else if (type_ == 'multiselection') {
+return;
 } else {
 evaluator = _value_evaluator;
 }



[tryton-commits] changeset in modules/account_payment_sepa:5.0 Handle multiple tr...

2022-10-12 Thread Nicolas Évrard
changeset c407830443b8 in modules/account_payment_sepa:5.0
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset=c407830443b8
description:
Handle multiple transactions in CAMT054 Ntry tags

issue11672
review413471003
(grafted from fc8e9d9cb870d9353ff374120688b8e9779b90c0)
diffstat:

 sepa_handler.py |  84 +---
 1 files changed, 44 insertions(+), 40 deletions(-)

diffs (122 lines):

diff -r 737c1376ef6e -r c407830443b8 sepa_handler.py
--- a/sepa_handler.py   Fri Oct 15 17:28:08 2021 +0200
+++ b/sepa_handler.py   Mon Oct 03 00:13:39 2022 +0200
@@ -35,48 +35,59 @@
 element.clear()
 
 def handle_entry(self, element):
-payments = self.get_payments(element)
-if self.is_returned(element):
-for payment in payments:
-self.set_return_information(payment, element)
-self.Payment.save(payments)
-self.Payment.fail(payments)
-else:
-date_value = self.date_value(element)
+tag = etree.QName(element)
+failed, succeeded = [], []
+date_value = self.date_value(element)
+
+for transaction in element.findall('.//{%s}TxDtls' % tag.namespace):
+payments = self.get_payments(transaction)
+if self.is_returned(transaction):
+for payment in payments:
+self.set_return_information(payment, transaction)
+failed.extend(payments)
+else:
+succeeded.extend(payments)
+
+if failed:
+self.Payment.save(failed)
+self.Payment.fail(failed)
+if succeeded:
 with Transaction().set_context(date_value=date_value):
-self.Payment.succeed(payments)
+self.Payment.succeed(succeeded)
 
 def get_payment_kind(self, element):
-tag = etree.QName(element)
-return self._kinds[
-element.find('./{%s}CdtDbtInd' % tag.namespace).text]
+camt_ns = etree.QName(element).namespace
+for path in [
+'./camt:CdtDbtInd',
+'./ancestor::camt:NtryDtls/camt:Btch/camt:CdtDbtInd',
+'./ancestor::camt:Ntry/camt:CdtDbtInd',
+]:
+cdtdbtind = element.xpath(path, namespaces={'camt': camt_ns})
+if cdtdbtind:
+return self._kinds[cdtdbtind[0].text]
 _kinds = {
 'CRDT': 'payable',
 'DBIT': 'receivable',
 }
 
-def get_payments(self, element):
-tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-# Version 1 doesn't have NtryDtls but directly TxDtls
-details = element.find('./{%s}TxDtls' % tag.namespace)
-if details is None:
-return []
-instr_id = details.find('.//{%s}InstrId' % tag.namespace)
+def get_payments(self, transaction):
+tag = etree.QName(transaction)
+instr_id = transaction.find(
+'.//{%s}InstrId' % tag.namespace)
+end_to_end_id = transaction.find(
+'.//{%s}EndToEndId' % tag.namespace)
+payment_kind = self.get_payment_kind(transaction)
 if instr_id is not None:
-payments = self.Payment.search([
+return self.Payment.search([
 ('sepa_instruction_id', '=', instr_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
-end_to_end_id = details.find('.//{%s}EndToEndId' % tag.namespace)
-if end_to_end_id is not None:
-payments = self.Payment.search([
+elif end_to_end_id is not None:
+return self.Payment.search([
 ('sepa_end_to_end_id', '=', end_to_end_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
+return []
 
 def date_value(self, element):
 tag = etree.QName(element)
@@ -92,25 +103,18 @@
 
 def is_returned(self, element):
 tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-return
-return_reason = details.find('.//{%s}RtrInf' % tag.namespace)
-if return_reason is None:
-return False
-return True
+return_reason = element.find('.//{%s}RtrInf' % tag.namespace)
+return return_reason is not None
 
 def set_return_information(self, payment, element):
 tag = etree.QName(element)
 
 reason_code = element.find(
-'./{%(ns)s}NtryDtls//{%(ns)s}RtrInf/{%(ns)s}Rsn/{%(ns)s}Cd'
-% {'ns': tag.namespace})
+

[tryton-commits] changeset in modules/account_payment_sepa:6.0 Handle multiple tr...

2022-10-12 Thread Nicolas Évrard
changeset e2d9f811b79e in modules/account_payment_sepa:6.0
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset=e2d9f811b79e
description:
Handle multiple transactions in CAMT054 Ntry tags

issue11672
review413471003
(grafted from fc8e9d9cb870d9353ff374120688b8e9779b90c0)
diffstat:

 sepa_handler.py |  84 +---
 1 files changed, 44 insertions(+), 40 deletions(-)

diffs (122 lines):

diff -r 9b25677cd795 -r e2d9f811b79e sepa_handler.py
--- a/sepa_handler.py   Fri Nov 05 00:17:58 2021 +0100
+++ b/sepa_handler.py   Mon Oct 03 00:13:39 2022 +0200
@@ -35,48 +35,59 @@
 element.clear()
 
 def handle_entry(self, element):
-payments = self.get_payments(element)
-if self.is_returned(element):
-for payment in payments:
-self.set_return_information(payment, element)
-self.Payment.save(payments)
-self.Payment.fail(payments)
-else:
-date_value = self.date_value(element)
+tag = etree.QName(element)
+failed, succeeded = [], []
+date_value = self.date_value(element)
+
+for transaction in element.findall('.//{%s}TxDtls' % tag.namespace):
+payments = self.get_payments(transaction)
+if self.is_returned(transaction):
+for payment in payments:
+self.set_return_information(payment, transaction)
+failed.extend(payments)
+else:
+succeeded.extend(payments)
+
+if failed:
+self.Payment.save(failed)
+self.Payment.fail(failed)
+if succeeded:
 with Transaction().set_context(date_value=date_value):
-self.Payment.succeed(payments)
+self.Payment.succeed(succeeded)
 
 def get_payment_kind(self, element):
-tag = etree.QName(element)
-return self._kinds[
-element.find('./{%s}CdtDbtInd' % tag.namespace).text]
+camt_ns = etree.QName(element).namespace
+for path in [
+'./camt:CdtDbtInd',
+'./ancestor::camt:NtryDtls/camt:Btch/camt:CdtDbtInd',
+'./ancestor::camt:Ntry/camt:CdtDbtInd',
+]:
+cdtdbtind = element.xpath(path, namespaces={'camt': camt_ns})
+if cdtdbtind:
+return self._kinds[cdtdbtind[0].text]
 _kinds = {
 'CRDT': 'payable',
 'DBIT': 'receivable',
 }
 
-def get_payments(self, element):
-tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-# Version 1 doesn't have NtryDtls but directly TxDtls
-details = element.find('./{%s}TxDtls' % tag.namespace)
-if details is None:
-return []
-instr_id = details.find('.//{%s}InstrId' % tag.namespace)
+def get_payments(self, transaction):
+tag = etree.QName(transaction)
+instr_id = transaction.find(
+'.//{%s}InstrId' % tag.namespace)
+end_to_end_id = transaction.find(
+'.//{%s}EndToEndId' % tag.namespace)
+payment_kind = self.get_payment_kind(transaction)
 if instr_id is not None:
-payments = self.Payment.search([
+return self.Payment.search([
 ('sepa_instruction_id', '=', instr_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
-end_to_end_id = details.find('.//{%s}EndToEndId' % tag.namespace)
-if end_to_end_id is not None:
-payments = self.Payment.search([
+elif end_to_end_id is not None:
+return self.Payment.search([
 ('sepa_end_to_end_id', '=', end_to_end_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
+return []
 
 def date_value(self, element):
 tag = etree.QName(element)
@@ -92,25 +103,18 @@
 
 def is_returned(self, element):
 tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-return
-return_reason = details.find('.//{%s}RtrInf' % tag.namespace)
-if return_reason is None:
-return False
-return True
+return_reason = element.find('.//{%s}RtrInf' % tag.namespace)
+return return_reason is not None
 
 def set_return_information(self, payment, element):
 tag = etree.QName(element)
 
 reason_code = element.find(
-'./{%(ns)s}NtryDtls//{%(ns)s}RtrInf/{%(ns)s}Rsn/{%(ns)s}Cd'
-% {'ns': tag.namespace})
+

[tryton-commits] changeset in modules/account_payment_sepa:6.2 Handle multiple tr...

2022-10-12 Thread Nicolas Évrard
changeset 464e762c9287 in modules/account_payment_sepa:6.2
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset=464e762c9287
description:
Handle multiple transactions in CAMT054 Ntry tags

issue11672
review413471003
(grafted from fc8e9d9cb870d9353ff374120688b8e9779b90c0)
diffstat:

 sepa_handler.py |  84 +---
 1 files changed, 44 insertions(+), 40 deletions(-)

diffs (122 lines):

diff -r 5cb9db4b9ba2 -r 464e762c9287 sepa_handler.py
--- a/sepa_handler.py   Fri Jul 01 23:55:42 2022 +0200
+++ b/sepa_handler.py   Mon Oct 03 00:13:39 2022 +0200
@@ -35,48 +35,59 @@
 element.clear()
 
 def handle_entry(self, element):
-payments = self.get_payments(element)
-if self.is_returned(element):
-for payment in payments:
-self.set_return_information(payment, element)
-self.Payment.save(payments)
-self.Payment.fail(payments)
-else:
-date_value = self.date_value(element)
+tag = etree.QName(element)
+failed, succeeded = [], []
+date_value = self.date_value(element)
+
+for transaction in element.findall('.//{%s}TxDtls' % tag.namespace):
+payments = self.get_payments(transaction)
+if self.is_returned(transaction):
+for payment in payments:
+self.set_return_information(payment, transaction)
+failed.extend(payments)
+else:
+succeeded.extend(payments)
+
+if failed:
+self.Payment.save(failed)
+self.Payment.fail(failed)
+if succeeded:
 with Transaction().set_context(date_value=date_value):
-self.Payment.succeed(payments)
+self.Payment.succeed(succeeded)
 
 def get_payment_kind(self, element):
-tag = etree.QName(element)
-return self._kinds[
-element.find('./{%s}CdtDbtInd' % tag.namespace).text]
+camt_ns = etree.QName(element).namespace
+for path in [
+'./camt:CdtDbtInd',
+'./ancestor::camt:NtryDtls/camt:Btch/camt:CdtDbtInd',
+'./ancestor::camt:Ntry/camt:CdtDbtInd',
+]:
+cdtdbtind = element.xpath(path, namespaces={'camt': camt_ns})
+if cdtdbtind:
+return self._kinds[cdtdbtind[0].text]
 _kinds = {
 'CRDT': 'payable',
 'DBIT': 'receivable',
 }
 
-def get_payments(self, element):
-tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-# Version 1 doesn't have NtryDtls but directly TxDtls
-details = element.find('./{%s}TxDtls' % tag.namespace)
-if details is None:
-return []
-instr_id = details.find('.//{%s}InstrId' % tag.namespace)
+def get_payments(self, transaction):
+tag = etree.QName(transaction)
+instr_id = transaction.find(
+'.//{%s}InstrId' % tag.namespace)
+end_to_end_id = transaction.find(
+'.//{%s}EndToEndId' % tag.namespace)
+payment_kind = self.get_payment_kind(transaction)
 if instr_id is not None:
-payments = self.Payment.search([
+return self.Payment.search([
 ('sepa_instruction_id', '=', instr_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
-end_to_end_id = details.find('.//{%s}EndToEndId' % tag.namespace)
-if end_to_end_id is not None:
-payments = self.Payment.search([
+elif end_to_end_id is not None:
+return self.Payment.search([
 ('sepa_end_to_end_id', '=', end_to_end_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
+return []
 
 def date_value(self, element):
 tag = etree.QName(element)
@@ -92,25 +103,18 @@
 
 def is_returned(self, element):
 tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-return
-return_reason = details.find('.//{%s}RtrInf' % tag.namespace)
-if return_reason is None:
-return False
-return True
+return_reason = element.find('.//{%s}RtrInf' % tag.namespace)
+return return_reason is not None
 
 def set_return_information(self, payment, element):
 tag = etree.QName(element)
 
 reason_code = element.find(
-'./{%(ns)s}NtryDtls//{%(ns)s}RtrInf/{%(ns)s}Rsn/{%(ns)s}Cd'
-% {'ns': tag.namespace})
+

[tryton-commits] changeset in modules/account_payment_sepa:6.4 Handle multiple tr...

2022-10-12 Thread Nicolas Évrard
changeset d09b18cbf5be in modules/account_payment_sepa:6.4
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset=d09b18cbf5be
description:
Handle multiple transactions in CAMT054 Ntry tags

issue11672
review413471003
(grafted from fc8e9d9cb870d9353ff374120688b8e9779b90c0)
diffstat:

 sepa_handler.py |  84 +---
 1 files changed, 44 insertions(+), 40 deletions(-)

diffs (122 lines):

diff -r 629907cf742d -r d09b18cbf5be sepa_handler.py
--- a/sepa_handler.py   Fri Jul 01 23:54:36 2022 +0200
+++ b/sepa_handler.py   Mon Oct 03 00:13:39 2022 +0200
@@ -35,48 +35,59 @@
 element.clear()
 
 def handle_entry(self, element):
-payments = self.get_payments(element)
-if self.is_returned(element):
-for payment in payments:
-self.set_return_information(payment, element)
-self.Payment.save(payments)
-self.Payment.fail(payments)
-else:
-date_value = self.date_value(element)
+tag = etree.QName(element)
+failed, succeeded = [], []
+date_value = self.date_value(element)
+
+for transaction in element.findall('.//{%s}TxDtls' % tag.namespace):
+payments = self.get_payments(transaction)
+if self.is_returned(transaction):
+for payment in payments:
+self.set_return_information(payment, transaction)
+failed.extend(payments)
+else:
+succeeded.extend(payments)
+
+if failed:
+self.Payment.save(failed)
+self.Payment.fail(failed)
+if succeeded:
 with Transaction().set_context(date_value=date_value):
-self.Payment.succeed(payments)
+self.Payment.succeed(succeeded)
 
 def get_payment_kind(self, element):
-tag = etree.QName(element)
-return self._kinds[
-element.find('./{%s}CdtDbtInd' % tag.namespace).text]
+camt_ns = etree.QName(element).namespace
+for path in [
+'./camt:CdtDbtInd',
+'./ancestor::camt:NtryDtls/camt:Btch/camt:CdtDbtInd',
+'./ancestor::camt:Ntry/camt:CdtDbtInd',
+]:
+cdtdbtind = element.xpath(path, namespaces={'camt': camt_ns})
+if cdtdbtind:
+return self._kinds[cdtdbtind[0].text]
 _kinds = {
 'CRDT': 'payable',
 'DBIT': 'receivable',
 }
 
-def get_payments(self, element):
-tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-# Version 1 doesn't have NtryDtls but directly TxDtls
-details = element.find('./{%s}TxDtls' % tag.namespace)
-if details is None:
-return []
-instr_id = details.find('.//{%s}InstrId' % tag.namespace)
+def get_payments(self, transaction):
+tag = etree.QName(transaction)
+instr_id = transaction.find(
+'.//{%s}InstrId' % tag.namespace)
+end_to_end_id = transaction.find(
+'.//{%s}EndToEndId' % tag.namespace)
+payment_kind = self.get_payment_kind(transaction)
 if instr_id is not None:
-payments = self.Payment.search([
+return self.Payment.search([
 ('sepa_instruction_id', '=', instr_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
-end_to_end_id = details.find('.//{%s}EndToEndId' % tag.namespace)
-if end_to_end_id is not None:
-payments = self.Payment.search([
+elif end_to_end_id is not None:
+return self.Payment.search([
 ('sepa_end_to_end_id', '=', end_to_end_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
+return []
 
 def date_value(self, element):
 tag = etree.QName(element)
@@ -92,25 +103,18 @@
 
 def is_returned(self, element):
 tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-return
-return_reason = details.find('.//{%s}RtrInf' % tag.namespace)
-if return_reason is None:
-return False
-return True
+return_reason = element.find('.//{%s}RtrInf' % tag.namespace)
+return return_reason is not None
 
 def set_return_information(self, payment, element):
 tag = etree.QName(element)
 
 reason_code = element.find(
-'./{%(ns)s}NtryDtls//{%(ns)s}RtrInf/{%(ns)s}Rsn/{%(ns)s}Cd'
-% {'ns': tag.namespace})
+

[tryton-commits] changeset in trytond:default Add configuration entries for unacc...

2022-10-09 Thread Nicolas Évrard
changeset b634739721c9 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=b634739721c9
description:
Add configuration entries for unaccent and similarity functions

issue10851
review370001002
diffstat:

 CHANGELOG  |   1 +
 doc/topics/configuration.rst   |  14 ++
 trytond/backend/postgresql/database.py |   5 +++--
 3 files changed, 18 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r fa9f7d4695e6 -r b634739721c9 CHANGELOG
--- a/CHANGELOG Sun Oct 09 18:51:02 2022 +0200
+++ b/CHANGELOG Sun Oct 09 19:58:51 2022 +0200
@@ -1,3 +1,4 @@
+* Add configuration entries for unaccent and similarity functions
 * Add authentication services
 * Schedule actions using server timezone
 * Reset the user sessions less often
diff -r fa9f7d4695e6 -r b634739721c9 doc/topics/configuration.rst
--- a/doc/topics/configuration.rst  Sun Oct 09 18:51:02 2022 +0200
+++ b/doc/topics/configuration.rst  Sun Oct 09 19:58:51 2022 +0200
@@ -229,6 +229,20 @@
 The maximum number of simultaneous connections to the database per process.
 Default: ``64``
 
+unaccent_function
+~
+
+The name of the unaccent function.
+
+Default: ``unaccent``
+
+similarity_function
+~~~
+
+The name of the similarity function.
+
+Default: ``similarity``
+
 request
 ---
 
diff -r fa9f7d4695e6 -r b634739721c9 trytond/backend/postgresql/database.py
--- a/trytond/backend/postgresql/database.pySun Oct 09 18:51:02 2022 +0200
+++ b/trytond/backend/postgresql/database.pySun Oct 09 19:58:51 2022 +0200
@@ -76,12 +76,13 @@
 
 class Unaccent(Function):
 __slots__ = ()
-_function = 'unaccent'
+_function = config.get('database', 'unaccent_function', default='unaccent')
 
 
 class Similarity(Function):
 __slots__ = ()
-_function = 'similarity'
+_function = config.get(
+'database', 'similarity_function', default='similarity')
 
 
 class Match(BinaryOperator):



[tryton-commits] changeset in trytond:default Schedule actions using server timezone

2022-10-02 Thread Nicolas Évrard
changeset b040256012ac in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=b040256012ac
description:
Schedule actions using server timezone

issue9436
review423091003
diffstat:

 CHANGELOG |   1 +
 doc/ref/tools/index.rst   |   1 +
 doc/ref/tools/timezone.rst|  25 ++
 doc/topics/cron.rst   |   5 ++
 setup.py  |   1 +
 trytond/__init__.py   |   1 +
 trytond/ir/cron.py|   9 +++-
 trytond/ir/view/cron_form.xml |   2 +
 trytond/tests/test_ir.py  |  76 ++-
 trytond/tests/test_tools.py   |  14 +++-
 trytond/tools/timezone.py |  45 +
 11 files changed, 176 insertions(+), 4 deletions(-)

diffs (321 lines):

diff -r f4c77eb02b5b -r b040256012ac CHANGELOG
--- a/CHANGELOG Mon Oct 03 00:15:12 2022 +0200
+++ b/CHANGELOG Mon Oct 03 00:20:49 2022 +0200
@@ -1,3 +1,4 @@
+* Schedule actions using server timezone
 * Reset the user sessions less often
 * Add straight values to wizard state view
 * Add strip option to Char fields
diff -r f4c77eb02b5b -r b040256012ac doc/ref/tools/index.rst
--- a/doc/ref/tools/index.rst   Mon Oct 03 00:15:12 2022 +0200
+++ b/doc/ref/tools/index.rst   Mon Oct 03 00:20:49 2022 +0200
@@ -13,3 +13,4 @@
 email
 singleton
 immutabledict
+timezone
diff -r f4c77eb02b5b -r b040256012ac doc/ref/tools/timezone.rst
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/doc/ref/tools/timezone.rstMon Oct 03 00:20:49 2022 +0200
@@ -0,0 +1,25 @@
+.. _ref-tools-timezone:
+.. module:: trytond.tools.timezone
+
+timezone
+
+
+.. function:: get_tzinfo(zoneid)
+
+   Get a class representing a IANA time zone specified by the string 
``zoneid``.
+
+.. function:: available_timezones()
+
+   Get a list of all the valid IANA keys available.
+
+.. attribute:: UTC
+
+   The UTC :py:class:`datetime.tzinfo` instance.
+
+.. attribute:: SERVER
+
+   The server timezone :py:class:`datetime.tzinfo` instance.
+
+   Tryton tests the environment variables ``TRYTOND_TZ`` and ``TZ`` in this
+   order to select to IANA key to use.
+   If they are both empty, it defaults to ``UTC``.
diff -r f4c77eb02b5b -r b040256012ac doc/topics/cron.rst
--- a/doc/topics/cron.rst   Mon Oct 03 00:15:12 2022 +0200
+++ b/doc/topics/cron.rst   Mon Oct 03 00:20:49 2022 +0200
@@ -11,6 +11,11 @@
 and the interval of time between calls. The method must be a class method of a
 :class:`~trytond.model.Model` which can be called without any parameters.
 
+.. note::
+
+   The timezone used to schedule the action is
+   :attr:`timezone.SERVER `.
+
 To register a new method with the scheduler, you must extend the ``ir.cron``
 model and append the new method to the
 :attr:`~trytond.model.fields.Selection.selection` attribute of the ``method``
diff -r f4c77eb02b5b -r b040256012ac setup.py
--- a/setup.py  Mon Oct 03 00:15:12 2022 +0200
+++ b/setup.py  Mon Oct 03 00:20:49 2022 +0200
@@ -161,6 +161,7 @@
 'werkzeug',
 'wrapt',
 'passlib >= 1.7.0',
+'pytz;python_verrion<"3.9"',
 ],
 extras_require={
 'test': tests_require,
diff -r f4c77eb02b5b -r b040256012ac trytond/__init__.py
--- a/trytond/__init__.py   Mon Oct 03 00:15:12 2022 +0200
+++ b/trytond/__init__.py   Mon Oct 03 00:20:49 2022 +0200
@@ -9,6 +9,7 @@
 
 __version__ = "6.5.0"
 
+os.environ.setdefault('TRYTOND_TZ', os.environ.get('TZ', 'UTC'))
 os.environ['TZ'] = 'UTC'
 if hasattr(time, 'tzset'):
 time.tzset()
diff -r f4c77eb02b5b -r b040256012ac trytond/ir/cron.py
--- a/trytond/ir/cron.pyMon Oct 03 00:15:12 2022 +0200
+++ b/trytond/ir/cron.pyMon Oct 03 00:20:49 2022 +0200
@@ -14,6 +14,7 @@
 from trytond.pool import Pool
 from trytond.pyson import Eval
 from trytond.status import processing
+from trytond.tools import timezone as tz
 from trytond.transaction import Transaction
 from trytond.worker import run_task
 
@@ -66,6 +67,7 @@
 ['minutes', 'hours', 'days', 'weeks']),
 },
 depends=['interval_type'])
+timezone = fields.Function(fields.Char("Timezone"), 'get_timezone')
 
 next_call = fields.DateTime("Next Call", select=True)
 method = fields.Selection([
@@ -97,6 +99,9 @@
 # Migration from 5.0: remove required on next_call
 table_h.not_null_action('next_call', 'remove')
 
+def get_timezone(self, name):
+return tz.SERVER.key
+
 @staticmethod
 def check_xml_record(crons, values):
 return True
@@ -110,7 +115,7 @@
 ]
 
 def compute_next_call(self, now):
-return (now
+return (now.replace(tzinfo=tz.UTC).astimezone(tz.SERVER)
 + relativedelta(**{self.interval_type: self.interval_number})
 + relativedelta(
 microsecond=0,
@@ -132,7 +137,7 @@
 int(self.weekday.index)
 if self.weekday
   

[tryton-commits] changeset in tryton:default Eager load at least 1/10 of the clie...

2022-10-02 Thread Nicolas Évrard
changeset 8fdd045ddd51 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=8fdd045ddd51
description:
Eager load at least 1/10 of the client limit

issue10043
review336131003
diffstat:

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

diffs (12 lines):

diff -r 3f68e6090c44 -r 8fdd045ddd51 tryton/gui/window/view_form/model/record.py
--- a/tryton/gui/window/view_form/model/record.py   Sat Oct 01 14:48:30 
2022 +0200
+++ b/tryton/gui/window/view_form/model/record.py   Mon Oct 03 00:22:51 
2022 +0200
@@ -83,7 +83,7 @@
 
 record_context = self.get_context()
 if loading == 'eager':
-limit = int(CONFIG['client.limit'] / len(fnames))
+limit = CONFIG['client.limit'] // min(len(fnames), 10)
 
 def filter_group(record):
 return (not record.destroyed



[tryton-commits] changeset in sao:default Eager load at least 1/10 of the client ...

2022-10-02 Thread Nicolas Évrard
changeset 4dacbcf16843 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset=4dacbcf16843
description:
Eager load at least 1/10 of the client limit

issue10043
review336131003
diffstat:

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

diffs (14 lines):

diff -r a963f1896290 -r 4dacbcf16843 src/model.js
--- a/src/model.js  Sat Oct 01 14:45:59 2022 +0200
+++ b/src/model.js  Mon Oct 03 00:22:51 2022 +0200
@@ -681,8 +681,8 @@
 
 var context = jQuery.extend({}, this.get_context());
 if (loading == 'eager') {
-var limit = parseInt(Sao.config.limit / fnames_to_fetch.length,
-10);
+var limit = Math.trunc(Sao.config.limit /
+Math.min(fnames_to_fetch.length, 10));
 
 const filter_group = record => {
 return (!record.destroyed &&



[tryton-commits] changeset in trytond:default Clear private caches when dropping ...

2022-10-02 Thread Nicolas Évrard
changeset f4c77eb02b5b in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=f4c77eb02b5b
description:
Clear private caches when dropping database

issue11744
review413601003
diffstat:

 trytond/backend/postgresql/database.py |  2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diffs (12 lines):

diff -r 38bd66006727 -r f4c77eb02b5b trytond/backend/postgresql/database.py
--- a/trytond/backend/postgresql/database.pyMon Oct 03 00:06:41 2022 +0200
+++ b/trytond/backend/postgresql/database.pyMon Oct 03 00:15:12 2022 +0200
@@ -299,6 +299,8 @@
 cursor.execute(SQL("DROP DATABASE {}")
 .format(Identifier(database_name)))
 cls._list_cache.clear()
+cls._has_proc.pop(database_name, None)
+cls._search_full_text_languages.pop(database_name, None)
 
 def get_version(self, connection):
 version = connection.server_version



[tryton-commits] changeset in modules/account_payment_sepa:default Handle multipl...

2022-10-02 Thread Nicolas Évrard
changeset fc8e9d9cb870 in modules/account_payment_sepa:default
details: 
https://hg.tryton.org/modules/account_payment_sepa?cmd=changeset=fc8e9d9cb870
description:
Handle multiple transactions in CAMT054 Ntry tags

issue11672
review413471003
diffstat:

 sepa_handler.py |  84 +---
 1 files changed, 44 insertions(+), 40 deletions(-)

diffs (122 lines):

diff -r e455de0a2feb -r fc8e9d9cb870 sepa_handler.py
--- a/sepa_handler.py   Fri Sep 16 23:37:38 2022 +0200
+++ b/sepa_handler.py   Mon Oct 03 00:13:39 2022 +0200
@@ -35,48 +35,59 @@
 element.clear()
 
 def handle_entry(self, element):
-payments = self.get_payments(element)
-if self.is_returned(element):
-for payment in payments:
-self.set_return_information(payment, element)
-self.Payment.save(payments)
-self.Payment.fail(payments)
-else:
-date_value = self.date_value(element)
+tag = etree.QName(element)
+failed, succeeded = [], []
+date_value = self.date_value(element)
+
+for transaction in element.findall('.//{%s}TxDtls' % tag.namespace):
+payments = self.get_payments(transaction)
+if self.is_returned(transaction):
+for payment in payments:
+self.set_return_information(payment, transaction)
+failed.extend(payments)
+else:
+succeeded.extend(payments)
+
+if failed:
+self.Payment.save(failed)
+self.Payment.fail(failed)
+if succeeded:
 with Transaction().set_context(date_value=date_value):
-self.Payment.succeed(payments)
+self.Payment.succeed(succeeded)
 
 def get_payment_kind(self, element):
-tag = etree.QName(element)
-return self._kinds[
-element.find('./{%s}CdtDbtInd' % tag.namespace).text]
+camt_ns = etree.QName(element).namespace
+for path in [
+'./camt:CdtDbtInd',
+'./ancestor::camt:NtryDtls/camt:Btch/camt:CdtDbtInd',
+'./ancestor::camt:Ntry/camt:CdtDbtInd',
+]:
+cdtdbtind = element.xpath(path, namespaces={'camt': camt_ns})
+if cdtdbtind:
+return self._kinds[cdtdbtind[0].text]
 _kinds = {
 'CRDT': 'payable',
 'DBIT': 'receivable',
 }
 
-def get_payments(self, element):
-tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-# Version 1 doesn't have NtryDtls but directly TxDtls
-details = element.find('./{%s}TxDtls' % tag.namespace)
-if details is None:
-return []
-instr_id = details.find('.//{%s}InstrId' % tag.namespace)
+def get_payments(self, transaction):
+tag = etree.QName(transaction)
+instr_id = transaction.find(
+'.//{%s}InstrId' % tag.namespace)
+end_to_end_id = transaction.find(
+'.//{%s}EndToEndId' % tag.namespace)
+payment_kind = self.get_payment_kind(transaction)
 if instr_id is not None:
-payments = self.Payment.search([
+return self.Payment.search([
 ('sepa_instruction_id', '=', instr_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
-end_to_end_id = details.find('.//{%s}EndToEndId' % tag.namespace)
-if end_to_end_id is not None:
-payments = self.Payment.search([
+elif end_to_end_id is not None:
+return self.Payment.search([
 ('sepa_end_to_end_id', '=', end_to_end_id.text),
-('kind', '=', self.get_payment_kind(element)),
+('kind', '=', payment_kind),
 ])
-return payments
+return []
 
 def date_value(self, element):
 tag = etree.QName(element)
@@ -92,25 +103,18 @@
 
 def is_returned(self, element):
 tag = etree.QName(element)
-details = element.find('./{%s}NtryDtls' % tag.namespace)
-if details is None:
-return
-return_reason = details.find('.//{%s}RtrInf' % tag.namespace)
-if return_reason is None:
-return False
-return True
+return_reason = element.find('.//{%s}RtrInf' % tag.namespace)
+return return_reason is not None
 
 def set_return_information(self, payment, element):
 tag = etree.QName(element)
 
 reason_code = element.find(
-'./{%(ns)s}NtryDtls//{%(ns)s}RtrInf/{%(ns)s}Rsn/{%(ns)s}Cd'
-% {'ns': tag.namespace})
+'.//{%(ns)s}RtrInf/{%(ns)s}Rsn/{%(ns)s}Cd' % {'ns': tag.namespace})
 if 

[tryton-commits] changeset in modules/account_invoice:default Extend scenario to ...

2022-10-02 Thread Nicolas Évrard
changeset 149066718d79 in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset=149066718d79
description:
Extend scenario to check amount_to_pay

issue10440
review351971032
diffstat:

 tests/scenario_invoice_group_line.rst |  16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diffs (60 lines):

diff -r 26b5f5d804ee -r 149066718d79 tests/scenario_invoice_group_line.rst
--- a/tests/scenario_invoice_group_line.rst Wed Sep 14 19:27:28 2022 +0200
+++ b/tests/scenario_invoice_group_line.rst Mon Oct 03 00:11:05 2022 +0200
@@ -64,6 +64,8 @@
 >>> invoice.click('post')
 >>> invoice.state
 'posted'
+>>> invoice.amount_to_pay
+Decimal('10.00')
 
 Post supplier invoice::
 
@@ -77,6 +79,8 @@
 >>> supplier_invoice.click('post')
 >>> supplier_invoice.state
 'posted'
+>>> supplier_invoice.amount_to_pay
+Decimal('5.00')
 
 Group lines::
 
@@ -91,9 +95,13 @@
 >>> invoice.reload()
 >>> invoice.state
 'posted'
+>>> invoice.amount_to_pay
+Decimal('0')
 >>> supplier_invoice.reload()
 >>> supplier_invoice.state
 'posted'
+>>> supplier_invoice.amount_to_pay
+Decimal('0')
 
 Receive remaining line::
 
@@ -121,9 +129,13 @@
 >>> invoice.reload()
 >>> invoice.state
 'paid'
+>>> invoice.amount_to_pay
+Decimal('0')
 >>> supplier_invoice.reload()
 >>> supplier_invoice.state
 'paid'
+>>> supplier_invoice.amount_to_pay
+Decimal('0')
 
 Remove the created reconciliation::
 
@@ -134,6 +146,10 @@
 >>> invoice.reload()
 >>> invoice.state
 'posted'
+>>> invoice.amount_to_pay
+Decimal('0')
 >>> supplier_invoice.reload()
 >>> supplier_invoice.state
 'posted'
+>>> supplier_invoice.amount_to_pay
+Decimal('0')



[tryton-commits] changeset in trytond:default Reset less often the user sessions

2022-10-02 Thread Nicolas Évrard
changeset 38bd66006727 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=38bd66006727
description:
Reset less often the user sessions

issue10202
review341741060
diffstat:

 CHANGELOG |   1 +
 trytond/ir/session.py |  42 +-
 2 files changed, 30 insertions(+), 13 deletions(-)

diffs (101 lines):

diff -r 15ef08043b65 -r 38bd66006727 CHANGELOG
--- a/CHANGELOG Sun Oct 02 00:22:56 2022 +0200
+++ b/CHANGELOG Mon Oct 03 00:06:41 2022 +0200
@@ -1,3 +1,4 @@
+* Reset the user sessions less often
 * Add straight values to wizard state view
 * Add strip option to Char fields
 * Strip only one wildcard
diff -r 15ef08043b65 -r 38bd66006727 trytond/ir/session.py
--- a/trytond/ir/session.py Sun Oct 02 00:22:56 2022 +0200
+++ b/trytond/ir/session.py Mon Oct 03 00:06:41 2022 +0200
@@ -4,9 +4,14 @@
 import json
 from secrets import token_hex
 
+from trytond.cache import Cache
 from trytond.config import config
 from trytond.model import ModelSQL, fields
 
+_session_timeout = datetime.timedelta(
+seconds=config.getint('session', 'timeout'))
+_reset_interval = _session_timeout // 10
+
 
 class Session(ModelSQL):
 "Session"
@@ -14,6 +19,7 @@
 _rec_name = 'key'
 
 key = fields.Char('Key', required=True, select=True, strip=False)
+_session_reset_cache = Cache('ir_session.session_reset', context=False)
 
 @classmethod
 def __setup__(cls):
@@ -32,6 +38,13 @@
 return token_hex(nbytes)
 
 @classmethod
+def write(cls, *args):
+super().write(*args)
+for sessions in args[0:None:2]:
+for session in sessions:
+cls._session_reset_cache.set(session.key, session.write_date)
+
+@classmethod
 def new(cls, values=None):
 "Create a new session for the transaction user and return the key."
 if values is None:
@@ -68,17 +81,20 @@
 ('create_uid', '=', user),
 domain or [],
 ])
-find = None
+find, last_reset = None, None
 to_delete = []
 for session in sessions:
 if abs(session.create_date - now) < timeout:
 if session.key == key:
 find = True
+last_reset = session.write_date or session.create_date
 else:
 if find is None and session.key == key:
 find = False
 to_delete.append(session)
 cls.delete(to_delete)
+if find:
+cls._session_reset_cache.set(key, last_reset)
 return find
 
 @classmethod
@@ -105,18 +121,18 @@
 def reset(cls, key, domain=None):
 "Reset key session timestamp"
 now = datetime.datetime.now()
-timeout = datetime.timedelta(
-seconds=config.getint('session', 'timeout'))
-timestamp = now - timeout
-sessions = cls.search([
-('key', '=', key),
-['OR',
-('create_date', '>=', timestamp),
-('write_date', '>=', timestamp),
-],
-domain or [],
-])
-cls.write(sessions, {})
+last_reset = cls._session_reset_cache.get(key)
+if last_reset is None or (now - _reset_interval) > last_reset:
+timestamp = now - _session_timeout
+sessions = cls.search([
+('key', '=', key),
+['OR',
+('create_date', '>=', timestamp),
+('write_date', '>=', timestamp),
+],
+domain or [],
+])
+cls.write(sessions, {})
 
 @classmethod
 def clear(cls, users, domain=None):



[tryton-commits] changeset in trytond:6.0 Catch get_connection errors in Cache li...

2022-09-29 Thread Nicolas Évrard
changeset ffac357d4312 in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=ffac357d4312
description:
Catch get_connection errors in Cache listener

issue11563
review411271003
(grafted from 7123014d260c278bd36a25d9c4a7543db553733c)
diffstat:

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

diffs (40 lines):

diff -r cb78ca4f66ed -r ffac357d4312 trytond/cache.py
--- a/trytond/cache.py  Thu Sep 15 21:49:12 2022 +0200
+++ b/trytond/cache.py  Sat Sep 17 19:00:48 2022 +0200
@@ -347,15 +347,18 @@
 
 @classmethod
 def _listen(cls, dbname):
-database = backend.Database(dbname)
-if not database.has_channel():
-raise NotImplementedError
+current_thread = threading.current_thread()
+pid = os.getpid()
+conn = None
+try:
+database = backend.Database(dbname)
+if not database.has_channel():
+raise NotImplementedError
 
-logger.info("listening on channel '%s' of '%s'", cls._channel, dbname)
-conn = database.get_connection(autocommit=True)
-pid = os.getpid()
-current_thread = threading.current_thread()
-try:
+logger.info(
+"listening on channel '%s' of '%s'", cls._channel, dbname)
+conn = database.get_connection(autocommit=True)
+
 cursor = conn.cursor()
 cursor.execute('LISTEN "%s"' % cls._channel)
 current_thread.listening = True
@@ -381,7 +384,8 @@
 "cache listener on '%s' crashed", dbname, exc_info=True)
 raise
 finally:
-database.put_connection(conn)
+if conn:
+database.put_connection(conn)
 with cls._listener_lock[pid]:
 if cls._listener.get((pid, dbname)) == current_thread:
 del cls._listener[pid, dbname]



[tryton-commits] changeset in trytond:6.2 Catch get_connection errors in Cache li...

2022-09-29 Thread Nicolas Évrard
changeset ae0476e33d82 in trytond:6.2
details: https://hg.tryton.org/trytond?cmd=changeset=ae0476e33d82
description:
Catch get_connection errors in Cache listener

issue11563
review411271003
(grafted from 7123014d260c278bd36a25d9c4a7543db553733c)
diffstat:

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

diffs (40 lines):

diff -r 7073f9719d8a -r ae0476e33d82 trytond/cache.py
--- a/trytond/cache.py  Thu Sep 15 21:49:12 2022 +0200
+++ b/trytond/cache.py  Sat Sep 17 19:00:48 2022 +0200
@@ -346,15 +346,18 @@
 
 @classmethod
 def _listen(cls, dbname):
-database = backend.Database(dbname)
-if not database.has_channel():
-raise NotImplementedError
+current_thread = threading.current_thread()
+pid = os.getpid()
+conn = None
+try:
+database = backend.Database(dbname)
+if not database.has_channel():
+raise NotImplementedError
 
-logger.info("listening on channel '%s' of '%s'", cls._channel, dbname)
-conn = database.get_connection(autocommit=True)
-pid = os.getpid()
-current_thread = threading.current_thread()
-try:
+logger.info(
+"listening on channel '%s' of '%s'", cls._channel, dbname)
+conn = database.get_connection(autocommit=True)
+
 cursor = conn.cursor()
 cursor.execute('LISTEN "%s"' % cls._channel)
 current_thread.listening = True
@@ -380,7 +383,8 @@
 "cache listener on '%s' crashed", dbname, exc_info=True)
 raise
 finally:
-database.put_connection(conn)
+if conn:
+database.put_connection(conn)
 with cls._listener_lock[pid]:
 if cls._listener.get((pid, dbname)) == current_thread:
 del cls._listener[pid, dbname]



[tryton-commits] changeset in trytond:6.4 Catch get_connection errors in Cache li...

2022-09-29 Thread Nicolas Évrard
changeset a87d1206c5cc in trytond:6.4
details: https://hg.tryton.org/trytond?cmd=changeset=a87d1206c5cc
description:
Catch get_connection errors in Cache listener

issue11563
review411271003
(grafted from 7123014d260c278bd36a25d9c4a7543db553733c)
diffstat:

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

diffs (45 lines):

diff -r a1b42a36e1f7 -r a87d1206c5cc trytond/cache.py
--- a/trytond/cache.py  Thu Sep 15 21:49:12 2022 +0200
+++ b/trytond/cache.py  Sat Sep 17 19:00:48 2022 +0200
@@ -348,16 +348,20 @@
 
 @classmethod
 def _listen(cls, dbname):
-database = backend.Database(dbname)
-if not database.has_channel():
-raise NotImplementedError
+current_thread = threading.current_thread()
+pid = os.getpid()
 
-logger.info("listening on channel '%s' of '%s'", cls._channel, dbname)
-conn = database.get_connection(autocommit=True)
-pid = os.getpid()
-selector = selectors.DefaultSelector()
-current_thread = threading.current_thread()
+conn, selector = None, None
 try:
+database = backend.Database(dbname)
+if not database.has_channel():
+raise NotImplementedError
+
+logger.info(
+"listening on channel '%s' of '%s'", cls._channel, dbname)
+conn = database.get_connection(autocommit=True)
+selector = selectors.DefaultSelector()
+
 cursor = conn.cursor()
 cursor.execute('LISTEN "%s"' % cls._channel)
 current_thread.listening = True
@@ -380,8 +384,10 @@
 "cache listener on '%s' crashed", dbname, exc_info=True)
 raise
 finally:
-selector.close()
-database.put_connection(conn)
+if selector:
+selector.close()
+if conn:
+database.put_connection(conn)
 with cls._listener_lock[pid]:
 if cls._listener.get((pid, dbname)) == current_thread:
 del cls._listener[pid, dbname]



[tryton-commits] changeset in tryton:5.0 Select the clicked line when activating ...

2022-09-29 Thread Nicolas Évrard
changeset 58e384fcce26 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=58e384fcce26
description:
Select the clicked line when activating a button in list view

issue11212
review433141003
(grafted from e97626052a77e58d84dafbe11c32f7ccea4fdfaa)
diffstat:

 tryton/gui/window/view_form/view/list_gtk/widget.py |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (21 lines):

diff -r 26f5b60e9b97 -r 58e384fcce26 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Tue Sep 06 
23:31:24 2022 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Sat Sep 17 
18:58:55 2022 +0200
@@ -1008,11 +1008,17 @@
 store = self.view.treeview.get_model()
 record = store.get_value(store.get_iter(path), 0)
 
+if self.view.record and self.view.record != record:
+widget.stop_emission_by_name('clicked')
+return True
+
 state_changes = record.expr_eval(
 self.attrs.get('states', {}))
 if state_changes.get('invisible') \
 or state_changes.get('readonly'):
 return True
+
+self.view.treeview.set_cursor(path)
 widget.handler_block_by_func(self.button_clicked)
 try:
 self.view.screen.button(self.attrs)



[tryton-commits] changeset in tryton:6.0 Select the clicked line when activating ...

2022-09-29 Thread Nicolas Évrard
changeset 2f09effcb95d in tryton:6.0
details: https://hg.tryton.org/tryton?cmd=changeset=2f09effcb95d
description:
Select the clicked line when activating a button in list view

issue11212
review433141003
(grafted from e97626052a77e58d84dafbe11c32f7ccea4fdfaa)
diffstat:

 tryton/gui/window/view_form/view/list_gtk/widget.py |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (21 lines):

diff -r d99d8c5b29e3 -r 2f09effcb95d 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Thu Sep 01 
22:07:13 2022 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Sat Sep 17 
18:58:55 2022 +0200
@@ -1303,11 +1303,17 @@
 store = self.view.treeview.get_model()
 record = store.get_value(store.get_iter(path), 0)
 
+if self.view.record and self.view.record != record:
+widget.stop_emission_by_name('clicked')
+return True
+
 state_changes = record.expr_eval(
 self.attrs.get('states', {}))
 if state_changes.get('invisible') \
 or state_changes.get('readonly'):
 return True
+
+self.view.treeview.set_cursor(path)
 widget.handler_block_by_func(self.button_clicked)
 try:
 self.view.screen.button(self.attrs)



[tryton-commits] changeset in tryton:6.2 Select the clicked line when activating ...

2022-09-29 Thread Nicolas Évrard
changeset 5ad7f307f7e5 in tryton:6.2
details: https://hg.tryton.org/tryton?cmd=changeset=5ad7f307f7e5
description:
Select the clicked line when activating a button in list view

issue11212
review433141003
(grafted from e97626052a77e58d84dafbe11c32f7ccea4fdfaa)
diffstat:

 tryton/gui/window/view_form/view/list_gtk/widget.py |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (21 lines):

diff -r b0a43b934892 -r 5ad7f307f7e5 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Thu Sep 01 
22:07:13 2022 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Sat Sep 17 
18:58:55 2022 +0200
@@ -1305,11 +1305,17 @@
 store = self.view.treeview.get_model()
 record = store.get_value(store.get_iter(path), 0)
 
+if self.view.record and self.view.record != record:
+widget.stop_emission_by_name('clicked')
+return True
+
 state_changes = record.expr_eval(
 self.attrs.get('states', {}))
 if state_changes.get('invisible') \
 or state_changes.get('readonly'):
 return True
+
+self.view.treeview.set_cursor(path)
 widget.handler_block_by_func(self.button_clicked)
 try:
 self.view.screen.button(self.attrs)



[tryton-commits] changeset in tryton:6.4 Select the clicked line when activating ...

2022-09-29 Thread Nicolas Évrard
changeset 60e29b9f6321 in tryton:6.4
details: https://hg.tryton.org/tryton?cmd=changeset=60e29b9f6321
description:
Select the clicked line when activating a button in list view

issue11212
review433141003
(grafted from e97626052a77e58d84dafbe11c32f7ccea4fdfaa)
diffstat:

 tryton/gui/window/view_form/view/list_gtk/widget.py |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (21 lines):

diff -r 26069b017018 -r 60e29b9f6321 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Thu Sep 01 
22:07:13 2022 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Sat Sep 17 
18:58:55 2022 +0200
@@ -1305,11 +1305,17 @@
 store = self.view.treeview.get_model()
 record = store.get_value(store.get_iter(path), 0)
 
+if self.view.record and self.view.record != record:
+widget.stop_emission_by_name('clicked')
+return True
+
 state_changes = record.expr_eval(
 self.attrs.get('states', {}))
 if state_changes.get('invisible') \
 or state_changes.get('readonly'):
 return True
+
+self.view.treeview.set_cursor(path)
 widget.handler_block_by_func(self.button_clicked)
 try:
 self.view.screen.button(self.attrs)



[tryton-commits] changeset in trytond:default Catch get_connection errors in Cach...

2022-09-17 Thread Nicolas Évrard
changeset 7123014d260c in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=7123014d260c
description:
Catch get_connection errors in Cache listener

issue11563
review411271003
diffstat:

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

diffs (45 lines):

diff -r 65b62a8b02c3 -r 7123014d260c trytond/cache.py
--- a/trytond/cache.py  Fri Sep 16 23:36:30 2022 +0200
+++ b/trytond/cache.py  Sat Sep 17 19:00:48 2022 +0200
@@ -348,16 +348,20 @@
 
 @classmethod
 def _listen(cls, dbname):
-database = backend.Database(dbname)
-if not database.has_channel():
-raise NotImplementedError
+current_thread = threading.current_thread()
+pid = os.getpid()
 
-logger.info("listening on channel '%s' of '%s'", cls._channel, dbname)
-conn = database.get_connection(autocommit=True)
-pid = os.getpid()
-selector = selectors.DefaultSelector()
-current_thread = threading.current_thread()
+conn, selector = None, None
 try:
+database = backend.Database(dbname)
+if not database.has_channel():
+raise NotImplementedError
+
+logger.info(
+"listening on channel '%s' of '%s'", cls._channel, dbname)
+conn = database.get_connection(autocommit=True)
+selector = selectors.DefaultSelector()
+
 cursor = conn.cursor()
 cursor.execute('LISTEN "%s"' % cls._channel)
 current_thread.listening = True
@@ -380,8 +384,10 @@
 "cache listener on '%s' crashed", dbname, exc_info=True)
 raise
 finally:
-selector.close()
-database.put_connection(conn)
+if selector:
+selector.close()
+if conn:
+database.put_connection(conn)
 with cls._listener_lock[pid]:
 if cls._listener.get((pid, dbname)) == current_thread:
 del cls._listener[pid, dbname]



[tryton-commits] changeset in tryton:default Select the clicked line when activat...

2022-09-17 Thread Nicolas Évrard
changeset e97626052a77 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=e97626052a77
description:
Select the clicked line when activating a button in list view

issue11212
review433141003
diffstat:

 tryton/gui/window/view_form/view/list_gtk/widget.py |  6 ++
 1 files changed, 6 insertions(+), 0 deletions(-)

diffs (21 lines):

diff -r ee18cb647324 -r e97626052a77 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Fri Sep 16 
23:36:30 2022 +0200
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Sat Sep 17 
18:58:55 2022 +0200
@@ -1305,11 +1305,17 @@
 store = self.view.treeview.get_model()
 record = store.get_value(store.get_iter(path), 0)
 
+if self.view.record and self.view.record != record:
+widget.stop_emission_by_name('clicked')
+return True
+
 state_changes = record.expr_eval(
 self.attrs.get('states', {}))
 if state_changes.get('invisible') \
 or state_changes.get('readonly'):
 return True
+
+self.view.treeview.set_cursor(path)
 widget.handler_block_by_func(self.button_clicked)
 try:
 self.view.screen.button(self.attrs)



[tryton-commits] changeset in tryton-tweet:default Post on mastodon too

2022-05-10 Thread Nicolas Évrard
changeset 457ea2c6531c in tryton-tweet:default
details: https://hg.tryton.org/tryton-tweet?cmd=changeset=457ea2c6531c
description:
Post on mastodon too
diffstat:

 requirements.txt |   1 +
 tweet|  68 +++
 2 files changed, 49 insertions(+), 20 deletions(-)

diffs (93 lines):

diff -r 9e0d01e3d806 -r 457ea2c6531c requirements.txt
--- a/requirements.txt  Thu Oct 28 12:05:37 2021 +0200
+++ b/requirements.txt  Tue May 10 18:13:12 2022 +0200
@@ -1,1 +1,2 @@
+requests
 python-twitter
diff -r 9e0d01e3d806 -r 457ea2c6531c tweet
--- a/tweet Thu Oct 28 12:05:37 2021 +0200
+++ b/tweet Tue May 10 18:13:12 2022 +0200
@@ -1,10 +1,12 @@
 #!/usr/bin/env python3
+import configparser
 import os
-import configparser
 import sys
+import urllib.parse
 from itertools import groupby
 from random import choice
 
+import requests
 import twitter
 
 curdir = os.path.dirname(__file__)
@@ -14,24 +16,50 @@
 return line == '\n'
 
 
-data, prefix = {
-'tip': ('tips', "#TrytonTips "),
-'success-story': ('success-stories', ""),
-}[sys.argv[1]]
-tweets = []
-with open(os.path.join(curdir, data), 'r') as fp:
-for key, lines in groupby(fp, block_separator):
-if key:
-continue
-tweets.append(prefix + ' '.join(map(str.strip, lines)))
-tweet = choice(tweets)
+def choose_text():
+data, prefix = {
+'tip': ('tips', "#TrytonTips "),
+'success-story': ('success-stories', ""),
+}[sys.argv[1]]
+tweets = []
+with open(os.path.join(curdir, data), 'r') as fp:
+for key, lines in groupby(fp, block_separator):
+if key:
+continue
+tweets.append(prefix + ' '.join(map(str.strip, lines)))
+return choice(tweets)
+
+
+def tweet(text):
+config = configparser.ConfigParser()
+config.read(os.path.join(curdir, 'twitter.cfg'))
 
-config = configparser.ConfigParser()
-config.read(os.path.join(curdir, 'twitter.cfg'))
+twitter.Api(
+consumer_key=config.get('consumer', 'key'),
+consumer_secret=config.get('consumer', 'secret'),
+access_token_key=config.get('access_token', 'key'),
+access_token_secret=config.get('access_token', 'secret')
+).PostUpdate(text)
+
+
+def toot(text):
+config = configparser.ConfigParser()
+config.read(os.path.join(curdir, 'mastodon.cfg'))
+token = config.get('tokens', 'access')
 
-twitter.Api(
-consumer_key=config.get('consumer', 'key'),
-consumer_secret=config.get('consumer', 'secret'),
-access_token_key=config.get('access_token', 'key'),
-access_token_secret=config.get('access_token', 'secret')
-).PostUpdate(tweet)
+requests.post(
+urllib.parse.urljoin(
+config.get('instance', 'url'), '/api/v1/statuses'),
+params={
+'status': text,
+},
+headers={
+'Authorization': f"Bearer {token}",
+})
+
+
+
+if __name__ == '__main__':
+text = choose_text()
+tweet(text)
+toot(text)



[tryton-commits] changeset in trytond:default Read at most cache size or IN_MAX r...

2022-05-10 Thread Nicolas Évrard
changeset 48bad78f99b0 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=48bad78f99b0
description:
Read at most cache size or IN_MAX records from the database

issue11468
review427111003
diffstat:

 trytond/model/modelstorage.py |  8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r 290ec5f156b2 -r 48bad78f99b0 trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py Sat May 07 14:10:36 2022 +0200
+++ b/trytond/model/modelstorage.py Tue May 10 15:24:37 2022 +0200
@@ -1676,11 +1676,13 @@
 if id_ not in s:
 s.add(id_)
 yield id_
+read_size = max(1, min(
+self._cache.size_limit, self._local_cache.size_limit,
+self._transaction.database.IN_MAX))
 index = self._ids.index(self.id)
 ids = chain(islice(self._ids, index, None),
 islice(self._ids, 0, max(index - 1, 0)))
-ids = islice(unique(filter(filter_, ids)),
-self._transaction.database.IN_MAX)
+ids = islice(unique(filter(filter_, ids)), read_size)
 
 def instantiate(field, value, data):
 if field._type in ('many2one', 'one2one', 'reference'):
@@ -1744,7 +1746,7 @@
 read_data = []
 for id_ in islice(chain(islice(self._ids, index, None),
 islice(self._ids, 0, max(index - 1, 0))),
-self._transaction.database.IN_MAX):
+read_size):
 if id_ in self._cache:
 data = {'id': id_}
 for fname in ffields:



[tryton-commits] changeset in tryton:default Load group fields before setting the...

2022-05-09 Thread Nicolas Évrard
changeset ba6c9da73849 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=ba6c9da73849
description:
Load group fields before setting the current record

issue11448
review423081003
diffstat:

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

diffs (16 lines):

diff -r 1fd17afe1078 -r ba6c9da73849 
tryton/gui/window/view_form/screen/screen.py
--- a/tryton/gui/window/view_form/screen/screen.py  Mon May 02 16:27:14 
2022 +0200
+++ b/tryton/gui/window/view_form/screen/screen.py  Mon May 09 16:13:31 
2022 +0200
@@ -420,11 +420,11 @@
 if self.parent:
 self.filter_widget = None
 self.order = None
+self.__group.add_fields(fields)
 if len(group):
 self.current_record = group[0]
 else:
 self.current_record = None
-self.__group.add_fields(fields)
 for name, views in fields_views.items():
 self.__group.fields[name].views.update(views)
 self.__group.exclude_field = self.exclude_field



[tryton-commits] changeset in trytond:default Remove python2 compatibility code f...

2022-05-06 Thread Nicolas Évrard
changeset 849222352082 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=849222352082
description:
Remove python2 compatibility code from fields.Binary

issue11467
review41003
diffstat:

 trytond/model/fields/binary.py |  12 +---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r c7b0d5f64013 -r 849222352082 trytond/model/fields/binary.py
--- a/trytond/model/fields/binary.pyMon May 02 16:25:17 2022 +0200
+++ b/trytond/model/fields/binary.pyFri May 06 18:18:01 2022 +0200
@@ -9,13 +9,21 @@
 from .field import Field
 
 
+def caster(d):
+if isinstance(d, bytes):
+return d
+elif isinstance(d, memoryview):
+return bytes(d)
+return bytes(d, encoding='utf8')
+
+
 class Binary(Field):
 '''
 Define a binary field (``bytes``).
 '''
 _type = 'binary'
 _sql_type = 'BLOB'
-cast = bytearray if bytes == str else bytes
+cast = staticmethod(caster)
 
 def __init__(self, string='', help='', required=False, readonly=False,
 domain=None, states=None, select=False, on_change=None,
@@ -89,8 +97,6 @@
 continue
 value = i[name]
 if value:
-if isinstance(value, str):
-value = value.encode('utf-8')
 value = converter(value)
 else:
 value = default



[tryton-commits] changeset in trytond:default Remove user login and user preferen...

2022-04-29 Thread Nicolas Évrard
changeset a18d951b647d in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=a18d951b647d
description:
Remove user login and user preferences cache

The user login cache could result in an error when using trytond in a
multiprocess environment due to a delay in the broadcast of the cache
invalidation.

The user preferences cache was there only to set the context when 
validating
the records but it is useless since the context is now set from the
transaction.

review401251002
issue11430
diffstat:

 trytond/model/modelstorage.py |  12 +-
 trytond/res/__init__.py   |   2 -
 trytond/res/ir.py |  39 --
 trytond/res/user.py   |  49 ++
 4 files changed, 4 insertions(+), 98 deletions(-)

diffs (232 lines):

diff -r 633a31cb1026 -r a18d951b647d trytond/model/modelstorage.py
--- a/trytond/model/modelstorage.py Wed Apr 27 18:28:46 2022 +0200
+++ b/trytond/model/modelstorage.py Fri Apr 29 17:14:27 2022 +0200
@@ -1146,15 +1146,6 @@
 # also convert iterator to list
 records = cls.browse(records)
 
-ctx_pref = {}
-if Transaction().user:
-try:
-User = pool.get('res.user')
-except KeyError:
-pass
-else:
-ctx_pref = User.get_preferences(context_only=True)
-
 def is_pyson(test):
 if isinstance(test, PYSON):
 return True
@@ -1324,8 +1315,7 @@
 field_names = set(field_names)
 function_fields = {name for name, field in cls._fields.items()
 if isinstance(field, fields.Function)}
-ctx_pref['active_test'] = False
-with Transaction().set_context(ctx_pref):
+with Transaction().set_context(active_test=False):
 for field_name, field in cls._fields.items():
 if (field_name not in field_names
 and not (field.validation_depends & field_names)
diff -r 633a31cb1026 -r a18d951b647d trytond/res/__init__.py
--- a/trytond/res/__init__.py   Wed Apr 27 18:28:46 2022 +0200
+++ b/trytond/res/__init__.py   Fri Apr 29 17:14:27 2022 +0200
@@ -30,10 +30,8 @@
 ir.ModelButtonRule,
 ir.ModelButtonClick,
 ir.RuleGroupGroup,
-ir.Lang,
 ir.SequenceType,
 ir.SequenceTypeGroup,
-ir.ModuleConfigWizardItem,
 ir.Export,
 ir.Export_Group,
 ir.Export_Write_Group,
diff -r 633a31cb1026 -r a18d951b647d trytond/res/ir.py
--- a/trytond/res/ir.py Wed Apr 27 18:28:46 2022 +0200
+++ b/trytond/res/ir.py Fri Apr 29 17:14:27 2022 +0200
@@ -176,16 +176,6 @@
 select=True, required=True)
 
 
-class Lang(metaclass=PoolMeta):
-__name__ = 'ir.lang'
-
-@classmethod
-def write(cls, langs, values, *args):
-super(Lang, cls).write(langs, values, *args)
-# Restart the cache for get_preferences
-Pool().get('res.user')._get_preferences_cache.clear()
-
-
 class SequenceType(metaclass=PoolMeta):
 __name__ = 'ir.sequence.type'
 groups = fields.Many2Many('ir.sequence.type-res.group', 'sequence_type',
@@ -224,35 +214,6 @@
 Rule._domain_get_cache.clear()
 
 
-class ModuleConfigWizardItem(metaclass=PoolMeta):
-__name__ = 'ir.module.config_wizard.item'
-
-@classmethod
-def create(cls, vlist):
-pool = Pool()
-User = pool.get('res.user')
-result = super(ModuleConfigWizardItem, cls).create(vlist)
-# Restart the cache for get_preferences
-User._get_preferences_cache.clear()
-return result
-
-@classmethod
-def write(cls, items, values, *args):
-pool = Pool()
-User = pool.get('res.user')
-super(ModuleConfigWizardItem, cls).write(items, values, *args)
-# Restart the cache for get_preferences
-User._get_preferences_cache.clear()
-
-@classmethod
-def delete(cls, items):
-pool = Pool()
-User = pool.get('res.user')
-super(ModuleConfigWizardItem, cls).delete(items)
-# Restart the cache for get_preferences
-User._get_preferences_cache.clear()
-
-
 class Export(metaclass=PoolMeta):
 __name__ = 'ir.export'
 
diff -r 633a31cb1026 -r a18d951b647d trytond/res/user.py
--- a/trytond/res/user.py   Wed Apr 27 18:28:46 2022 +0200
+++ b/trytond/res/user.py   Fri Apr 29 17:14:27 2022 +0200
@@ -155,9 +155,7 @@
 warnings = fields.One2Many('res.user.warning', 'user', 'Warnings')
 sessions = fields.Function(fields.Integer('Sessions'),
 'get_sessions')
-_get_preferences_cache = Cache('res_user.get_preferences')
 _get_groups_cache = Cache('res_user.get_groups', context=False)
-_get_login_cache = Cache('res_user._get_login', context=False)
 
 @classmethod
 def __setup__(cls):
@@ -374,10 +372,7 @@
 @classmethod
 def 

[tryton-commits] changeset in modules/company_work_time:default Remove user login...

2022-04-29 Thread Nicolas Évrard
changeset 4a857556b923 in modules/company_work_time:default
details: 
https://hg.tryton.org/modules/company_work_time?cmd=changeset=4a857556b923
description:
Remove user login and user preferences cache

The user login cache could result in an error when using trytond in a
multiprocess environment due to a delay in the broadcast of the cache
invalidation.

The user preferences cache was there only to set the context when 
validating
the records but it is useless since the context is now set from the
transaction.

review401251002
issue11430
diffstat:

 company.py |  7 ---
 1 files changed, 0 insertions(+), 7 deletions(-)

diffs (14 lines):

diff -r bfbd2c379a74 -r 4a857556b923 company.py
--- a/company.pySat Apr 16 18:30:17 2022 +0200
+++ b/company.pyFri Apr 29 17:14:27 2022 +0200
@@ -37,10 +37,3 @@
 @staticmethod
 def default_hours_per_work_year():
 return 1920
-
-@classmethod
-def write(cls, *args):
-pool = Pool()
-User = pool.get('res.user')
-super(Company, cls).write(*args)
-User._get_preferences_cache.clear()



[tryton-commits] changeset in trytond:6.2 Add compatibility with Werkzeug 2.1.0

2022-04-14 Thread Nicolas Évrard
changeset 34ec02f528d7 in trytond:6.2
details: https://hg.tryton.org/trytond?cmd=changeset=34ec02f528d7
description:
Add compatibility with Werkzeug 2.1.0

issue11353
review356241003
(grafted from 6355790727873d028d833d6126a934e593114a67)
diffstat:

 trytond/tests/test_routes.py |  24 
 trytond/tests/test_wsgi.py   |  12 ++--
 2 files changed, 18 insertions(+), 18 deletions(-)

diffs (155 lines):

diff -r 67a94f7e03e8 -r 34ec02f528d7 trytond/tests/test_routes.py
--- a/trytond/tests/test_routes.py  Sat Mar 19 15:04:09 2022 +0100
+++ b/trytond/tests/test_routes.py  Thu Mar 31 13:43:36 2022 +0200
@@ -6,7 +6,7 @@
 import unittest
 
 from werkzeug.test import Client
-from werkzeug.wrappers import BaseResponse
+from werkzeug.wrappers import Response
 
 from trytond.pool import Pool
 from trytond.tests.test_tryton import activate_module, DB_NAME, drop_db
@@ -46,7 +46,7 @@
 
 def test_data_no_field(self):
 "Test GET data without field"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(self.data_url('res.user'), headers=self.auth_headers)
 
@@ -55,7 +55,7 @@
 
 def test_data_one_field(self):
 "Test GET data with one field"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -66,7 +66,7 @@
 
 def test_data_multiple_fields(self):
 "Test GET data with multiple fields"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -78,7 +78,7 @@
 
 def test_data_language(self):
 "Test GET data with language"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -93,7 +93,7 @@
 
 def test_data_size(self):
 "Test GET data with size limit"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -107,7 +107,7 @@
 
 def test_data_page(self):
 "Test GET data with page"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response0 = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -130,7 +130,7 @@
 
 def test_data_encoding(self):
 "Test GET data with encoding"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -147,7 +147,7 @@
 
 def test_data_delimiter(self):
 "Test GET data with delimiter"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -159,7 +159,7 @@
 
 def test_data_quotechar(self):
 "Test GET data with quotechar"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -172,7 +172,7 @@
 
 def test_data_no_header(self):
 "Test GET data without header"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -183,7 +183,7 @@
 
 def test_data_locale_format(self):
 "Test GET data in locale format"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response_std = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
diff -r 67a94f7e03e8 -r 34ec02f528d7 trytond/tests/test_wsgi.py
--- a/trytond/tests/test_wsgi.pySat Mar 19 15:04:09 2022 +0100
+++ b/trytond/tests/test_wsgi.pyThu Mar 31 13:43:36 2022 +0200
@@ -34,7 +34,7 @@
 raise exception
 
 client = Client(app)
-(response, status, headers) = client.get('/willfail')
+_ = client.get('/willfail')
 
 spy.assert_called_once_with(app, sentinel.request, exception)
 
@@ -60,7 +60,7 @@
 raise exception
 
 client = Client(app)
-(response, status, headers) = client.get('/willfail')
+_ = client.get('/willfail')
 
 spy1.assert_called_once_with(app, sentinel.request, exception)
 spy2.assert_called_once_with(app, sentinel.request, exception)
@@ -84,7 +84,7 @@
 raise exception
 
 client = Client(app)
-(response, status, headers) = client.get('/willfail')
+_ = client.get('/willfail')
 
 spy.assert_called_once_with(app, sentinel.request, exception)
 
@@ -105,10 +105,10 @@
 raise self.TestException('foo')
 
 client = Client(app)
-   

[tryton-commits] changeset in trytond:6.0 Add compatibility with Werkzeug 2.1.0

2022-04-14 Thread Nicolas Évrard
changeset d488548ca402 in trytond:6.0
details: https://hg.tryton.org/trytond?cmd=changeset=d488548ca402
description:
Add compatibility with Werkzeug 2.1.0

issue11353
review356241003
(grafted from 6355790727873d028d833d6126a934e593114a67)
diffstat:

 trytond/tests/test_routes.py |  24 
 trytond/tests/test_wsgi.py   |  12 ++--
 2 files changed, 18 insertions(+), 18 deletions(-)

diffs (155 lines):

diff -r e4dea759b0f6 -r d488548ca402 trytond/tests/test_routes.py
--- a/trytond/tests/test_routes.py  Fri May 28 09:10:15 2021 +0200
+++ b/trytond/tests/test_routes.py  Thu Mar 31 13:43:36 2022 +0200
@@ -6,7 +6,7 @@
 import unittest
 
 from werkzeug.test import Client
-from werkzeug.wrappers import BaseResponse
+from werkzeug.wrappers import Response
 
 from trytond.pool import Pool
 from trytond.tests.test_tryton import activate_module, DB_NAME, drop_db
@@ -46,7 +46,7 @@
 
 def test_data_no_field(self):
 "Test GET data without field"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(self.data_url('res.user'), headers=self.auth_headers)
 
@@ -55,7 +55,7 @@
 
 def test_data_one_field(self):
 "Test GET data with one field"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -66,7 +66,7 @@
 
 def test_data_multiple_fields(self):
 "Test GET data with multiple fields"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -78,7 +78,7 @@
 
 def test_data_language(self):
 "Test GET data with language"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -93,7 +93,7 @@
 
 def test_data_size(self):
 "Test GET data with size limit"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -107,7 +107,7 @@
 
 def test_data_page(self):
 "Test GET data with page"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response0 = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -130,7 +130,7 @@
 
 def test_data_encoding(self):
 "Test GET data with encoding"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('ir.lang'), headers=self.auth_headers,
@@ -147,7 +147,7 @@
 
 def test_data_delimiter(self):
 "Test GET data with delimiter"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -159,7 +159,7 @@
 
 def test_data_quotechar(self):
 "Test GET data with quotechar"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -172,7 +172,7 @@
 
 def test_data_no_header(self):
 "Test GET data without header"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
@@ -183,7 +183,7 @@
 
 def test_data_locale_format(self):
 "Test GET data in locale format"
-c = Client(app, BaseResponse)
+c = Client(app, Response)
 
 response_std = c.get(
 self.data_url('res.user'), headers=self.auth_headers,
diff -r e4dea759b0f6 -r d488548ca402 trytond/tests/test_wsgi.py
--- a/trytond/tests/test_wsgi.pyFri May 28 09:10:15 2021 +0200
+++ b/trytond/tests/test_wsgi.pyThu Mar 31 13:43:36 2022 +0200
@@ -34,7 +34,7 @@
 raise exception
 
 client = Client(app)
-(response, status, headers) = client.get('/willfail')
+_ = client.get('/willfail')
 
 spy.assert_called_once_with(app, sentinel.request, exception)
 
@@ -60,7 +60,7 @@
 raise exception
 
 client = Client(app)
-(response, status, headers) = client.get('/willfail')
+_ = client.get('/willfail')
 
 spy1.assert_called_once_with(app, sentinel.request, exception)
 spy2.assert_called_once_with(app, sentinel.request, exception)
@@ -84,7 +84,7 @@
 raise exception
 
 client = Client(app)
-(response, status, headers) = client.get('/willfail')
+_ = client.get('/willfail')
 
 spy.assert_called_once_with(app, sentinel.request, exception)
 
@@ -105,10 +105,10 @@
 raise self.TestException('foo')
 
 client = Client(app)
-   

[tryton-commits] changeset in tryton:5.0 Request a column size recomputation on t...

2022-04-14 Thread Nicolas Évrard
changeset 48a7129d20ad in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset=48a7129d20ad
description:
Request a column size recomputation on treeview realization

issue11228
review370861002
(grafted from d415b76ceb89d70a716e415b0e524576d7d2303d)
diffstat:

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

diffs (23 lines):

diff -r 0bc786fbba7d -r 48a7129d20ad 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Sun Mar 06 
18:02:00 2022 +0100
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Wed Apr 06 
14:27:11 2022 +0200
@@ -50,12 +50,15 @@
 
 
 def realized(func):
-"Decorator for treeview realized"
+has_been_realized = False
+
 @wraps(func)
 def wrapper(self, *args, **kwargs):
-if (hasattr(self.view.treeview, 'get_realized')
-and not self.view.treeview.get_realized()):
-return
+nonlocal has_been_realized
+if not has_been_realized:
+has_been_realized = self.view.treeview.get_realized()
+if has_been_realized:
+self.view.treeview.queue_resize()
 return func(self, *args, **kwargs)
 return wrapper
 



[tryton-commits] changeset in tryton:6.0 Request a column size recomputation on t...

2022-04-14 Thread Nicolas Évrard
changeset e5fbd9092453 in tryton:6.0
details: https://hg.tryton.org/tryton?cmd=changeset=e5fbd9092453
description:
Request a column size recomputation on treeview realization

issue11228
review370861002
(grafted from d415b76ceb89d70a716e415b0e524576d7d2303d)
diffstat:

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

diffs (23 lines):

diff -r e94fef3e95da -r e5fbd9092453 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Sun Mar 06 
18:02:00 2022 +0100
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Wed Apr 06 
14:27:11 2022 +0200
@@ -51,12 +51,15 @@
 
 
 def realized(func):
-"Decorator for treeview realized"
+has_been_realized = False
+
 @wraps(func)
 def wrapper(self, *args, **kwargs):
-if (hasattr(self.view.treeview, 'get_realized')
-and not self.view.treeview.get_realized()):
-return
+nonlocal has_been_realized
+if not has_been_realized:
+has_been_realized = self.view.treeview.get_realized()
+if has_been_realized:
+self.view.treeview.queue_resize()
 return func(self, *args, **kwargs)
 return wrapper
 



[tryton-commits] changeset in tryton:6.2 Request a column size recomputation on t...

2022-04-14 Thread Nicolas Évrard
changeset 1f1a5356caff in tryton:6.2
details: https://hg.tryton.org/tryton?cmd=changeset=1f1a5356caff
description:
Request a column size recomputation on treeview realization

issue11228
review370861002
(grafted from d415b76ceb89d70a716e415b0e524576d7d2303d)
diffstat:

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

diffs (23 lines):

diff -r e948a83f7767 -r 1f1a5356caff 
tryton/gui/window/view_form/view/list_gtk/widget.py
--- a/tryton/gui/window/view_form/view/list_gtk/widget.py   Sun Mar 06 
18:02:00 2022 +0100
+++ b/tryton/gui/window/view_form/view/list_gtk/widget.py   Wed Apr 06 
14:27:11 2022 +0200
@@ -51,12 +51,15 @@
 
 
 def realized(func):
-"Decorator for treeview realized"
+has_been_realized = False
+
 @wraps(func)
 def wrapper(self, *args, **kwargs):
-if (hasattr(self.view.treeview, 'get_realized')
-and not self.view.treeview.get_realized()):
-return
+nonlocal has_been_realized
+if not has_been_realized:
+has_been_realized = self.view.treeview.get_realized()
+if has_been_realized:
+self.view.treeview.queue_resize()
 return func(self, *args, **kwargs)
 return wrapper
 



[tryton-commits] changeset in trytond:default Remove extra operator when simplify...

2022-04-14 Thread Nicolas Évrard
changeset b9ed8d94a300 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=b9ed8d94a300
description:
Remove extra operator when simplifying nested domains

issue11406
review390621002
diffstat:

 trytond/tests/test_tools.py   |  5 +
 trytond/tools/domain_inversion.py |  9 +++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 0cd242b9bfc4 -r b9ed8d94a300 trytond/tests/test_tools.py
--- a/trytond/tests/test_tools.py   Tue Apr 12 13:09:01 2022 +0200
+++ b/trytond/tests/test_tools.py   Thu Apr 14 10:21:54 2022 +0200
@@ -570,6 +570,11 @@
 self.assertEqual(
 simplify(domain), ['OR', ['x', '=', 3], ['y', '=', 5]])
 
+domain = ['OR', ('x', '=', 1), ['OR', ('x', '=', 2), ('x', '=', 3)]]
+self.assertEqual(
+simplify(domain),
+['OR', ('x', '=', 1), ('x', '=', 2), ('x', '=', 3)])
+
 domain = [['x', '=', 3], ['OR']]
 self.assertEqual(simplify(domain), [['x', '=', 3]])
 
diff -r 0cd242b9bfc4 -r b9ed8d94a300 trytond/tools/domain_inversion.py
--- a/trytond/tools/domain_inversion.py Tue Apr 12 13:09:01 2022 +0200
+++ b/trytond/tools/domain_inversion.py Thu Apr 14 10:21:54 2022 +0200
@@ -307,9 +307,14 @@
 domain_op = bool_operator(domain)
 for branch in domain:
 simplified_branch = simplify_nested(branch)
-if (bool_operator(branch) == domain_op
+if (bool_operator(simplified_branch) == domain_op
 or len(simplified_branch) == 1):
-simplified.extend(simplified_branch)
+if (simplified
+and simplified_branch
+and simplified_branch[0] in ['AND', 'OR']):
+simplified.extend(simplified_branch[1:])
+else:
+simplified.extend(simplified_branch)
 else:
 simplified.append(simplified_branch)
 return simplified



[tryton-commits] changeset in tryton:default Remove extra operator when simplifyi...

2022-04-14 Thread Nicolas Évrard
changeset 0a6285f33c2f in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=0a6285f33c2f
description:
Remove extra operator when simplifying nested domains

issue11406
review390621002
diffstat:

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

diffs (20 lines):

diff -r 7a9ef1e1db52 -r 0a6285f33c2f tryton/common/domain_inversion.py
--- a/tryton/common/domain_inversion.py Mon Apr 11 23:41:21 2022 +0200
+++ b/tryton/common/domain_inversion.py Thu Apr 14 10:21:54 2022 +0200
@@ -307,9 +307,14 @@
 domain_op = bool_operator(domain)
 for branch in domain:
 simplified_branch = simplify_nested(branch)
-if (bool_operator(branch) == domain_op
+if (bool_operator(simplified_branch) == domain_op
 or len(simplified_branch) == 1):
-simplified.extend(simplified_branch)
+if (simplified
+and simplified_branch
+and simplified_branch[0] in ['AND', 'OR']):
+simplified.extend(simplified_branch[1:])
+else:
+simplified.extend(simplified_branch)
 else:
 simplified.append(simplified_branch)
 return simplified



[tryton-commits] changeset in sao:default Remove extra operator when simplifying ...

2022-04-14 Thread Nicolas Évrard
changeset f71d57b75ee9 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset=f71d57b75ee9
description:
Remove extra operator when simplifying nested domains

issue11406
review390621002
diffstat:

 src/common.js |  15 +++
 tests/sao.js  |   3 +++
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs (40 lines):

diff -r ad6e506af3ac -r f71d57b75ee9 src/common.js
--- a/src/common.js Wed Apr 13 19:07:40 2022 +0200
+++ b/src/common.js Thu Apr 14 10:21:53 2022 +0200
@@ -2574,12 +2574,19 @@
 return this.simplify_nested(domain[0]);
 } else {
 var simplified = [];
-var domain_op = this._bool_operator(domain);
 for (var branch of domain) {
 var simplified_branch = this.simplify_nested(branch);
-if ((this._bool_operator(branch) == domain_op) ||
-(simplified_branch.length == 1)) {
-simplified.push(...simplified_branch);
+if ((this._bool_operator(simplified_branch) ==
+this._bool_operator(simplified)) ||
+(simplified_branch.length == 1)) {
+if ((simplified.length > 0) &&
+(simplified_branch.length > 0) &&
+((simplified_branch[0] == 'AND') ||
+(simplified_branch[0] == 'OR'))) {
+simplified.push(...simplified_branch.slice(1));
+} else {
+simplified.push(...simplified_branch);
+}
 } else {
 simplified.push(simplified_branch);
 }
diff -r ad6e506af3ac -r f71d57b75ee9 tests/sao.js
--- a/tests/sao.js  Wed Apr 13 19:07:40 2022 +0200
+++ b/tests/sao.js  Thu Apr 14 10:21:53 2022 +0200
@@ -2612,6 +2612,9 @@
 [
 ['OR', ['x', '=', 3], ['AND', ['y', '=', 5]]],
 ['OR', ['x', '=', 3], ['y', '=', 5]]],
+[
+['OR', ['x', '=', 1], ['OR', ['x', '=', 2], ['x', '=', 3]]],
+['OR', ['x', '=', 1], ['x', '=', 2], ['x', '=', 3]]],
 [[['x', '=', 3], ['OR']], [['x', '=', 3]]],
 [['OR', ['x', '=', 3], []], []],
 [['OR', ['x', '=', 3], ['OR']], []],



[tryton-commits] changeset in modules/account_move_line_grouping:default Add dele...

2022-04-11 Thread Nicolas Évrard
changeset 943412699dfe in modules/account_move_line_grouping:default
details: 
https://hg.tryton.org/modules/account_move_line_grouping?cmd=changeset=943412699dfe
description:
Add delegated amount on lines to pay

issue10345
review346191002
diffstat:

 CHANGELOG |   1 +
 account.py|  16 +++-
 tests/scenario_account_move_line_grouping.rst |   5 -
 view/move_line_group_form.xml |   2 ++
 4 files changed, 22 insertions(+), 2 deletions(-)

diffs (87 lines):

diff -r 48a4abb19462 -r 943412699dfe CHANGELOG
--- a/CHANGELOG Sun Apr 10 19:11:37 2022 +0200
+++ b/CHANGELOG Mon Apr 11 19:19:54 2022 +0200
@@ -1,3 +1,4 @@
+* Add delegated amount on move lines
 * Add support for Python 3.10
 * Remove support for Python 3.6
 
diff -r 48a4abb19462 -r 943412699dfe account.py
--- a/account.pySun Apr 10 19:11:37 2022 +0200
+++ b/account.pyMon Apr 11 19:19:54 2022 +0200
@@ -1,7 +1,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.
 from sql import Literal, Null, Select, Window
-from sql.aggregate import BoolAnd, Min, Sum
+from sql.aggregate import BoolAnd, BoolOr, Min, Sum
 from sql.functions import CurrentTimestamp, FirstValue
 
 from trytond.model import ModelSQL, ModelView, fields
@@ -47,7 +47,16 @@
 'get_amount')
 amount_currency = fields.Function(fields.Many2One(
 'currency.currency', "Amount Currency"), 'get_amount_currency')
+delegated_amount = fields.Function(Monetary(
+"Delegated Amount",
+currency='amount_currency', digits='amount_currency',
+states={
+'invisible': ~Eval('partially_reconciled', False),
+}),
+'get_delegated_amount')
 
+partially_reconciled = fields.Boolean(
+"Partially Reconciled", readonly=True)
 reconciled = fields.Boolean("Reconciled", readonly=True)
 amount_reconciled = Monetary(
 "Amount Reconciled",
@@ -136,6 +145,7 @@
 Sum(line.debit).as_('debit'),
 Sum(line.credit).as_('credit'),
 Sum(line.amount_second_currency).as_('amount_second_currency'),
+BoolOr(line.reconciliation != Null).as_('partially_reconciled'),
 BoolAnd(line.reconciliation != Null).as_('reconciled'),
 Sum(
 line.debit + line.credit,
@@ -153,6 +163,10 @@
 if self.account:
 return self.account.currency.id
 
+def get_delegated_amount(self, name):
+return self.amount_currency.round(
+sum(l.delegated_amount for l in self.lines if l.delegated_amount))
+
 
 class MoveLineGroup_MoveLine(ModelSQL):
 "Account Move Line Group - Move Line"
diff -r 48a4abb19462 -r 943412699dfe 
tests/scenario_account_move_line_grouping.rst
--- a/tests/scenario_account_move_line_grouping.rst Sun Apr 10 19:11:37 
2022 +0200
+++ b/tests/scenario_account_move_line_grouping.rst Mon Apr 11 19:19:54 
2022 +0200
@@ -109,6 +109,10 @@
 ... ])
 >>> line.amount_reconciled == Decimal(22)
 True
+>>> line.partially_reconciled
+True
+>>> line.delegated_amount
+Decimal('0.00')
 >>> if backend.name != 'sqlite':
 ... len(line.lines)
 ... else:
@@ -125,4 +129,3 @@
 ... else:
 ... 1
 1
-
diff -r 48a4abb19462 -r 943412699dfe view/move_line_group_form.xml
--- a/view/move_line_group_form.xml Sun Apr 10 19:11:37 2022 +0200
+++ b/view/move_line_group_form.xml Mon Apr 11 19:19:54 2022 +0200
@@ -40,6 +40,8 @@
 
 
 
+
+
 
 
 



[tryton-commits] changeset in modules/account_invoice:default Add delegated amoun...

2022-04-11 Thread Nicolas Évrard
changeset 69d87d4691ea in modules/account_invoice:default
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset=69d87d4691ea
description:
Add delegated amount on lines to pay

issue10345
review346191002
diffstat:

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

diffs (11 lines):

diff -r 8c118af9986c -r 69d87d4691ea view/move_line_list_to_pay.xml
--- a/view/move_line_list_to_pay.xmlSun Apr 10 19:11:37 2022 +0200
+++ b/view/move_line_list_to_pay.xmlMon Apr 11 19:19:54 2022 +0200
@@ -5,5 +5,6 @@
 
 
 
-
+
+
 



[tryton-commits] changeset in modules/account:default Add delegated amount on lin...

2022-04-11 Thread Nicolas Évrard
changeset 56e9b82a66f1 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset=56e9b82a66f1
description:
Add delegated amount on lines to pay

issue10345
review346191002
diffstat:

 CHANGELOG  |   1 +
 move.py|  21 +
 tests/scenario_move_line_group.rst |  11 +++
 view/move_line_form.xml|   3 +++
 view/move_line_tree.xml|   1 +
 5 files changed, 37 insertions(+), 0 deletions(-)

diffs (97 lines):

diff -r 9307e7841f70 -r 56e9b82a66f1 CHANGELOG
--- a/CHANGELOG Sun Apr 10 19:11:37 2022 +0200
+++ b/CHANGELOG Mon Apr 11 19:19:54 2022 +0200
@@ -1,3 +1,4 @@
+* Add delegated amount on move lines
 * Enforce same type for children account as their parent
 * Show debit / credit columns in ledgers when they contain lines
 * Count number of lines in Account and General Ledger
diff -r 9307e7841f70 -r 56e9b82a66f1 move.py
--- a/move.py   Sun Apr 10 19:11:37 2022 +0200
+++ b/move.py   Mon Apr 11 19:19:54 2022 +0200
@@ -841,6 +841,13 @@
 'get_amount')
 amount_currency = fields.Function(fields.Many2One('currency.currency',
 'Amount Currency'), 'get_amount_currency')
+delegated_amount = fields.Function(Monetary(
+"Delegated Amount",
+currency='amount_currency', digits='amount_currency',
+states={
+'invisible': ~Eval('reconciliation', False),
+}),
+'get_delegated_amount')
 
 del _states
 
@@ -1035,6 +1042,20 @@
 order_move_origin = MoveLineMixin._order_move_field('origin')
 order_move_state = MoveLineMixin._order_move_field('state')
 
+def get_delegated_amount(self, name):
+def final_delegated_line(line):
+if not line.reconciliation or not line.reconciliation.delegate_to:
+return line
+return final_delegated_line(line.reconciliation.delegate_to)
+
+final_delegation = final_delegated_line(self)
+if final_delegation == self:
+return None
+elif final_delegation.reconciliation:
+return final_delegation.amount_currency.round(0)
+else:
+return final_delegation.amount
+
 @classmethod
 def query_get(cls, table):
 '''
diff -r 9307e7841f70 -r 56e9b82a66f1 tests/scenario_move_line_group.rst
--- a/tests/scenario_move_line_group.rstSun Apr 10 19:11:37 2022 +0200
+++ b/tests/scenario_move_line_group.rstMon Apr 11 19:19:54 2022 +0200
@@ -117,6 +117,14 @@
 >>> payable.balance, payable.amount_second_currency
 (Decimal('0.00'), Decimal('0.00'))
 
+>>> delegated_line1, delegated_line2 = lines
+>>> delegated_line1.reload()
+>>> delegated_line2.reload()
+>>> delegated_line1.delegated_amount
+Decimal('45')
+>>> delegated_line2.delegated_amount
+Decimal('45')
+
 >>> Reconciliation = Model.get('account.move.reconciliation')
 >>> reconciliations = Reconciliation.find([])
 >>> len(reconciliations)
@@ -151,3 +159,6 @@
>>> cancel.execute('cancel')
>>> Reconciliation.find([('id', '=', reconciliations[0].id)])
[]
+
+   >>> delegated_line1.reload()
+   >>> delegated_line1.delegated_amount
diff -r 9307e7841f70 -r 56e9b82a66f1 view/move_line_form.xml
--- a/view/move_line_form.xml   Sun Apr 10 19:11:37 2022 +0200
+++ b/view/move_line_form.xml   Mon Apr 11 19:19:54 2022 +0200
@@ -34,8 +34,11 @@
 
 
 
+
 
 
+
+
 
 
 
diff -r 9307e7841f70 -r 56e9b82a66f1 view/move_line_tree.xml
--- a/view/move_line_tree.xml   Sun Apr 10 19:11:37 2022 +0200
+++ b/view/move_line_tree.xml   Mon Apr 11 19:19:54 2022 +0200
@@ -11,6 +11,7 @@
 
 
 
+
 
 
 



[tryton-commits] changeset in tryton:default Use a file in the user directory for...

2022-04-11 Thread Nicolas Évrard
changeset e0688f8ac964 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=e0688f8ac964
description:
Use a file in the user directory for stdout and stderr on Windows

issue11390
review397911002
diffstat:

 CHANGELOG|   1 +
 bin/tryton   |   4 
 doc/usage.rst|   3 +++
 tryton/config.py |  12 +---
 4 files changed, 13 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r a1dac30e2d70 -r e0688f8ac964 CHANGELOG
--- a/CHANGELOG Mon Apr 11 12:48:41 2022 +0200
+++ b/CHANGELOG Mon Apr 11 16:37:34 2022 +0200
@@ -1,3 +1,4 @@
+* Add option to define logging output location
 * Remove TreeViewControl
 * Manage optional column
 * Default CSV encoding to UTF8 with BOM
diff -r a1dac30e2d70 -r e0688f8ac964 bin/tryton
--- a/bin/trytonMon Apr 11 12:48:41 2022 +0200
+++ b/bin/trytonMon Apr 11 16:37:34 2022 +0200
@@ -11,10 +11,6 @@
 pass
 
 if hasattr(sys, 'frozen'):
-if not ('-v' in sys.argv or '--verbose' in sys.argv or
-'-l' in sys.argv or '--log-level' in sys.argv):
-sys.stdout = open(os.devnull, 'w')
-sys.stderr = open(os.devnull, 'w')
 prefix = os.path.dirname(sys.executable)
 os.environ['GTK_EXE_PREFIX'] = prefix
 os.environ['GTK_DATA_PREFIX'] = prefix
diff -r a1dac30e2d70 -r e0688f8ac964 doc/usage.rst
--- a/doc/usage.rst Mon Apr 11 12:48:41 2022 +0200
+++ b/doc/usage.rst Mon Apr 11 16:37:34 2022 +0200
@@ -38,6 +38,9 @@
 -l LOG_LEVEL, --log-level=LOG_LEVEL  Specify the log level: DEBUG, INFO,
  WARNING, ERROR, CRITICAL
 
+-o LOG_OUTPUT, --log-ouput=LOG_OUTPUT Specify the file used to output logging
+  information
+
 -u LOGIN, --user=LOGIN   Specify the login user
 
 -s SERVER, --server=SERVER   Specify the server hostname:port
diff -r a1dac30e2d70 -r e0688f8ac964 tryton/config.py
--- a/tryton/config.py  Mon Apr 11 12:48:41 2022 +0200
+++ b/tryton/config.py  Mon Apr 11 16:37:34 2022 +0200
@@ -84,6 +84,8 @@
 parser.add_option("-l", "--log-level", dest="log_level",
 help=_("specify the log level: "
 "DEBUG, INFO, WARNING, ERROR, CRITICAL"))
+parser.add_option("-o", "--log-ouput", dest="log_output", default=None,
+help=_("specify the file used to output logging information"))
 parser.add_option("-u", "--user", dest="login",
 help=_("specify the login user"))
 parser.add_option("-s", "--server", dest="host",
@@ -93,8 +95,10 @@
 get_config_dir(), 'tryton.conf')
 self.load()
 
-self.options['dev'] = opt.dev
-logging.basicConfig()
+logging_config = {}
+if opt.log_output:
+logging_config['filename'] = opt.log_output
+
 loglevels = {
 'DEBUG': logging.DEBUG,
 'INFO': logging.INFO,
@@ -107,8 +111,10 @@
 opt.log_level = 'INFO'
 else:
 opt.log_level = 'ERROR'
-logging.getLogger().setLevel(loglevels[opt.log_level.upper()])
+logging_config['level'] = loglevels[opt.log_level.upper()]
+logging.basicConfig(**logging_config)
 
+self.options['dev'] = opt.dev
 for arg in ['login', 'host']:
 if getattr(opt, arg):
 self.options['login.' + arg] = getattr(opt, arg)



[tryton-commits] changeset in trytond:default Support _write, _delete and _timest...

2022-04-11 Thread Nicolas Évrard
changeset dec0a57b1d90 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=dec0a57b1d90
description:
Support _write, _delete and _timestamp values when set from default 
value

issue11012
review372751002
diffstat:

 doc/ref/models.rst |  5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (15 lines):

diff -r 51164f435179 -r dec0a57b1d90 doc/ref/models.rst
--- a/doc/ref/models.rstSun Apr 10 19:10:14 2022 +0200
+++ b/doc/ref/models.rstMon Apr 11 12:48:41 2022 +0200
@@ -285,6 +285,11 @@
``.``.
The number of *dots* in the name is not limited.
 
+   The virtual fields ``_write`` and ``_delete`` can be used the read the
+   writeable and deleteable state of the records.
+   Regarding the ``_timestamp`` virtual fields it contains a timestamp that is
+   used in the context to make a soft lock preventing update collisions.
+
.. note::
   The order of the returned list is not guaranteed.
 



[tryton-commits] changeset in tryton:default Support _write, _delete and _timesta...

2022-04-11 Thread Nicolas Évrard
changeset a1dac30e2d70 in tryton:default
details: https://hg.tryton.org/tryton?cmd=changeset=a1dac30e2d70
description:
Support _write, _delete and _timestamp values when set from default 
value

issue11012
review372751002
diffstat:

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

diffs (13 lines):

diff -r 70dae4f35b49 -r a1dac30e2d70 tryton/gui/window/view_form/model/record.py
--- a/tryton/gui/window/view_form/model/record.py   Wed Apr 06 23:37:45 
2022 +0200
+++ b/tryton/gui/window/view_form/model/record.py   Mon Apr 11 12:48:41 
2022 +0200
@@ -427,6 +427,9 @@
 def set_default(self, val, signal=True, validate=True):
 fieldnames = []
 for fieldname, value in list(val.items()):
+if fieldname in {'_write', '_delete', '_timestamp'}:
+setattr(self, fieldname, value)
+continue
 if fieldname not in self.group.fields:
 continue
 if fieldname == self.group.exclude_field:



[tryton-commits] changeset in sao:default Support _write, _delete and _timestamp ...

2022-04-11 Thread Nicolas Évrard
changeset d55dcdf12d28 in sao:default
details: https://hg.tryton.org/sao?cmd=changeset=d55dcdf12d28
description:
Support _write, _delete and _timestamp values when set from default 
value

issue11012
review372751002
diffstat:

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

diffs (16 lines):

diff -r 9efb7fa52876 -r d55dcdf12d28 src/model.js
--- a/src/model.js  Sun Apr 10 19:28:21 2022 +0200
+++ b/src/model.js  Mon Apr 11 12:48:41 2022 +0200
@@ -953,6 +953,12 @@
 var promises = [];
 var fieldnames = [];
 for (var fname in values) {
+if ((fname == '_write') ||
+(fname == '_delete') ||
+(fname == '_timestamp')) {
+this[fname] = values[fname];
+continue;
+}
 if (!values.hasOwnProperty(fname)) {
 continue;
 }



[tryton-commits] changeset in trytond:default Send only the required fields when ...

2022-04-08 Thread Nicolas Évrard
changeset 4ceb8ad07bd5 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset=4ceb8ad07bd5
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 CHANGELOG |   3 +++
 doc/ref/fields.rst|  17 -
 trytond/ir/email_.py  |   2 +-
 trytond/model/active.py   |   2 --
 trytond/model/fields/date.py  |  19 +--
 trytond/model/fields/field.py |  26 +++---
 trytond/model/fields/float.py |  22 +-
 trytond/model/fields/many2many.py |  19 ---
 trytond/model/fields/one2many.py  |  18 +++---
 trytond/model/fields/reference.py |  17 ++---
 trytond/model/modelstorage.py |   7 +++
 trytond/model/modelview.py|  24 ++--
 trytond/tests/modelview.py|  16 
 trytond/tests/modelview.xml   |  24 
 trytond/tests/test_modelview.py   |  22 ++
 trytond/tests/test_tryton.py  |  21 ++---
 16 files changed, 207 insertions(+), 52 deletions(-)

diffs (543 lines):

diff -r 7df5f88c1e60 -r 4ceb8ad07bd5 CHANGELOG
--- a/CHANGELOG Fri Apr 08 09:55:23 2022 +0200
+++ b/CHANGELOG Fri Apr 08 19:07:14 2022 +0200
@@ -1,3 +1,6 @@
+* Use a set for field's depends
+* Relax the constraint on a field's depends
+* Include only needed fields when fetching a view definition
 * Make warning check re-entrant
 * Manage DatabaseDataError in ModelSQL
 * Remove support for pysqlite2
diff -r 7df5f88c1e60 -r 4ceb8ad07bd5 doc/ref/fields.rst
--- a/doc/ref/fields.rstFri Apr 08 09:55:23 2022 +0200
+++ b/doc/ref/fields.rstFri Apr 08 19:07:14 2022 +0200
@@ -112,13 +112,28 @@
 
 .. attribute:: Field.depends
 
-   A list of field names on which the field depends.
+   A :py:class:`set` of extra field names on which the field depends.
 
This means that the client read also these fields even if they are not
defined on the view.
:attr:`Field.depends` is used for example to ensure that
:class:`~trytond.pyson.PYSON` statement could be evaluated.
 
+.. attribute:: Field.display_depends
+
+   A computed set of field names on which the field depends when being
+   displayed in a read only view.
+
+.. attribute:: Field.edition_depends
+
+   A computed set of field names on which the field depends when being
+   displayed in a writable view.
+
+.. attribute:: Field.validation_depends
+
+   A computed set of field names on which the field depends when being
+   validated.
+
 .. attribute:: Field.context
 
A dictionary which updates the current context for *relation field*.
diff -r 7df5f88c1e60 -r 4ceb8ad07bd5 trytond/ir/email_.py
--- a/trytond/ir/email_.py  Fri Apr 08 09:55:23 2022 +0200
+++ b/trytond/ir/email_.py  Fri Apr 08 19:07:14 2022 +0200
@@ -332,7 +332,7 @@
 ],
 ]
 ]
-field.depends.append('model')
+field.depends.add('model')
 cls.__rpc__.update({
 'get': RPC(instantiate=0),
 'get_default': RPC(),
diff -r 7df5f88c1e60 -r 4ceb8ad07bd5 trytond/model/active.py
--- a/trytond/model/active.py   Fri Apr 08 09:55:23 2022 +0200
+++ b/trytond/model/active.py   Fri Apr 08 19:07:14 2022 +0200
@@ -32,8 +32,6 @@
 field.states['readonly'] |= inactive
 else:
 field.states['readonly'] = inactive
-if 'active' not in field.depends:
-field.depends.append('active')
 
 if issubclass(cls, ModelView):
 for states in cls._buttons.values():
diff -r 7df5f88c1e60 -r 4ceb8ad07bd5 trytond/model/fields/date.py
--- a/trytond/model/fields/date.py  Fri Apr 08 09:55:23 2022 +0200
+++ b/trytond/model/fields/date.py  Fri Apr 08 19:07:14 2022 +0200
@@ -1,13 +1,14 @@
 # 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 datetime
+from functools import cached_property
 
 from sql.functions import AtTimeZone, Function
 
 from trytond import backend
-from trytond.pyson import PYSONEncoder
+from trytond.pyson import PYSON, PYSONEncoder
 
-from .field import Field
+from .field import Field, get_eval_fields
 
 
 class SQLite_Date(Function):
@@ -59,6 +60,20 @@
 definition['format'] = encoder.encode(self.format)
 return definition
 
+@cached_property
+def display_depends(self):
+depends = super().display_depends
+if isinstance(self.format, PYSON):
+depends |= get_eval_fields(self.format)
+return depends
+
+@cached_property
+def validation_depends(self):
+depends = super().display_depends
+if isinstance(self.format, PYSON):
+depends |= 

[tryton-commits] changeset in modules/web_user:default Send only the required fie...

2022-04-08 Thread Nicolas Évrard
changeset 784cb76aff7a in modules/web_user:default
details: https://hg.tryton.org/modules/web_user?cmd=changeset=784cb76aff7a
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (13 lines):

diff -r 00d3db4a79c3 -r 784cb76aff7a user.py
--- a/user.py   Fri Apr 08 09:46:11 2022 +0200
+++ b/user.py   Fri Apr 08 19:07:14 2022 +0200
@@ -72,8 +72,7 @@
 email = fields.Char('E-mail', select=True,
 states={
 'required': Eval('active', True),
-},
-depends=['active'])
+})
 email_valid = fields.Boolean('E-mail Valid')
 email_token = fields.Char('E-mail Token', select=True)
 password_hash = fields.Char('Password Hash')



[tryton-commits] changeset in modules/web_shop_vue_storefront:default Send only t...

2022-04-08 Thread Nicolas Évrard
changeset 04573aa647ee in modules/web_shop_vue_storefront:default
details: 
https://hg.tryton.org/modules/web_shop_vue_storefront?cmd=changeset=04573aa647ee
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 party.py |  3 +--
 web.py   |  6 ++
 2 files changed, 3 insertions(+), 6 deletions(-)

diffs (34 lines):

diff -r 36f7c33e8c9a -r 04573aa647ee party.py
--- a/party.py  Wed Apr 06 23:37:45 2022 +0200
+++ b/party.py  Fri Apr 08 19:07:14 2022 +0200
@@ -36,8 +36,7 @@
 domain=[
 ('party', '=', Eval('party', -1)),
 ('type', 'in', ['phone', 'mobile']),
-],
-depends=['party'])
+])
 
 def get_vsf(self, for_party=None):
 if for_party and for_party != self.party:
diff -r 36f7c33e8c9a -r 04573aa647ee web.py
--- a/web.pyWed Apr 06 23:37:45 2022 +0200
+++ b/web.pyFri Apr 08 19:07:14 2022 +0200
@@ -82,15 +82,13 @@
 states={
 'required': Eval('type') == 'vsf',
 'invisible': Eval('type') != 'vsf',
-},
-depends=['type'])
+})
 vsf_elasticsearch_index = fields.Char(
 "Elasticsearch Index",
 states={
 'required': Eval('type') == 'vsf',
 'invisible': Eval('type') != 'vsf',
-},
-depends=['type'])
+})
 
 @classmethod
 def __setup__(cls):



[tryton-commits] changeset in modules/web_shop_shopify:default Send only the requ...

2022-04-08 Thread Nicolas Évrard
changeset 9e0083eba168 in modules/web_shop_shopify:default
details: 
https://hg.tryton.org/modules/web_shop_shopify?cmd=changeset=9e0083eba168
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 product.py |  12 
 web.py |  19 +++
 2 files changed, 11 insertions(+), 20 deletions(-)

diffs (101 lines):

diff -r 631a1eb1c574 -r 9e0083eba168 product.py
--- a/product.pyWed Apr 06 23:37:45 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -75,7 +75,7 @@
 'readonly': Bool(Eval('shopify_identifiers', [-1])),
 'invisible': ~Eval('salable', False),
 },
-depends=['default_uom_category', 'shopify_identifiers', 'salable'])
+depends={'default_uom_category'})
 
 @classmethod
 def __setup__(cls):
@@ -89,7 +89,6 @@
 ('category', 'in', [Eval(c, -1) for c in categories]),
 ('digits', '=', 0),
 ]
-cls.shopify_uom.depends.extend(categories)
 
 @classmethod
 def _shopify_uom_categories(cls):
@@ -471,8 +470,7 @@
 If(Eval('shopify_option3'),
 ('id', '!=', Eval('shopify_option3')),
 ()),
-],
-depends=['attributes', 'shopify_option2', 'shopify_option3'])
+])
 shopify_option2 = fields.Many2One(
 'product.attribute', "Option 2",
 domain=[
@@ -486,8 +484,7 @@
 ],
 states={
 'invisible': ~Eval('shopify_option1'),
-},
-depends=['attributes', 'shopify_option1', 'shopify_option3'])
+})
 shopify_option3 = fields.Many2One(
 'product.attribute', "Option 3",
 domain=[
@@ -501,8 +498,7 @@
 ],
 states={
 'invisible': ~Eval('shopify_option2'),
-},
-depends=['attributes', 'shopify_option1', 'shopify_option2'])
+})
 
 @classmethod
 def __setup__(cls):
diff -r 631a1eb1c574 -r 9e0083eba168 web.py
--- a/web.pyWed Apr 06 23:37:45 2022 +0200
+++ b/web.pyFri Apr 08 19:07:14 2022 +0200
@@ -32,32 +32,28 @@
 'required': Eval('type') == 'shopify',
 'invisible': Eval('type') != 'shopify',
 }
-_depends = ['type']
 
-shopify_url = fields.Char("Shop URL", states=_states, depends=_depends)
+shopify_url = fields.Char("Shop URL", states=_states)
 shopify_version = fields.Selection(
-'get_shopify_versions', "Version", states=_states, depends=_depends)
-shopify_password = fields.Char(
-"Password", states=_states, depends=_depends)
+'get_shopify_versions', "Version", states=_states)
+shopify_password = fields.Char("Password", states=_states)
 shopify_webhook_shared_secret = fields.Char(
 "Webhook Shared Secret",
 states={
 'invisible': _states['invisible'],
-},
-depends=_depends)
+})
 shopify_webhook_endpoint_order = fields.Function(
 fields.Char(
 "Webhook Order Endpoint",
 help="The URL to be called by Shopify for Order events."),
 'on_change_with_shopify_webhook_endpoint_order')
 shopify_warehouses = fields.One2Many(
-'web.shop-stock.location', 'shop', "Warehouses",
-states=_states, depends=_depends)
+'web.shop-stock.location', 'shop', "Warehouses", states=_states)
 shopify_payment_journals = fields.One2Many(
 'web.shop.shopify_payment_journal', 'shop', "Payment Journals",
-states=_states, depends=_depends)
+states=_states)
 
-del _states, _depends
+del _states
 
 @classmethod
 def __setup__(cls):
@@ -69,7 +65,6 @@
 field.states['invisible'] |= invisible
 else:
 field.states['invisible'] = invisible
-field.depends.append('type')
 
 @classmethod
 def get_shopify_versions(cls):



[tryton-commits] changeset in modules/web_shop:default Send only the required fie...

2022-04-08 Thread Nicolas Évrard
changeset 31883463311b in modules/web_shop:default
details: https://hg.tryton.org/modules/web_shop?cmd=changeset=31883463311b
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 product.py |   1 -
 sale.py|   3 +--
 web.py |  16 +++-
 3 files changed, 8 insertions(+), 12 deletions(-)

diffs (85 lines):

diff -r 895c459ace78 -r 31883463311b product.py
--- a/product.pyWed Apr 06 23:37:45 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -25,7 +25,6 @@
 states={
 'invisible': ~Eval('salable'),
 },
-depends=['salable'],
 help="The list of web shops on which the product is published.")
 
 
diff -r 895c459ace78 -r 31883463311b sale.py
--- a/sale.py   Wed Apr 06 23:37:45 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -21,8 +21,7 @@
 states={
 'required': Bool(Eval('web_shop')),
 'readonly': ~Eval('web_id'),
-},
-depends=['web_shop'])
+})
 
 @classmethod
 def __setup__(cls):
diff -r 895c459ace78 -r 31883463311b web.py
--- a/web.pyWed Apr 06 23:37:45 2022 +0200
+++ b/web.pyFri Apr 08 19:07:14 2022 +0200
@@ -69,7 +69,7 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['company'])
+depends={'company'})
 
 products = fields.Many2Many(
 'web.shop-product.product', 'shop', 'product', "Products",
@@ -79,14 +79,14 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['company'],
+depends={'company'},
 help="The list of products to publish.")
 products_removed = Many2ManyInactive(
 'web.shop-product.product', 'shop', 'product', "Products Removed",
 context={
 'company': Eval('company', -1),
 },
-depends=['company'],
+depends={'company'},
 help="The list of products to unpublish.")
 
 categories = fields.Many2Many(
@@ -94,14 +94,14 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['company'],
+depends={'company'},
 help="The list of categories to publish.")
 categories_removed = Many2ManyInactive(
 'web.shop-product.category', 'shop', 'category', "Categories Removed",
 context={
 'company': Eval('company', -1),
 },
-depends=['company'],
+depends={'company'},
 help="The list of categories to unpublish.")
 
 _name_cache = Cache('web.shop.name', context=False)
@@ -325,12 +325,10 @@
 domain=['OR',
 ('party', '=', Eval('party', -1)),
 ('party', 'in', Eval('secondary_parties', [])),
-],
-depends=['party', 'secondary_parties'])
+])
 shipment_address = fields.Many2One(
 'party.address', "Shipment Address",
 domain=['OR',
 ('party', '=', Eval('party', -1)),
 ('party', 'in', Eval('secondary_parties', [])),
-],
-depends=['party', 'secondary_parties'])
+])



[tryton-commits] changeset in modules/user_role:default Send only the required fi...

2022-04-08 Thread Nicolas Évrard
changeset bca0085906ce in modules/user_role:default
details: https://hg.tryton.org/modules/user_role?cmd=changeset=bca0085906ce
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (22 lines):

diff -r f118b84951b9 -r bca0085906ce res.py
--- a/res.pyWed Apr 06 23:37:45 2022 +0200
+++ b/res.pyFri Apr 08 19:07:14 2022 +0200
@@ -98,16 +98,14 @@
 If(Eval('from_date') & Eval('to_date'),
 ('from_date', '<=', Eval('to_date', None)),
 ()),
-],
-depends=['to_date'])
+])
 to_date = fields.Date(
 "To Date",
 domain=[
 If(Eval('from_date') & Eval('to_date'),
 ('to_date', '>=', Eval('from_date', None)),
 ()),
-],
-depends=['from_date'])
+])
 
 @classmethod
 def __setup__(cls):



[tryton-commits] changeset in modules/timesheet:default Send only the required fi...

2022-04-08 Thread Nicolas Évrard
changeset 8294ff41a637 in modules/timesheet:default
details: https://hg.tryton.org/modules/timesheet?cmd=changeset=8294ff41a637
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 line.py |  3 ---
 work.py |  4 
 2 files changed, 0 insertions(+), 7 deletions(-)

diffs (61 lines):

diff -r cbb75a7bbe60 -r 8294ff41a637 line.py
--- a/line.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/line.py   Fri Apr 08 19:07:14 2022 +0200
@@ -34,7 +34,6 @@
 ('end_date', '>=', Eval('date', None)),
 ],
 ],
-depends=['company', 'date'],
 help="The employee who spends the time.")
 date = fields.Date('Date', required=True, select=True,
 help="When the time is spent.")
@@ -51,7 +50,6 @@
 ('timesheet_end_date', '>=', Eval('date', None)),
 ],
 ],
-depends=['date', 'company'],
 help="The work on which the time is spent.")
 description = fields.Char('Description',
 help="Additional description of the work done.")
@@ -177,7 +175,6 @@
 ('end_date', '>=', Eval('date', None)),
 ],
 ],
-depends=['date'],
 help="The employee who spends the time.")
 date = fields.Date('Date', required=True,
 help="When the time is spent.")
diff -r cbb75a7bbe60 -r 8294ff41a637 work.py
--- a/work.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/work.py   Fri Apr 08 19:07:14 2022 +0200
@@ -24,14 +24,12 @@
 'invisible': Bool(Eval('origin')),
 'required': ~Eval('origin'),
 },
-depends=['origin'],
 help="The main identifier of the work.")
 origin = fields.Reference('Origin', selection='get_origin',
 states={
 'invisible': Bool(Eval('name')),
 'required': ~Eval('name'),
 },
-depends=['name'],
 help="Use to relate the time spent to other records.")
 duration = fields.Function(fields.TimeDelta('Timesheet Duration',
 'company_work_time', help="Total time spent on this work."),
@@ -42,7 +40,6 @@
 ('timesheet_start_date', '<=', Eval('timesheet_end_date')),
 ()),
 ],
-depends=['timesheet_end_date'],
 help="Restrict adding lines before the date.")
 timesheet_end_date = fields.Date('Timesheet End',
 domain=[
@@ -50,7 +47,6 @@
 ('timesheet_end_date', '>=', Eval('timesheet_start_date')),
 ()),
 ],
-depends=['timesheet_start_date'],
 help="Restrict adding lines after the date.")
 company = fields.Many2One('company.company', 'Company', required=True,
 select=True, help="Make the work belong to the company.")



[tryton-commits] changeset in modules/stock_supply_production:default Send only t...

2022-04-08 Thread Nicolas Évrard
changeset e62a415e9559 in modules/stock_supply_production:default
details: 
https://hg.tryton.org/modules/stock_supply_production?cmd=changeset=e62a415e9559
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (12 lines):

diff -r 6edaaba16b00 -r e62a415e9559 stock.py
--- a/stock.py  Thu Apr 07 00:06:34 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -22,8 +22,6 @@
 ('producible', '=', True),
 ()),
 ]
-if 'type' not in cls.product.depends:
-cls.product.depends.append('type')
 
 cls.warehouse_location.states['invisible'] &= (
 Eval('type') != 'production')



[tryton-commits] changeset in modules/stock_supply:default Send only the required...

2022-04-08 Thread Nicolas Évrard
changeset 8d07467c9b63 in modules/stock_supply:default
details: 
https://hg.tryton.org/modules/stock_supply?cmd=changeset=8d07467c9b63
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 location.py|   2 --
 order_point.py |  23 ---
 2 files changed, 8 insertions(+), 17 deletions(-)

diffs (99 lines):

diff -r 0fb7b188fb26 -r 8d07467c9b63 location.py
--- a/location.py   Thu Apr 07 00:06:34 2022 +0200
+++ b/location.py   Fri Apr 08 19:07:14 2022 +0200
@@ -18,7 +18,6 @@
 domain=[
 ('type', 'in', ['storage', 'view']),
 ],
-depends=['type'],
 help='Leave empty for no default provisioning.')
 overflowing_location = fields.Many2One('stock.location',
 'Overflowing Location',
@@ -28,7 +27,6 @@
 domain=[
 ('type', 'in', ['storage', 'view']),
 ],
-depends=['type'],
 help='Leave empty for no default overflowing.')
 
 
diff -r 0fb7b188fb26 -r 8d07467c9b63 order_point.py
--- a/order_point.pyThu Apr 07 00:06:34 2022 +0200
+++ b/order_point.pyFri Apr 08 19:07:14 2022 +0200
@@ -30,23 +30,21 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['type', 'company'])
+depends={'company'})
 warehouse_location = fields.Many2One('stock.location',
 'Warehouse Location', select=True,
 domain=[('type', '=', 'warehouse')],
 states={
 'invisible': Not(Equal(Eval('type'), 'purchase')),
 'required': Equal(Eval('type'), 'purchase'),
-},
-depends=['type'])
+})
 storage_location = fields.Many2One('stock.location', 'Storage Location',
 select=True,
 domain=[('type', '=', 'storage')],
 states={
 'invisible': Not(Equal(Eval('type'), 'internal')),
 'required': Equal(Eval('type'), 'internal'),
-},
-depends=['type'])
+})
 location = fields.Function(fields.Many2One('stock.location', 'Location'),
 'get_location', searcher='search_location')
 provisioning_location = fields.Many2One(
@@ -56,8 +54,7 @@
 'invisible': Not(Equal(Eval('type'), 'internal')),
 'required': ((Eval('type') == 'internal')
 & (Eval('min_quantity', None) != None)),  # noqa: E711
-},
-depends=['type', 'min_quantity'])
+})
 overflowing_location = fields.Many2One(
 'stock.location', 'Overflowing Location',
 domain=[('type', 'in', ['storage', 'view'])],
@@ -65,8 +62,7 @@
 'invisible': Eval('type') != 'internal',
 'required': ((Eval('type') == 'internal')
 & (Eval('max_quantity', None) != None)),  # noqa: E711
-},
-depends=['type', 'max_quantity'])
+})
 type = fields.Selection(
 [('internal', 'Internal'),
  ('purchase', 'Purchase')],
@@ -80,8 +76,7 @@
 domain=['OR',
 ('min_quantity', '=', None),
 ('min_quantity', '<=', Eval('target_quantity', 0)),
-],
-depends=['target_quantity', 'type'])
+])
 target_quantity = fields.Float(
 "Target Quantity", digits='unit', required=True,
 domain=[
@@ -93,8 +88,7 @@
 ('max_quantity', '=', None),
 ('target_quantity', '<=', Eval('max_quantity', 0)),
 ],
-],
-depends=['min_quantity', 'max_quantity'])
+])
 max_quantity = fields.Float(
 "Maximal Quantity", digits='unit',
 states={
@@ -103,8 +97,7 @@
 domain=['OR',
 ('max_quantity', '=', None),
 ('max_quantity', '>=', Eval('target_quantity', 0)),
-],
-depends=['type', 'target_quantity'])
+])
 company = fields.Many2One('company.company', 'Company', required=True,
 domain=[
 ('id', If(In('company', Eval('context', {})), '=', '!='),



[tryton-commits] changeset in modules/stock_split:default Send only the required ...

2022-04-08 Thread Nicolas Évrard
changeset 0ee8bce1756e in modules/stock_split:default
details: 
https://hg.tryton.org/modules/stock_split?cmd=changeset=0ee8bce1756e
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (20 lines):

diff -r 60c1b5038a7f -r 0ee8bce1756e stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -82,8 +82,7 @@
 uom = fields.Many2One('product.uom', 'Uom', required=True,
 domain=[
 ('category', '=', Eval('uom_category')),
-],
-depends=['uom_category'])
+])
 uom_category = fields.Many2One('product.uom.category', 'Uom Category',
 readonly=True)
 
@@ -194,6 +193,5 @@
 moves = fields.Many2Many(
 'stock.move', None, None, "Moves",
 domain=[('id', 'in', Eval('domain_moves'))],
-depends=['domain_moves'],
 help="The selected moves will be sent in the new shipment.")
 domain_moves = fields.Many2Many('stock.move', None, None, "Domain Moves")



[tryton-commits] changeset in modules/stock_shipment_measurements:default Send on...

2022-04-08 Thread Nicolas Évrard
changeset 959e711bcf2e in modules/stock_shipment_measurements:default
details: 
https://hg.tryton.org/modules/stock_shipment_measurements?cmd=changeset=959e711bcf2e
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (13 lines):

diff -r 404e5da2f5fc -r 959e711bcf2e stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -368,8 +368,7 @@
 domain=[('category', '=', Id('product', 'uom_cat_weight'))],
 states={
 'required': Bool(Eval('additional_weight')),
-},
-depends=['additional_weight'])
+})
 total_weight = fields.Function(
 fields.Float(
 "Total Weight", digits='weight_uom',



[tryton-commits] changeset in modules/stock_shipment_cost:default Send only the r...

2022-04-08 Thread Nicolas Évrard
changeset 16c1f78214c1 in modules/stock_shipment_cost:default
details: 
https://hg.tryton.org/modules/stock_shipment_cost?cmd=changeset=16c1f78214c1
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (36 lines):

diff -r 03fdd68fed45 -r 16c1f78214c1 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -30,29 +30,25 @@
 
 carrier = fields.Many2One('carrier', 'Carrier', states={
 'readonly': Eval('state').in_(['done', 'cancelled']),
-},
-depends=['state'])
+})
 
 cost_used = fields.Function(fields.Numeric(
 "Cost", digits=price_digits,
 states={
 'invisible': Eval('cost_edit', False),
-},
-depends=['cost_edit']),
+}),
 'on_change_with_cost_used')
 cost = fields.Numeric(
 "Cost", digits=price_digits,
 states={
 'invisible': ~Eval('cost_edit', False),
 'readonly': Eval('state').in_(['done', 'cancelled']),
-},
-depends=['state'])
+})
 cost_edit = fields.Boolean(
 "Edit Cost",
 states={
 'readonly': Eval('state').in_(['done', 'cancelled']),
 },
-depends=['state'],
 help="Check to edit the cost.")
 
 def _get_carrier_context(self):



[tryton-commits] changeset in modules/stock_secondary_unit:default Send only the ...

2022-04-08 Thread Nicolas Évrard
changeset 6b25aefed1a6 in modules/stock_secondary_unit:default
details: 
https://hg.tryton.org/modules/stock_secondary_unit?cmd=changeset=6b25aefed1a6
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (33 lines):

diff -r 9235a2bc8d67 -r 6b25aefed1a6 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -16,8 +16,7 @@
 'invisible': ~Eval('secondary_unit'),
 'readonly': Eval('state').in_(
 ['cancelled', 'assigned', 'done']),
-},
-depends=['secondary_unit', 'state']),
+}),
 'on_change_with_secondary_quantity', setter='set_secondary')
 secondary_unit = fields.Many2One(
 'product.uom', "Secondary Unit", ondelete='RESTRICT',
@@ -27,8 +26,7 @@
 states={
 'invisible': ~Eval('product_secondary_uom_category'),
 'readonly': Eval('state').in_(['cancelled', 'assigned', 'done']),
-},
-depends=['product_secondary_uom_category', 'state'])
+})
 secondary_unit_price = fields.Function(
 Monetary(
 "Secondary Unit Price", currency='currency', digits=price_digits,
@@ -36,8 +34,7 @@
 'invisible': (~Eval('unit_price_required')
 | ~Eval('secondary_unit')),
 'readonly': Eval('state') != 'draft',
-},
-depends=['unit_price_required', 'secondary_unit', 'state']),
+}),
 'on_change_with_secondary_unit_price', setter='set_secondary')
 
 product_secondary_uom_category = fields.Function(



[tryton-commits] changeset in modules/stock_quantity_issue:default Send only the ...

2022-04-08 Thread Nicolas Évrard
changeset c50097fc4f1f in modules/stock_quantity_issue:default
details: 
https://hg.tryton.org/modules/stock_quantity_issue?cmd=changeset=c50097fc4f1f
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (22 lines):

diff -r c64e3cc86850 -r c50097fc4f1f stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -36,8 +36,7 @@
 'stock.shipment.internal': [
 ('company', '=', Eval('company', -1)),
 ],
-},
-depends=['company'])
+})
 planned_date = fields.Function(
 fields.Date("Planned Date"),
 'on_change_with_planned_date')
@@ -60,7 +59,7 @@
 'stock_skip_warehouse': False,
 'stock_date_end': Eval('planned_date'),
 },
-depends=['company', 'warehouse', 'planned_date'])
+depends={'company', 'warehouse', 'planned_date'})
 
 processed_by = employee_field("Processed by", states=['processing'])
 solved_by = employee_field("Solved by", states=['solved'])



[tryton-commits] changeset in modules/stock_quantity_early_planning:default Send ...

2022-04-08 Thread Nicolas Évrard
changeset 7b62c2ccfb93 in modules/stock_quantity_early_planning:default
details: 
https://hg.tryton.org/modules/stock_quantity_early_planning?cmd=changeset=7b62c2ccfb93
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (23 lines):

diff -r d62bbb9aae28 -r 7b62c2ccfb93 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -34,8 +34,7 @@
 'stock.shipment.internal': [
 ('company', '=', Eval('company', -1)),
 ],
-},
-depends=['company'])
+})
 planned_date = fields.Function(
 fields.Date("Planned Date"),
 'on_change_with_planned_date')
@@ -58,8 +57,7 @@
 "Earliest Percentage", digits=(1, 4),
 states={
 'invisible': ~Eval('earliest_date'),
-},
-depends=['earliest_date']),
+}),
 'get_earliest_percentage')
 warehouse = fields.Function(
 fields.Many2One('stock.location', "Warehouse"),



[tryton-commits] changeset in modules/stock_product_location:default Send only th...

2022-04-08 Thread Nicolas Évrard
changeset 0606a48d4b33 in modules/stock_product_location:default
details: 
https://hg.tryton.org/modules/stock_product_location?cmd=changeset=0606a48d4b33
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 location.py |  8 +++-
 product.py  |  6 ++
 2 files changed, 5 insertions(+), 9 deletions(-)

diffs (54 lines):

diff -r e35d2fda73f6 -r 0606a48d4b33 location.py
--- a/location.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/location.py   Fri Apr 08 19:07:14 2022 +0200
@@ -19,16 +19,14 @@
 If(Bool(Eval('product')),
 ('products', '=', Eval('product')),
 ()),
-],
-depends=['product'])
+])
 product = fields.Many2One(
 'product.product', "Variant", ondelete='CASCADE', select=True,
 domain=[
 If(Bool(Eval('template')),
 ('template', '=', Eval('template')),
 ()),
-],
-depends=['template'])
+])
 warehouse = fields.Many2One('stock.location', 'Warehouse', required=True,
 domain=[('type', '=', 'warehouse')], ondelete='CASCADE')
 location = fields.Many2One('stock.location', 'Storage Location',
@@ -37,7 +35,7 @@
 ('type', '=', 'storage'),
 ('parent', 'child_of', If(Bool(Eval('warehouse')),
 [Eval('warehouse')], [])),
-], depends=['warehouse'])
+])
 
 @classmethod
 def __register__(cls, module_name):
diff -r e35d2fda73f6 -r 0606a48d4b33 product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -11,8 +11,7 @@
 "Default Locations",
 states={
 'invisible': ~Eval('type').in_(['goods', 'assets']),
-},
-depends=['type'])
+})
 
 @classmethod
 def copy(cls, templates, default=None):
@@ -48,8 +47,7 @@
 ],
 states={
 'invisible': ~Eval('type').in_(['goods', 'assets']),
-},
-depends=['type', 'template'])
+})
 
 @classmethod
 def copy(cls, products, default=None):



[tryton-commits] changeset in modules/stock_package_shipping_ups:default Send onl...

2022-04-08 Thread Nicolas Évrard
changeset 4aa328383509 in modules/stock_package_shipping_ups:default
details: 
https://hg.tryton.org/modules/stock_package_shipping_ups?cmd=changeset=4aa328383509
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 carrier.py |  12 
 1 files changed, 4 insertions(+), 8 deletions(-)

diffs (43 lines):

diff -r efe30bca2b9c -r 4aa328383509 carrier.py
--- a/carrier.pyWed Apr 06 23:37:44 2022 +0200
+++ b/carrier.pyFri Apr 08 19:07:14 2022 +0200
@@ -63,8 +63,7 @@
 states={
 'required': Eval('shipping_service') == 'ups',
 'invisible': Eval('shipping_service') != 'ups',
-},
-depends=['shipping_service'])
+})
 ups_label_image_format = fields.Selection([
 (None, ''),
 ('EPL', 'EPL2'),
@@ -76,8 +75,7 @@
 states={
 'required': Eval('shipping_service') == 'ups',
 'invisible': Eval('shipping_service') != 'ups',
-},
-depends=['shipping_service'])
+})
 ups_label_height = fields.Selection([
 (None, ''),
 ('6', '6'),
@@ -88,8 +86,7 @@
 & (Eval('ups_label_image_format') != 'GIF')),
 'invisible': ((Eval('shipping_service') != 'ups')
 | (Eval('ups_label_image_format') == 'GIF')),
-},
-depends=['shipping_service', 'ups_label_image_format'])
+})
 ups_notifications = fields.MultiSelection([
 ('5', "Quantum View In-transit"),
 ('6', "Quantum View Shop"),
@@ -101,8 +98,7 @@
 ], "Notifications", sort=False,
 states={
 'invisible': Eval('shipping_service') != 'ups',
-},
-depends=['shipping_service'])
+})
 
 @classmethod
 def __setup__(cls):



[tryton-commits] changeset in modules/stock_package_shipping_sendcloud:default Se...

2022-04-08 Thread Nicolas Évrard
changeset b77b97a3eef4 in modules/stock_package_shipping_sendcloud:default
details: 
https://hg.tryton.org/modules/stock_package_shipping_sendcloud?cmd=changeset=b77b97a3eef4
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (30 lines):

diff -r b6fcc1bf5be4 -r b77b97a3eef4 carrier.py
--- a/carrier.pyWed Apr 06 23:37:44 2022 +0200
+++ b/carrier.pyFri Apr 08 19:07:14 2022 +0200
@@ -60,14 +60,12 @@
 'carrier.sendcloud.address', 'sendcloud', "Addresses",
 states={
 'readonly': ~Eval('id') | (Eval('id', -1) < 0),
-},
-depends=['id'])
+})
 shipping_methods = fields.One2Many(
 'carrier.sendcloud.shipping_method', 'sendcloud', "Methods",
 states={
 'readonly': ~Eval('id') | (Eval('id', -1) < 0),
-},
-depends=['id'])
+})
 
 _addresses_sender_cache = Cache(
 'carrier.credential.sendcloud.addresses_sender',
@@ -252,8 +250,7 @@
 states={
 'invisible': Eval('shipping_service') != 'sendcloud',
 'required': Eval('shipping_service') == 'sendcloud',
-},
-depends=['shipping_service'])
+})
 
 @classmethod
 def __setup__(cls):



[tryton-commits] changeset in modules/stock_package_shipping_mygls:default Send o...

2022-04-08 Thread Nicolas Évrard
changeset dfb918f9ac8a in modules/stock_package_shipping_mygls:default
details: 
https://hg.tryton.org/modules/stock_package_shipping_mygls?cmd=changeset=dfb918f9ac8a
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 carrier.py |  10 +++---
 1 files changed, 3 insertions(+), 7 deletions(-)

diffs (41 lines):

diff -r 8a3e96d47a26 -r dfb918f9ac8a carrier.py
--- a/carrier.pyWed Apr 06 23:37:44 2022 +0200
+++ b/carrier.pyFri Apr 08 19:07:14 2022 +0200
@@ -44,8 +44,7 @@
 ], "Type of Printer", sort=False, translate=False,
 states={
 'invisible': Eval('shipping_service') != 'mygls',
-},
-depends=['shipping_service'])
+})
 mygls_print_position = fields.Integer(
 "Print Position",
 domain=[
@@ -58,8 +57,7 @@
 'invisible': (
 (Eval('mygls_type_of_printer') != 'A4_2x2')
 | (Eval('shipping_service') != 'mygls')),
-},
-depends=['mygls_type_of_printer', 'shipping_service'])
+})
 mygls_services = fields.MultiSelection([
 ('24h', "Service guaranteed delivery shipment in 24 Hours"),
 ('AOS', "Addressee Only Service"),
@@ -80,8 +78,7 @@
 ], "Services",
 states={
 'invisible': Eval('shipping_service') != 'mygls',
-},
-depends=['shipping_service'])
+})
 
 mygls_sms = fields.Char(
 "SMS", translate=True,
@@ -89,7 +86,6 @@
 'invisible': Eval('shipping_service') != 'mygls',
 'required': Eval('mygls_services', []).contains('SM1'),
 },
-depends=['shipping_service', 'mygls_services'],
 help="Variables that can be used in the text of the SMS:\n"
 "ParcelNr#, #COD#, #PickupDate#, #From_Name#, #ClientRef#")
 



[tryton-commits] changeset in modules/stock_package_shipping_dpd:default Send onl...

2022-04-08 Thread Nicolas Évrard
changeset c37274cc143c in modules/stock_package_shipping_dpd:default
details: 
https://hg.tryton.org/modules/stock_package_shipping_dpd?cmd=changeset=c37274cc143c
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (33 lines):

diff -r e915e8f6a460 -r c37274cc143c carrier.py
--- a/carrier.pyWed Apr 06 23:37:44 2022 +0200
+++ b/carrier.pyFri Apr 08 19:07:14 2022 +0200
@@ -71,8 +71,7 @@
 states={
 'required': Eval('shipping_service') == 'dpd',
 'invisible': Eval('shipping_service') != 'dpd',
-},
-depends=['shipping_service'])
+})
 dpd_printer_language = fields.Selection([
 (None, ''),
 ('PDF', "PDF"),
@@ -81,8 +80,7 @@
 states={
 'required': Eval('shipping_service') == 'dpd',
 'invisible': Eval('shipping_service') != 'dpd',
-},
-depends=['shipping_service'])
+})
 dpd_paper_format = fields.Selection([
 (None, ''),
 ('A4', "A4"),
@@ -92,8 +90,7 @@
 states={
 'required': Eval('shipping_service') == 'dpd',
 'invisible': Eval('shipping_service') != 'dpd',
-},
-depends=['shipping_service'])
+})
 
 @classmethod
 def __setup__(cls):



[tryton-commits] changeset in modules/stock_package_shipping:default Send only th...

2022-04-08 Thread Nicolas Évrard
changeset 7f6aadaf0351 in modules/stock_package_shipping:default
details: 
https://hg.tryton.org/modules/stock_package_shipping?cmd=changeset=7f6aadaf0351
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 stock.py |  21 -
 1 files changed, 8 insertions(+), 13 deletions(-)

diffs (70 lines):

diff -r e9d2ba0c6189 -r 7f6aadaf0351 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -27,8 +27,7 @@
 class DimensionsMixin(object):
 __slots__ = ()
 
-length = fields.Float('Length', digits=(16, Eval('length_digits', 2)),
-depends=['length_digits'])
+length = fields.Float('Length', digits=(16, Eval('length_digits', 2)))
 length_uom = fields.Many2One('product.uom', 'Length Unit',
 domain=[
 ('category', '=', Id('product', 'uom_cat_length')),
@@ -36,11 +35,10 @@
 states={
 'required': Bool(Eval('length')),
 },
-depends=['length', 'length_digits'])
+depends={'length_digits'})
 length_digits = fields.Function(fields.Integer('Length Digits'),
 'on_change_with_length_digits')
-height = fields.Float('Height', digits=(16, Eval('height_digits', 2)),
-depends=['height_digits'])
+height = fields.Float('Height', digits=(16, Eval('height_digits', 2)))
 height_uom = fields.Many2One('product.uom', 'Height Unit',
 domain=[
 ('category', '=', Id('product', 'uom_cat_length')),
@@ -48,11 +46,10 @@
 states={
 'required': Bool(Eval('height')),
 },
-depends=['height', 'height_digits'])
+depends={'height_digits'})
 height_digits = fields.Function(fields.Integer('Height Digits'),
 'on_change_with_height_digits')
-width = fields.Float('Width', digits=(16, Eval('width_digits', 2)),
-depends=['width_digits'])
+width = fields.Float('Width', digits=(16, Eval('width_digits', 2)))
 width_uom = fields.Many2One('product.uom', 'Width Unit',
 domain=[
 ('category', '=', Id('product', 'uom_cat_length')),
@@ -60,7 +57,7 @@
 states={
 'required': Bool(Eval('width')),
 },
-depends=['width', 'width_digits'])
+depends={'width_digits'})
 width_digits = fields.Function(fields.Integer('Width Digits'),
 'on_change_with_width_digits')
 
@@ -198,8 +195,7 @@
 shipping_description = fields.Char('Shipping Description',
 states={
 'readonly': Eval('state').in_(['done', 'packed'])
-},
-depends=['state'])
+})
 
 @classmethod
 def __setup__(cls):
@@ -324,8 +320,7 @@
 'carrier', "Carrier",
 states={
 'readonly': ~Eval('state').in_(['draft', 'waiting', 'assigned']),
-},
-depends=['state'])
+})
 
 @classmethod
 @ModelView.button



[tryton-commits] changeset in modules/stock_package:default Send only the require...

2022-04-08 Thread Nicolas Évrard
changeset c35f60a8ad8d in modules/stock_package:default
details: 
https://hg.tryton.org/modules/stock_package?cmd=changeset=c35f60a8ad8d
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 stock.py |  34 ++
 1 files changed, 10 insertions(+), 24 deletions(-)

diffs (123 lines):

diff -r affb2684cb58 -r c35f60a8ad8d stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -46,8 +46,7 @@
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock_package', 'sequence_type_package')),
-],
-depends=['company'])
+])
 
 @classmethod
 def __register__(cls, module_name):
@@ -138,8 +137,7 @@
 domain=[('category', '=', Id('product', 'uom_cat_weight'))],
 states={
 'required': Bool(Eval('packaging_weight')),
-},
-depends=['packaging_weight'])
+})
 
 @fields.depends(
 'packaging_volume', 'packaging_volume_uom',
@@ -189,8 +187,7 @@
 'stock.package.type', "Type", required=True,
 states={
 'readonly': Eval('state') == 'closed',
-},
-depends=['state'])
+})
 shipment = fields.Reference(
 "Shipment", selection='get_shipment', select=True,
 states={
@@ -203,8 +200,7 @@
 'stock.shipment.in.return': [
 ('company', '=', Eval('company', -1)),
 ],
-},
-depends=['state', 'company'])
+})
 moves = fields.One2Many('stock.move', 'package', 'Moves',
 domain=[
 ('company', '=', Eval('company', -1)),
@@ -220,8 +216,7 @@
 ],
 states={
 'readonly': Eval('state') == 'closed',
-},
-depends=['company', 'shipment', 'state'])
+})
 parent = fields.Many2One(
 'stock.package', "Parent", select=True, ondelete='CASCADE',
 domain=[
@@ -230,8 +225,7 @@
 ],
 states={
 'readonly': Eval('state') == 'closed',
-},
-depends=['company', 'shipment', 'state'])
+})
 children = fields.One2Many(
 'stock.package', 'parent', 'Children',
 domain=[
@@ -240,8 +234,7 @@
 ],
 states={
 'readonly': Eval('state') == 'closed',
-},
-depends=['company', 'shipment', 'state'])
+})
 state = fields.Function(fields.Selection([
 ('open', "Open"),
 ('closed', "Closed"),
@@ -374,8 +367,7 @@
 ],
 states={
 'readonly': Eval('state') == 'cancelled',
-},
-depends=['company', 'state'])
+})
 
 @property
 def package_path(self):
@@ -409,15 +401,13 @@
 packages = fields.One2Many('stock.package', 'shipment', 'Packages',
 domain=[
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
 root_packages = fields.Function(fields.One2Many('stock.package',
 'shipment', 'Packages',
 domain=[
 ('company', '=', Eval('company', -1)),
 ('parent', '=', None),
-],
-depends=['company']),
+]),
 'get_root_packages', setter='set_root_packages')
 
 def get_root_packages(self, name):
@@ -457,10 +447,8 @@
 Eval('warehouse_storage') == Eval('warehouse_output'),
 Eval('state') != 'waiting',
 Eval('state') != 'picked')
-packages_depends = ['warehouse_storage', 'warehouse_output', 'state']
 for field in [cls.packages, cls.root_packages]:
 field.states['readonly'] = packages_readonly
-field.depends.extend(packages_depends)
 
 @classmethod
 @ModelView.button
@@ -513,10 +501,8 @@
 def __setup__(cls):
 super().__setup__()
 packages_readonly = ~Eval('state').in_(['waiting', 'assigned'])
-packages_depends = ['state']
 for field in [cls.packages, cls.root_packages]:
 field.states['readonly'] = packages_readonly
-field.depends.extend(packages_depends)
 
 @classmethod
 @ModelView.button



[tryton-commits] changeset in modules/stock_lot_unit:default Send only the requir...

2022-04-08 Thread Nicolas Évrard
changeset 9cb63f87123c in modules/stock_lot_unit:default
details: 
https://hg.tryton.org/modules/stock_lot_unit?cmd=changeset=9cb63f87123c
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (30 lines):

diff -r 27aee08d2f4e -r 9cb63f87123c product.py
--- a/product.pyFri Apr 08 18:58:33 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -16,7 +16,6 @@
 states={
 'invisible': Eval('type') == 'service',
 },
-depends=['type', 'default_uom_category'],
 help="The default unit for lot.")
 
 
diff -r 27aee08d2f4e -r 9cb63f87123c stock.py
--- a/stock.py  Fri Apr 08 18:58:33 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -17,7 +17,6 @@
 domain=[
 ('category', '=', Eval('product_default_uom_category', -1)),
 ],
-depends=['product_default_uom_category'],
 help="The biggest unit for the lot.")
 unit_quantity = fields.Float(
 "Unit Quantity", digits='unit',
@@ -25,7 +24,6 @@
 'required': Bool(Eval('unit')),
 'invisible': ~Eval('unit'),
 },
-depends=['unit'],
 help="The maximal quantity for the lot.")
 
 product_default_uom_category = fields.Function(



[tryton-commits] changeset in modules/stock_lot_sled:default Send only the requir...

2022-04-08 Thread Nicolas Évrard
changeset 18f14b9083f0 in modules/stock_lot_sled:default
details: 
https://hg.tryton.org/modules/stock_lot_sled?cmd=changeset=18f14b9083f0
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (42 lines):

diff -r 01d066cbc049 -r 18f14b9083f0 product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -16,7 +16,6 @@
 states={
 'invisible': Eval('shelf_life_state', 'none') == 'none',
 },
-depends=['shelf_life_state'],
 help='In number of days.')
 expiration_state = fields.Selection(
 DATE_STATE, 'Expiration State', sort=False)
@@ -24,7 +23,6 @@
 states={
 'invisible': Eval('expiration_state', 'none') == 'none',
 },
-depends=['expiration_state'],
 help='In number of days.')
 
 @staticmethod
diff -r 01d066cbc049 -r 18f14b9083f0 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -52,8 +52,7 @@
 'required': (
 Eval('shelf_life_expiration_state', 'none') == 'required'),
 'invisible': Eval('shelf_life_expiration_state', 'none') == 'none',
-},
-depends=['shelf_life_expiration_state'])
+})
 shelf_life_expiration_state = fields.Function(
 fields.Selection(DATE_STATE, 'Shelf Life Expiration State'),
 'on_change_with_shelf_life_expiration_state')
@@ -61,8 +60,7 @@
 states={
 'required': Eval('expiration_state', 'none') == 'required',
 'invisible': Eval('expiration_state', 'none') == 'none',
-},
-depends=['expiration_state'])
+})
 expiration_state = fields.Function(
 fields.Selection(DATE_STATE, 'Expiration State'),
 'on_change_with_expiration_state')



[tryton-commits] changeset in modules/stock_lot:default Send only the required fi...

2022-04-08 Thread Nicolas Évrard
changeset 13cf1b0ce00c in modules/stock_lot:default
details: https://hg.tryton.org/modules/stock_lot?cmd=changeset=13cf1b0ce00c
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 product.py |   4 +---
 stock.py   |  19 ++-
 2 files changed, 7 insertions(+), 16 deletions(-)

diffs (87 lines):

diff -r 8f23ae5997bd -r 13cf1b0ce00c product.py
--- a/product.pyThu Apr 07 10:31:53 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -45,8 +45,7 @@
 help='The type of location for which lot is required.',
 states={
 'invisible': ~Eval('type').in_(['goods', 'assets']),
-},
-depends=['type'])
+})
 lot_sequence = fields.Many2One(
 'ir.sequence', "Lot Sequence",
 domain=[
@@ -55,7 +54,6 @@
 states={
 'invisible': ~Eval('type').in_(['goods', 'assets']),
 },
-depends=['type'],
 help="The sequence used to automatically number lots.")
 
 @classmethod
diff -r 8f23ae5997bd -r 13cf1b0ce00c stock.py
--- a/stock.py  Thu Apr 07 10:31:53 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -56,8 +56,7 @@
 "Number", required=True, select=True,
 states={
 'required': ~Eval('has_sequence') | (Eval('id', -1) >= 0),
-},
-depends=['has_sequence'])
+})
 product = fields.Many2One('product.product', 'Product', required=True)
 has_sequence = fields.Function(
 fields.Boolean("Has Sequence"), 'on_change_with_has_sequence')
@@ -289,13 +288,11 @@
 product = fields.Many2One('product.product', "Product")
 quantity = fields.Function(
 fields.Float(
-"Quantity", digits=(16, Eval('default_uom_digits', 2)),
-depends=['default_uom_digits']),
+"Quantity", digits=(16, Eval('default_uom_digits', 2))),
 'get_lot', searcher='search_lot')
 forecast_quantity = fields.Function(
 fields.Float(
-"Forecast Quantity", digits=(16, Eval('default_uom_digits', 2)),
-depends=['default_uom_digits']),
+"Forecast Quantity", digits=(16, Eval('default_uom_digits', 2))),
 'get_lot', searcher='search_lot')
 default_uom = fields.Function(
 fields.Many2One('product.uom', "Default UOM"),
@@ -398,8 +395,7 @@
 ],
 states={
 'readonly': Eval('state').in_(['cancelled', 'done']),
-},
-depends=['state', 'product'])
+})
 
 @classmethod
 def __setup__(cls):
@@ -526,15 +522,13 @@
 ],
 states={
 'readonly': ~Eval('quantity_remaining', 0),
-},
-depends=['product', 'quantity_remaining'])
+})
 
 duplicate_lot_number = fields.Integer(
 "Duplicate Lot Number",
 states={
 'invisible': Len(Eval('lots')) != 1,
 },
-depends=['lots'],
 help="The number of times the lot must be duplicated.")
 
 @classmethod
@@ -725,8 +719,7 @@
 ],
 states={
 'readonly': Eval('inventory_state') != 'draft',
-},
-depends=['product', 'inventory_state'])
+})
 
 @classmethod
 def __setup__(cls):



[tryton-commits] changeset in modules/stock_location_move:default Send only the r...

2022-04-08 Thread Nicolas Évrard
changeset 0ee17ffee5d1 in modules/stock_location_move:default
details: 
https://hg.tryton.org/modules/stock_location_move?cmd=changeset=0ee17ffee5d1
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (23 lines):

diff -r c3b387598941 -r 0ee17ffee5d1 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -17,8 +17,7 @@
 "Movable", select=True,
 states={
 'invisible': Eval('type') != 'storage',
-},
-depends=['type'])
+})
 assigned_by = fields.Reference(
 "Assigned by", 'get_assigned_by', readonly=True)
 
@@ -119,8 +118,7 @@
 states={
 'readonly': (~Eval('state').in_(['request', 'draft'])
 | ~Eval('from_location') | ~Eval('to_location')),
-},
-depends=['state', 'from_location', 'to_location'])
+})
 
 @classmethod
 @ModelView.button



[tryton-commits] changeset in modules/stock_forecast:default Send only the requir...

2022-04-08 Thread Nicolas Évrard
changeset a478a4910025 in modules/stock_forecast:default
details: 
https://hg.tryton.org/modules/stock_forecast?cmd=changeset=a478a4910025
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 forecast.py |  39 +++
 1 files changed, 15 insertions(+), 24 deletions(-)

diffs (123 lines):

diff -r 9ca1d87bf008 -r a478a4910025 forecast.py
--- a/forecast.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/forecast.py   Fri Apr 08 19:07:14 2022 +0200
@@ -28,36 +28,31 @@
 _states = {
 'readonly': Not(Equal(Eval('state'), 'draft')),
 }
-_depends = ['state']
 
 warehouse = fields.Many2One(
 'stock.location', 'Location', required=True,
 domain=[('type', '=', 'warehouse')], states={
 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
 Bool(Eval('lines', [0]))),
-},
-depends=['state'])
+})
 destination = fields.Many2One(
 'stock.location', 'Destination', required=True,
-domain=[('type', 'in', ['customer', 'production'])], states=_states,
-depends=_depends)
+domain=[('type', 'in', ['customer', 'production'])], states=_states)
 from_date = fields.Date(
 "From Date", required=True,
 domain=[('from_date', '<=', Eval('to_date'))],
-states=_states, depends=_depends + ['to_date'])
+states=_states)
 to_date = fields.Date(
 "To Date", required=True,
 domain=[('to_date', '>=', Eval('from_date'))],
-states=_states, depends=_depends + ['from_date'])
+states=_states)
 lines = fields.One2Many(
-'stock.forecast.line', 'forecast', 'Lines', states=_states,
-depends=_depends)
+'stock.forecast.line', 'forecast', 'Lines', states=_states)
 company = fields.Many2One(
 'company.company', 'Company', required=True, states={
 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
 Bool(Eval('lines', [0]))),
-},
-depends=['state'])
+})
 state = fields.Selection([
 ('draft', "Draft"),
 ('done', "Done"),
@@ -66,7 +61,7 @@
 active = fields.Function(fields.Boolean('Active'),
 'get_active', searcher='search_active')
 
-del _states, _depends
+del _states
 
 @classmethod
 def __setup__(cls):
@@ -259,14 +254,13 @@
 _states = {
 'readonly': Eval('forecast_state') != 'draft',
 }
-_depends = ['forecast_state']
 
 product = fields.Many2One('product.product', 'Product', required=True,
 domain=[
 ('type', '=', 'goods'),
 ('consumable', '=', False),
 ],
-states=_states, depends=_depends)
+states=_states)
 product_uom_category = fields.Function(
 fields.Many2One('product.uom.category', 'Product Uom Category'),
 'on_change_with_product_uom_category')
@@ -277,15 +271,15 @@
 ('category', '!=', -1)),
 ],
 states=_states,
-depends=['product', 'product_uom_category'] + _depends)
+depends={'product'})
 quantity = fields.Float(
 "Quantity", digits='uom', required=True,
 domain=[('quantity', '>=', 0)],
-states=_states, depends=_depends)
+states=_states)
 minimal_quantity = fields.Float(
 "Minimal Qty", digits='uom', required=True,
 domain=[('minimal_quantity', '<=', Eval('quantity'))],
-states=_states, depends=['quantity'] + _depends)
+states=_states)
 moves = fields.Many2Many('stock.forecast.line-stock.move',
 'line', 'move', 'Moves', readonly=True)
 forecast = fields.Many2One(
@@ -293,15 +287,14 @@
 states={
 'readonly': ((Eval('forecast_state') != 'draft')
 & Bool(Eval('forecast'))),
-},
-depends=['forecast_state'])
+})
 forecast_state = fields.Function(
 fields.Selection('get_forecast_states', 'Forecast State'),
 'on_change_with_forecast_state')
 quantity_executed = fields.Function(fields.Float(
 "Quantity Executed", digits='uom'), 'get_quantity_executed')
 
-del _states, _depends
+del _states
 
 @classmethod
 def __setup__(cls):
@@ -509,12 +502,10 @@
 __name__ = 'stock.forecast.complete.ask'
 from_date = fields.Date(
 "From Date", required=True,
-domain=[('from_date', '<', Eval('to_date'))],
-depends=['to_date'])
+domain=[('from_date', '<', Eval('to_date'))])
 to_date = fields.Date(
 "To Date", required=True,
-domain=[('to_date', '>', Eval('from_date'))],
-depends=['from_date'])
+domain=[('to_date', '>', Eval('from_date'))])
 
 
 class ForecastCompleteChoose(ModelView):



[tryton-commits] changeset in modules/stock_consignment:default Send only the req...

2022-04-08 Thread Nicolas Évrard
changeset ab0666f8e5ce in modules/stock_consignment:default
details: 
https://hg.tryton.org/modules/stock_consignment?cmd=changeset=ab0666f8e5ce
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (11 lines):

diff -r 562f2e9956f9 -r ab0666f8e5ce stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -17,7 +17,6 @@
 states={
 'invisible': ~Eval('type').in_(['supplier', 'storage']),
 },
-depends=['type'],
 help="The party invoiced when consignment stock is used.")
 
 @classmethod



[tryton-commits] changeset in modules/stock_assign_manual:default Send only the r...

2022-04-08 Thread Nicolas Évrard
changeset 0eb578a763c1 in modules/stock_assign_manual:default
details: 
https://hg.tryton.org/modules/stock_assign_manual?cmd=changeset=0eb578a763c1
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (35 lines):

diff -r b21ee7b8b1f9 -r 0eb578a763c1 stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -180,7 +180,6 @@
 ('quantity', '<=', Eval('move_quantity', 0)),
 ],
 ],
-depends=['move_quantity'],
 help="The maximum quantity to assign from the place.\n"
 "Leave empty for the full quantity of the move.")
 unit = fields.Many2One('product.uom', "Unit", readonly=True)
@@ -369,7 +368,6 @@
 ('unassigned_quantity', '<=', Eval('move_quantity', 0)),
 ],
 ],
-depends=['move_quantity'],
 help="The quantity to unassign")
 assigned_quantity = fields.Float(
 "Assigned Quantity", digits='unit',
@@ -380,7 +378,6 @@
 ('assigned_quantity', '<=', Eval('move_quantity', 0)),
 ],
 ],
-depends=['move_quantity'],
 help="The quantity left assigned")
 unit = fields.Function(
 fields.Many2One('product.uom', "Unit"), 'on_change_with_unit')
@@ -427,7 +424,6 @@
 moves = fields.One2Many(
 'stock.shipment.assigned.move', None, "Moves",
 domain=[('move.id', 'in', Eval('assigned_moves'))],
-depends=['assigned_moves'],
 help="The moves to unassign.")
 assigned_moves = fields.Many2Many(
 'stock.move', None, None, "Assigned Moves")



[tryton-commits] changeset in modules/stock:default Send only the required fields...

2022-04-08 Thread Nicolas Évrard
changeset b483de7e3ad8 in modules/stock:default
details: https://hg.tryton.org/modules/stock?cmd=changeset=b483de7e3ad8
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 configuration.py  |  18 +++--
 inventory.py  |  19 +++---
 location.py   |  20 +-
 move.py   |  28 ---
 period.py |   2 +-
 product.py|   6 +--
 shipment.py   |  83 +++---
 stock_reporting_margin.py |   8 +--
 8 files changed, 49 insertions(+), 135 deletions(-)

diffs (859 lines):

diff -r ffb276238a51 -r b483de7e3ad8 configuration.py
--- a/configuration.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/configuration.py  Fri Apr 08 19:07:14 2022 +0200
@@ -137,48 +137,42 @@
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock', 'sequence_type_shipment_in')),
-],
-depends=['company'])
+])
 shipment_in_return_sequence = fields.Many2One(
 'ir.sequence', "Supplier Return Shipment Sequence", required=True,
 domain=[
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock', 'sequence_type_shipment_in_return')),
-],
-depends=['company'])
+])
 shipment_out_sequence = fields.Many2One(
 'ir.sequence', "Customer Shipment Sequence", required=True,
 domain=[
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock', 'sequence_type_shipment_out')),
-],
-depends=['company'])
+])
 shipment_out_return_sequence = fields.Many2One(
 'ir.sequence', "Customer Return Shipment Sequence", required=True,
 domain=[
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock', 'sequence_type_shipment_out_return')),
-],
-depends=['company'])
+])
 shipment_internal_sequence = fields.Many2One(
 'ir.sequence', "Internal Shipment Sequence", required=True,
 domain=[
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock', 'sequence_type_shipment_internal')),
-],
-depends=['company'])
+])
 inventory_sequence = fields.Many2One(
 'ir.sequence', "Inventory Sequence", required=True,
 domain=[
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('stock', 'sequence_type_inventory')),
-],
-depends=['company'])
+])
 
 @classmethod
 def __register__(cls, module_name):
diff -r ffb276238a51 -r b483de7e3ad8 inventory.py
--- a/inventory.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/inventory.py  Fri Apr 08 19:07:14 2022 +0200
@@ -25,7 +25,6 @@
 _states = {
 'readonly': Eval('state') != 'draft',
 }
-_depends = ['state']
 
 number = fields.Char('Number', readonly=True,
 help="The main identifier for the inventory.")
@@ -34,31 +33,27 @@
 domain=[('type', '=', 'storage')], states={
 'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
 },
-depends=['state'],
 help="The location inventoried.")
 date = fields.Date('Date', required=True, states={
 'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
 },
-depends=['state'],
 help="The date of the stock count.")
 lines = fields.One2Many(
 'stock.inventory.line', 'inventory', 'Lines',
 states={
 'readonly': (_states['readonly'] | ~Eval('location')
 | ~Eval('date')),
-},
-depends=['location', 'date'] + _depends)
+})
 empty_quantity = fields.Selection([
 (None, ""),
 ('keep', "Keep"),
 ('empty', "Empty"),
-], "Empty Quantity", states=_states, depends=_depends,
+], "Empty Quantity", states=_states,
 help="How lines without a quantity are handled.")
 company = fields.Many2One('company.company', 'Company', required=True,
 states={
 'readonly': (Eval('state') != 'draft') | Eval('lines', [0]),
 },
-depends=['state'],
 help="The company the inventory is associated with.")
 state = fields.Selection([
 ('draft', "Draft"),
@@ -67,7 +62,7 @@
 ], "State", readonly=True, select=True, sort=False,
 help="The current state of the inventory.")
 
-del _states, _depends
+del _states
 
 @classmethod
 def __setup__(cls):
@@ -326,12 +321,11 

[tryton-commits] changeset in modules/sale_supply_production:default Send only th...

2022-04-08 Thread Nicolas Évrard
changeset dd09caf380ee in modules/sale_supply_production:default
details: 
https://hg.tryton.org/modules/sale_supply_production?cmd=changeset=dd09caf380ee
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (11 lines):

diff -r 53b4790d0133 -r dd09caf380ee product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -12,7 +12,6 @@
 super().__setup__()
 cls.supply_on_sale.states['invisible'] &= (
 ~Eval('producible') | ~Eval('salable'))
-cls.supply_on_sale.depends.extend(['producible', 'salable'])
 
 
 class Product(metaclass=PoolMeta):



[tryton-commits] changeset in modules/sale_supply_drop_shipment:default Send only...

2022-04-08 Thread Nicolas Évrard
changeset ad9c5a72f13f in modules/sale_supply_drop_shipment:default
details: 
https://hg.tryton.org/modules/sale_supply_drop_shipment?cmd=changeset=ad9c5a72f13f
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 purchase.py |  19 +++
 stock.py|  29 -
 2 files changed, 19 insertions(+), 29 deletions(-)

diffs (167 lines):

diff -r b10e54408017 -r ad9c5a72f13f purchase.py
--- a/purchase.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/purchase.py   Fri Apr 08 19:07:14 2022 +0200
@@ -26,14 +26,13 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['company'])
+depends={'company'})
 delivery_address = fields.Many2One('party.address', 'Delivery Address',
 domain=[('party', '=', Eval('customer'))],
 states={
 'invisible': ~Eval('customer'),
 'readonly': Eval('state') != 'draft',
-},
-depends=['customer', 'state'])
+})
 
 
 class Configuration(metaclass=PoolMeta):
@@ -90,28 +89,25 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['company'])
+depends={'company'})
 delivery_address = fields.Many2One('party.address', 'Delivery Address',
 domain=[('party', '=', Eval('customer'))],
 states={
 'readonly': Eval('state') != 'draft',
 'invisible': ~Eval('customer'),
-},
-depends=['state', 'customer'])
+})
 drop_shipments = fields.Function(fields.Many2Many('stock.shipment.drop',
 None, None, "Drop Shipments",
 states={
 'invisible': ~Eval('customer'),
-},
-depends=['customer']),
+}),
 'get_drop_shipments', searcher='search_drop_shipments')
 drop_location = fields.Many2One('stock.location', 'Drop Location',
 domain=[('type', '=', 'drop')],
 states={
 'invisible': ~Eval('customer', False),
 'required': Eval('customer', False),
-},
-depends=['customer'])
+})
 
 @staticmethod
 def default_drop_location():
@@ -203,8 +199,7 @@
 drop_shipment = fields.Boolean('Drop Shipment',
 states={
 'invisible': ~Eval('drop_shipment_available', False),
-},
-depends=['drop_shipment_available'])
+})
 drop_shipment_available = fields.Function(
 fields.Boolean("Drop Shipment Available"),
 'on_change_with_drop_shipment_available')
diff -r b10e54408017 -r ad9c5a72f13f stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -57,8 +57,7 @@
 ('sequence_type', '=',
 Id('sale_supply_drop_shipment',
 'sequence_type_shipment_drop')),
-],
-depends=['company'])
+])
 
 @classmethod
 def __register__(cls, module_name):
@@ -99,20 +98,18 @@
 states={
 'readonly': Eval('state').in_(['cancelled', 'done']),
 },
-depends=['state'],
 help="When the stock was actually sent.")
 planned_date = fields.Date('Planned Date', states={
 'readonly': Eval('state') != 'draft',
-}, depends=['state'])
+})
 company = fields.Many2One('company.company', 'Company', required=True,
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['state'])
+})
 reference = fields.Char('Reference', select=1,
 states={
 'readonly': Eval('state') != 'draft',
-}, depends=['state'])
+})
 supplier = fields.Many2One('party.party', 'Supplier', required=True,
 states={
 'readonly': (((Eval('state') != 'draft')
@@ -122,13 +119,12 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['state', 'supplier', 'company'])
+depends={'company'})
 contact_address = fields.Many2One('party.address', 'Contact Address',
 states={
 'readonly': Eval('state') != 'draft',
 },
-domain=[('party', '=', Eval('supplier'))],
-depends=['state', 'supplier'])
+domain=[('party', '=', Eval('supplier'))])
 customer = fields.Many2One('party.party', 'Customer', required=True,
 states={
 'readonly': (((Eval('state') != 'draft')
@@ -138,14 +134,13 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['state', 'company'])
+depends={'company'})
 delivery_address = fields.Many2One('party.address', 'Delivery Address',
 required=True,
 states={
 'readonly': Eval('state') != 'draft',
 },
-

[tryton-commits] changeset in modules/sale_supply:default Send only the required ...

2022-04-08 Thread Nicolas Évrard
changeset 6daa8f899aa9 in modules/sale_supply:default
details: 
https://hg.tryton.org/modules/sale_supply?cmd=changeset=6daa8f899aa9
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (13 lines):

diff -r 7a3df504bcb6 -r 6daa8f899aa9 product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -11,8 +11,7 @@
 supply_on_sale = fields.Boolean('Supply On Sale',
 states={
 'invisible': ~Eval('purchasable') | ~Eval('salable'),
-},
-depends=['purchasable', 'salable'])
+})
 
 
 class Product(metaclass=PoolMeta):



[tryton-commits] changeset in modules/sale_subscription_asset:default Send only t...

2022-04-08 Thread Nicolas Évrard
changeset 17c1c977296c in modules/sale_subscription_asset:default
details: 
https://hg.tryton.org/modules/sale_subscription_asset?cmd=changeset=17c1c977296c
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (21 lines):

diff -r 4f450a507131 -r 17c1c977296c sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -83,8 +83,7 @@
 & Eval('asset_lot_required')),
 'invisible': ~Eval('asset_lot_required'),
 'readonly': Eval('subscription_state') != 'draft',
-},
-depends=['service', 'subscription_state', 'asset_lot_required'])
+})
 asset_lot_required = fields.Function(
 fields.Boolean("Asset Lot Required"),
 'on_change_with_asset_lot_required')
@@ -99,7 +98,6 @@
 ('quantity', '=', 1),
 ()),
 ]
-cls.quantity.depends.append('asset_lot')
 
 @fields.depends('service')
 def on_change_with_asset_lot_required(self, name=None):



[tryton-commits] changeset in modules/sale_subscription:default Send only the req...

2022-04-08 Thread Nicolas Évrard
changeset e94325afd7fb in modules/sale_subscription:default
details: 
https://hg.tryton.org/modules/sale_subscription?cmd=changeset=e94325afd7fb
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 configuration.py |   3 +-
 service.py   |   3 +-
 subscription.py  |  65 ++-
 3 files changed, 23 insertions(+), 48 deletions(-)

diffs (241 lines):

diff -r c9aaea87b083 -r e94325afd7fb configuration.py
--- a/configuration.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/configuration.py  Fri Apr 08 19:07:14 2022 +0200
@@ -38,8 +38,7 @@
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('sale_subscription', 'sequence_type_subscription')),
-],
-depends=['company'])
+])
 
 @classmethod
 def default_subscription_sequence(cls):
diff -r c9aaea87b083 -r e94325afd7fb service.py
--- a/service.pyWed Apr 06 23:37:44 2022 +0200
+++ b/service.pyFri Apr 08 19:07:14 2022 +0200
@@ -18,8 +18,7 @@
 consumption_delay = fields.TimeDelta("Consumption Delay",
 states={
 'invisible': ~Eval('consumption_recurrence'),
-},
-depends=['consumption_recurrence'])
+})
 
 def get_rec_name(self, name):
 return self.product.rec_name
diff -r c9aaea87b083 -r e94325afd7fb subscription.py
--- a/subscription.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/subscription.py   Fri Apr 08 19:07:14 2022 +0200
@@ -35,7 +35,6 @@
 states={
 'readonly': (Eval('state') != 'draft') | Eval('party', True),
 },
-depends=['state', 'party'],
 help="Make the subscription belong to the company.")
 
 number = fields.Char(
@@ -48,8 +47,7 @@
 description = fields.Char("Description",
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['state'])
+})
 
 party = fields.Many2One(
 'party.party', "Party", required=True,
@@ -60,7 +58,6 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['state', 'company'],
 help="The party who subscribes.")
 contact = fields.Many2One(
 'party.contact_mechanism', "Contact",
@@ -70,7 +67,7 @@
 search_context={
 'related_party': Eval('party'),
 },
-depends=['company', 'party'])
+depends={'company', 'party'})
 invoice_party = fields.Many2One('party.party', "Invoice Party",
 states={
 'readonly': ((Eval('state') != 'draft')
@@ -82,7 +79,7 @@
 search_context={
 'related_party': Eval('party'),
 },
-depends=['state', 'company', 'party'])
+depends={'company', 'party'})
 invoice_address = fields.Many2One(
 'party.address', "Invoice Address",
 domain=[
@@ -92,30 +89,26 @@
 states={
 'readonly': Eval('state') != 'draft',
 'required': ~Eval('state').in_(['draft']),
-},
-depends=['party', 'invoice_party', 'state'])
+})
 payment_term = fields.Many2One(
 'account.invoice.payment_term', "Payment Term",
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['state'])
+})
 
 currency = fields.Many2One(
 'currency.currency', "Currency", required=True,
 states={
 'readonly': ((Eval('state') != 'draft')
 | (Eval('lines', [0]) & Eval('currency', 0))),
-},
-depends=['state'])
+})
 
 start_date = fields.Date(
 "Start Date", required=True,
 states={
 'readonly': ((Eval('state') != 'draft')
 | Eval('next_invoice_date')),
-},
-depends=['state', 'next_invoice_date'])
+})
 end_date = fields.Date(
 "End Date",
 domain=['OR',
@@ -127,36 +120,31 @@
 ],
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['start_date', 'state'])
+})
 
 invoice_recurrence = fields.Many2One(
 'sale.subscription.recurrence.rule.set', "Invoice Recurrence",
 required=True,
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['state'])
+})
 invoice_start_date = fields.Date("Invoice Start Date",
 states={
 'readonly': ((Eval('state') != 'draft')
 | Eval('next_invoice_date')),
-},
-depends=['state', 'next_invoice_date'])
+})
 next_invoice_date = fields.Date(
 "Next Invoice Date", readonly=True,
 states={
 'invisible': Eval('state') != 'running',
-},
-

[tryton-commits] changeset in modules/sale_shipment_cost:default Send only the re...

2022-04-08 Thread Nicolas Évrard
changeset aac31f00ca6e in modules/sale_shipment_cost:default
details: 
https://hg.tryton.org/modules/sale_shipment_cost?cmd=changeset=aac31f00ca6e
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 sale.py  |   9 -
 stock.py |  12 
 2 files changed, 8 insertions(+), 13 deletions(-)

diffs (82 lines):

diff -r 297e68b5e987 -r aac31f00ca6e sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -87,7 +87,7 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['state', 'available_carriers', 'company'])
+depends={'company'})
 available_carriers = fields.Function(
 fields.Many2Many('carrier', None, None, 'Available Carriers'),
 'on_change_with_available_carriers')
@@ -97,7 +97,7 @@
 ('shipment', 'On Shipment'),
 ], 'Shipment Cost Method', states={
 'readonly': Eval('state') != 'draft',
-}, depends=['state'])
+})
 
 @classmethod
 def __register__(cls, module):
@@ -326,7 +326,7 @@
 'sale_shipment_cost.msg_sale_shipment_cost_unique'),
 ]
 # shipment_cost is needed to compute the unit_price
-cls.unit_price.depends.append('shipment_cost')
+cls.unit_price.depends.add('shipment_cost')
 
 @fields.depends('shipment_cost', 'unit_price')
 def compute_unit_price(self):
@@ -404,8 +404,7 @@
 "Amount with Shipment Cost Included",
 states={
 'invisible': ~Eval('amount'),
-},
-depends=['amount'])
+})
 
 @classmethod
 def default_amount_shipment_cost_included(cls):
diff -r 297e68b5e987 -r aac31f00ca6e stock.py
--- a/stock.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -19,8 +19,7 @@
 'invisible': (
 Eval('cost_edit', False)
 | (Eval('cost_method') != 'shipment')),
-},
-depends=['cost_edit', 'cost_method']),
+}),
 'on_change_with_cost_sale_currency_used')
 cost_sale_currency = fields.Many2One(
 'currency.currency', "Cost Sale Currency",
@@ -30,16 +29,14 @@
 | (Eval('cost_method') != 'shipment')),
 'required': Bool(Eval('cost_sale')),
 'readonly': Eval('state').in_(['done', 'cancelled']),
-},
-depends=['cost_method', 'cost_sale', 'state'])
+})
 cost_sale_used = fields.Function(fields.Numeric(
 "Cost Sale", digits=price_digits,
 states={
 'invisible': (
 Eval('cost_edit', False)
 | (Eval('cost_method') != 'shipment')),
-},
-depends=['cost_edit', 'cost_method']),
+}),
 'on_change_with_cost_sale_used')
 cost_sale = fields.Numeric(
 "Cost Sale", digits=price_digits,
@@ -48,8 +45,7 @@
 ~Eval('cost_edit', False)
 | (Eval('cost_method') != 'shipment')),
 'readonly': Eval('state').in_(['done', 'cancelled']),
-},
-depends=['cost_method', 'state'])
+})
 
 cost_invoice_line = fields.Many2One('account.invoice.line',
 'Cost Invoice Line', readonly=True)



[tryton-commits] changeset in modules/sale_secondary_unit:default Send only the r...

2022-04-08 Thread Nicolas Évrard
changeset 6a010315ca4c in modules/sale_secondary_unit:default
details: 
https://hg.tryton.org/modules/sale_secondary_unit?cmd=changeset=6a010315ca4c
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 product.py |   6 +-
 sale.py|  10 +++---
 2 files changed, 4 insertions(+), 12 deletions(-)

diffs (69 lines):

diff -r eb99542841ea -r 6a010315ca4c product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -15,15 +15,13 @@
 'product.uom', "Sale Secondary UOM",
 domain=[
 ('category', '!=', Eval('default_uom_category')),
-],
-depends=['default_uom_category'])
+])
 sale_secondary_uom_factor = fields.Float(
 "Sale Secondary UOM Factor", digits=uom_conversion_digits,
 states={
 'required': Bool(Eval('sale_secondary_uom')),
 'invisible': ~Eval('sale_secondary_uom'),
 },
-depends=['sale_secondary_uom'],
 help="The coefficient for the formula:\n"
 "1 (sale unit) = coefficient (secondary unit)")
 sale_secondary_uom_rate = fields.Float(
@@ -32,7 +30,6 @@
 'required': Bool(Eval('sale_secondary_uom')),
 'invisible': ~Eval('sale_secondary_uom'),
 },
-depends=['sale_secondary_uom'],
 help="The coefficient for the formula:\n"
 "coefficient (sale unit) = 1 (secondary unit)")
 sale_secondary_uom_category = fields.Function(
@@ -123,7 +120,6 @@
 cls.sale_secondary_uom.states = {
 'invisible': ~Eval('salable', False),
 }
-cls.sale_secondary_uom.depends.append('salable')
 
 
 class Product(metaclass=PoolMeta):
diff -r eb99542841ea -r 6a010315ca4c sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -16,8 +16,7 @@
 'invisible': ((Eval('type') != 'line')
 | ~Eval('secondary_unit')),
 'readonly': Eval('sale_state') != 'draft',
-},
-depends=['type', 'secondary_unit', 'sale_state']),
+}),
 'on_change_with_secondary_quantity', setter='set_secondary')
 secondary_unit = fields.Many2One(
 'product.uom', "Secondary Unit", ondelete='RESTRICT',
@@ -31,17 +30,14 @@
 | (~Eval('secondary_uom_factor')
 & ~Eval('secondary_uom_rate'))),
 'readonly': Eval('sale_state') != 'draft',
-},
-depends=['product_secondary_uom_category', 'type',
-'secondary_uom_factor', 'secondary_uom_rate', 'sale_state'])
+})
 secondary_unit_price = fields.Function(Monetary(
 "Secondary Unit Price", currency='currency', digits=price_digits,
 states={
 'invisible': ((Eval('type') != 'line')
 | ~Eval('secondary_unit')),
 'readonly': Eval('sale_state') != 'draft',
-},
-depends=['type', 'secondary_unit', 'sale_state']),
+}),
 'on_change_with_secondary_unit_price', setter='set_secondary')
 
 secondary_uom_factor = fields.Float("Secondary UOM Factor")



[tryton-commits] changeset in modules/sale_promotion_coupon:default Send only the...

2022-04-08 Thread Nicolas Évrard
changeset 9642cc97ece8 in modules/sale_promotion_coupon:default
details: 
https://hg.tryton.org/modules/sale_promotion_coupon?cmd=changeset=9642cc97ece8
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (12 lines):

diff -r c19ca45b0529 -r 9642cc97ece8 sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -185,7 +185,7 @@
 states={
 'readonly': Eval('state') != 'draft',
 },
-depends=['state', 'company', 'party'])
+depends={'party'})
 
 @classmethod
 @ModelView.button



[tryton-commits] changeset in modules/sale_promotion:default Send only the requir...

2022-04-08 Thread Nicolas Évrard
changeset cdc61cf9044e in modules/sale_promotion:default
details: 
https://hg.tryton.org/modules/sale_promotion?cmd=changeset=cdc61cf9044e
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 sale.py |  24 +---
 1 files changed, 9 insertions(+), 15 deletions(-)

diffs (77 lines):

diff -r c51f1e13ee9f -r cdc61cf9044e sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -79,7 +79,7 @@
 domain=[
 ('company', '=', Eval('_parent_sale', {}).get('company', -1)),
 ],
-depends=['sale'])
+depends={'sale'})
 
 
 class Promotion(
@@ -99,56 +99,50 @@
 datetime.date.max,
 Eval('end_date', datetime.date.max))),
 ('start_date', '=', None),
-],
-depends=['end_date'])
+])
 end_date = fields.Date('End Date',
 domain=['OR',
 ('end_date', '>=', If(~Eval('start_date', None),
 datetime.date.min,
 Eval('start_date', datetime.date.min))),
 ('end_date', '=', None),
-],
-depends=['start_date'])
+])
 price_list = fields.Many2One('product.price_list', 'Price List',
 ondelete='CASCADE',
 domain=[
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
 
 amount = Monetary("Amount", currency='currency', digits='currency')
 currency = fields.Many2One(
 'currency.currency', "Currency",
 states={
 'required': Bool(Eval('amount', 0)),
-},
-depends=['amount'])
+})
 untaxed_amount = fields.Boolean(
 "Untaxed Amount",
 states={
 'invisible': ~Eval('amount'),
-},
-depends=['amount'])
+})
 
 quantity = fields.Float('Quantity', digits='unit')
 unit = fields.Many2One('product.uom', 'Unit',
 states={
 'required': Bool(Eval('quantity', 0)),
-},
-depends=['quantity'])
+})
 products = fields.Many2Many(
 'sale.promotion-product.product', 'promotion', 'product', "Products",
 context={
 'company': Eval('company', -1),
 },
-depends=['company'])
+depends={'company'})
 categories = fields.Many2Many(
 'sale.promotion-product.category', 'promotion', 'category',
 "Categories",
 context={
 'company': Eval('company', -1),
 },
-depends=['company'])
+depends={'company'})
 formula = fields.Char('Formula', required=True,
 help=('Python expression that will be evaluated with:\n'
 '- unit_price: the original unit_price'))



[tryton-commits] changeset in modules/sale_product_customer:default Send only the...

2022-04-08 Thread Nicolas Évrard
changeset f484c5c4c023 in modules/sale_product_customer:default
details: 
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset=f484c5c4c023
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 product.py |  12 
 sale.py|   5 ++---
 2 files changed, 6 insertions(+), 11 deletions(-)

diffs (65 lines):

diff -r afd4ca1bdf1e -r f484c5c4c023 product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -22,8 +22,7 @@
 ('products', '=', Eval('product')),
 ()),
 If(Eval('active'), ('active', '=', True), ()),
-],
-depends=['product', 'active'])
+])
 product = fields.Many2One(
 'product.product', "Variant", select=True,
 domain=[
@@ -31,8 +30,7 @@
 ('template', '=', Eval('template')),
 ()),
 If(Eval('active'), ('active', '=', True), ()),
-],
-depends=['template', 'active'])
+])
 party = fields.Many2One('party.party', "Customer", required=True,
 ondelete='CASCADE')
 name = fields.Char("Name", translate=True)
@@ -88,8 +86,7 @@
 },
 domain=[
 If(~Eval('active'), ('active', '=', False), ()),
-],
-depends=['salable', 'active'])
+])
 
 def product_customer_used(self, **pattern):
 for product_customer in self.product_customers:
@@ -132,8 +129,7 @@
 ],
 states={
 'invisible': ~Eval('salable', False),
-},
-depends=['template', 'salable', 'active'])
+})
 
 def product_customer_used(self, **pattern):
 for product_customer in self.product_customers:
diff -r afd4ca1bdf1e -r f484c5c4c023 sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -28,7 +28,7 @@
 'invisible': Eval('type') != 'line',
 'readonly': Eval('sale_state') != 'draft',
 },
-depends=['product', 'type', 'sale_state', 'sale'])
+depends={'sale'})
 
 @fields.depends('sale', '_parent_sale.party')
 def _get_product_customer_pattern(self):
@@ -80,8 +80,7 @@
 ],
 states={
 'invisible': Eval('action') != 'product',
-},
-depends=['action', 'product', 'party'])
+})
 
 @fields.depends('line')
 def on_change_line(self):



[tryton-commits] changeset in modules/sale_price_list:default Send only the requi...

2022-04-08 Thread Nicolas Évrard
changeset bbc9ce71fbb7 in modules/sale_price_list:default
details: 
https://hg.tryton.org/modules/sale_price_list?cmd=changeset=bbc9ce71fbb7
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 configuration.py |  3 +--
 party.py |  5 ++---
 sale.py  |  7 +--
 3 files changed, 4 insertions(+), 11 deletions(-)

diffs (53 lines):

diff -r 91f39dd75ca9 -r bbc9ce71fbb7 configuration.py
--- a/configuration.py  Fri Apr 08 12:31:56 2022 +0200
+++ b/configuration.py  Fri Apr 08 19:07:14 2022 +0200
@@ -27,5 +27,4 @@
 'product.price_list', "Sale Price List",
 domain=[
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
diff -r 91f39dd75ca9 -r bbc9ce71fbb7 party.py
--- a/party.py  Fri Apr 08 12:31:56 2022 +0200
+++ b/party.py  Fri Apr 08 19:07:14 2022 +0200
@@ -52,13 +52,12 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['company'])
+depends={'company'})
 sale_price_list = fields.Many2One(
 'product.price_list', "Sale Price List",
 domain=[
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
 
 @classmethod
 def __register__(cls, module_name):
diff -r 91f39dd75ca9 -r bbc9ce71fbb7 sale.py
--- a/sale.py   Fri Apr 08 12:31:56 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -13,8 +13,7 @@
 states={
 'readonly': Or(Not(Equal(Eval('state'), 'draft')),
 Bool(Eval('lines', [0]))),
-},
-depends=['state', 'company'])
+})
 
 @classmethod
 def __setup__(cls):
@@ -23,10 +22,6 @@
 | Eval('lines', [0]))
 cls.lines.states['readonly'] = (cls.lines.states['readonly']
 | ~Eval('party') | ~Eval('company'))
-if 'party' not in cls.lines.depends:
-cls.lines.depends.append('party')
-if 'company' not in cls.lines.depends:
-cls.lines.depends.append('company')
 
 @fields.depends('company')
 def on_change_party(self):



[tryton-commits] changeset in modules/sale_point:default Send only the required f...

2022-04-08 Thread Nicolas Évrard
changeset 8253741149c8 in modules/sale_point:default
details: 
https://hg.tryton.org/modules/sale_point?cmd=changeset=8253741149c8
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 product.py |   1 -
 sale.py|  89 ++---
 2 files changed, 32 insertions(+), 58 deletions(-)

diffs (290 lines):

diff -r 362117053013 -r 8253741149c8 product.py
--- a/product.pyWed Apr 06 23:37:44 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -15,7 +15,6 @@
 states={
 'invisible': ~Eval('salable', False),
 },
-depends=['salable'],
 help="The price with default tax included."))
 gross_prices = fields.One2Many(
 'product.gross_price', 'template', "Gross Prices")
diff -r 362117053013 -r 8253741149c8 sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -37,8 +37,7 @@
 domain=[
 ('company', '=', Eval('company', -1)),
 ('sequence_type', '=', Id('sale_point', 'sequence_type_sale')),
-],
-depends=['company'])
+])
 
 address = fields.Many2One('party.address', "Address")
 
@@ -100,18 +99,15 @@
 _states = {
 'readonly': Eval('state') != 'open',
 }
-_depends = ['state']
 
 company = fields.Many2One(
-'company.company', "Company", required=True,
-states=_states, depends=_depends)
+'company.company', "Company", required=True, states=_states)
 employee = fields.Many2One(
 'company.employee', "Employee",
 domain=[
 ('company', '=', Eval('company', -1)),
 ],
-states=_states,
-depends=['company'] + _depends)
+states=_states)
 point = fields.Many2One(
 'sale.point', "Point", required=True, ondelete='RESTRICT',
 states={
@@ -121,25 +117,21 @@
 },
 domain=[
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'] + _depends)
+])
 number = fields.Char(
 "Number", readonly=True, select=True,
 states={
 'required': Eval('state').in_(['done', 'posted']),
-},
-depends=['state'])
-date = fields.Date("Date", required=True, states=_states, depends=_depends)
+})
+date = fields.Date("Date", required=True, states=_states)
 lines = fields.One2Many(
 'sale.point.sale.line', 'sale', "Lines",
 states={
 'readonly': (~Eval('point')
 | _states['readonly']),
-},
-depends=['point'] + _depends)
+})
 payments = fields.One2Many(
-'sale.point.payment', 'sale', "Payments",
-states=_states, depends=_depends)
+'sale.point.payment', 'sale', "Payments", states=_states)
 total_tax = fields.Function(Monetary(
 "Total Tax", currency='currency', digits='currency'),
 'on_change_with_total_tax')
@@ -168,7 +160,7 @@
 currency = fields.Function(fields.Many2One(
 'currency.currency', "Currency"), 'on_change_with_currency')
 
-del _states, _depends
+del _states
 
 @classmethod
 def __setup__(cls):
@@ -446,11 +438,10 @@
 _states = {
 'readonly': Eval('sale_state') != 'open',
 }
-_depends = ['sale_state']
 
 sale = fields.Many2One(
 'sale.point.sale', "Sale", required=True, ondelete='CASCADE',
-states=_states, depends=_depends)
+states=_states)
 product = fields.Many2One(
 'product.product', "Product", required=True,
 domain=[
@@ -459,10 +450,9 @@
 context={
 'company': Eval('company'),
 },
-states=_states, depends=_depends + ['company'])
+states=_states, depends={'company'})
 quantity = fields.Float(
-"Quantity", digits='unit', required=True,
-states=_states, depends=_depends)
+"Quantity", digits='unit', required=True, states=_states)
 unit = fields.Function(
 fields.Many2One('product.uom', "Unit"), 'on_change_with_unit')
 unit_list_price = fields.Numeric(
@@ -477,7 +467,7 @@
 })
 unit_price = fields.Function(fields.Numeric(
 "Unit Price", digits=price_digits,
-depends=['unit_list_price', 'unit_gross_price']),
+depends={'unit_list_price', 'unit_gross_price'}),
 'on_change_with_unit_price')
 amount = fields.Function(Monetary(
 "Amount", currency='currency', digits='currency'),
@@ -498,7 +488,7 @@
 fields.Many2One('currency.currency', "Currency"),
 'on_change_with_currency')
 
-del _states, _depends
+del _states
 
 @classmethod
 def __setup__(cls):
@@ -721,21 +711,18 @@
 readonly=True, 

[tryton-commits] changeset in modules/sale_payment:default Send only the required...

2022-04-08 Thread Nicolas Évrard
changeset a7365169d053 in modules/sale_payment:default
details: 
https://hg.tryton.org/modules/sale_payment?cmd=changeset=a7365169d053
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

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

diffs (14 lines):

diff -r 7a9444b66a34 -r a7365169d053 sale.py
--- a/sale.py   Wed Apr 06 23:37:44 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -37,9 +37,7 @@
 ],
 states={
 'readonly': Eval('state') != 'quotation',
-},
-depends=['company', 'total_amount', 'party', 'invoice_party',
-'currency', 'state'])
+})
 
 @classmethod
 @ModelView.button



[tryton-commits] changeset in modules/sale_opportunity:default Send only the requ...

2022-04-08 Thread Nicolas Évrard
changeset 99aab2e7a1c3 in modules/sale_opportunity:default
details: 
https://hg.tryton.org/modules/sale_opportunity?cmd=changeset=99aab2e7a1c3
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 configuration.py |   3 +--
 opportunity.py   |  49 +++--
 2 files changed, 20 insertions(+), 32 deletions(-)

diffs (150 lines):

diff -r e9d3b5b04d3c -r 99aab2e7a1c3 configuration.py
--- a/configuration.py  Wed Apr 06 23:37:44 2022 +0200
+++ b/configuration.py  Fri Apr 08 19:07:14 2022 +0200
@@ -39,8 +39,7 @@
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=',
 Id('sale_opportunity', 'sequence_type_sale_opportunity')),
-],
-depends=['company'])
+])
 
 @classmethod
 def __register__(cls, module_name):
diff -r e9d3b5b04d3c -r 99aab2e7a1c3 opportunity.py
--- a/opportunity.pyWed Apr 06 23:37:44 2022 +0200
+++ b/opportunity.pyFri Apr 08 19:07:14 2022 +0200
@@ -33,12 +33,10 @@
 _states_start = {
 'readonly': Eval('state') != 'lead',
 }
-_depends_start = ['state']
 _states_stop = {
 'readonly': Eval('state').in_(
 ['converted', 'won', 'lost', 'cancelled']),
 }
-_depends_stop = ['state']
 
 number = fields.Char('Number', readonly=True, required=True, select=True)
 reference = fields.Char('Reference', select=True)
@@ -51,7 +49,7 @@
 context={
 'company': Eval('company', -1),
 },
-depends=['state', 'company'])
+depends={'company'})
 contact = fields.Many2One(
 'party.contact_mechanism', "Contact",
 context={
@@ -63,7 +61,7 @@
 depends=['party', 'company'])
 address = fields.Many2One('party.address', 'Address',
 domain=[('party', '=', Eval('party'))],
-select=True, depends=['party', 'state'],
+select=True,
 states=_states_stop)
 company = fields.Many2One('company.company', 'Company', required=True,
 select=True,
@@ -73,38 +71,32 @@
 domain=[
 ('id', If(In('company', Eval('context', {})), '=', '!='),
 Get(Eval('context', {}), 'company', 0)),
-],
-depends=_depends_stop)
+])
 currency = fields.Function(fields.Many2One(
 'currency.currency', "Currency"),
 'on_change_with_currency')
 amount = Monetary(
 "Amount", currency='currency', digits='currency',
-states=_states_stop, depends=_depends_stop,
+states=_states_stop,
 help='Estimated revenue amount.')
 payment_term = fields.Many2One('account.invoice.payment_term',
 'Payment Term', states={
 'readonly': In(Eval('state'),
 ['converted', 'lost', 'cancelled']),
-},
-depends=['state'])
+})
 employee = fields.Many2One('company.employee', 'Employee',
 states={
 'readonly': _states_stop['readonly'],
 'required': ~Eval('state').in_(['lead', 'lost', 'cancelled']),
 },
-depends=['state', 'company'],
 domain=[('company', '=', Eval('company'))])
 start_date = fields.Date('Start Date', required=True, select=True,
-states=_states_start, depends=_depends_start)
-end_date = fields.Date('End Date', select=True,
-states=_states_stop, depends=_depends_stop)
-description = fields.Char('Description',
-states=_states_stop, depends=_depends_stop)
-comment = fields.Text('Comment', states=_states_stop,
-depends=_depends_stop)
+states=_states_start)
+end_date = fields.Date('End Date', select=True, states=_states_stop)
+description = fields.Char('Description', states=_states_stop)
+comment = fields.Text('Comment', states=_states_stop)
 lines = fields.One2Many('sale.opportunity.line', 'opportunity', 'Lines',
-states=_states_stop, depends=_depends_stop)
+states=_states_stop)
 conversion_probability = fields.Float('Conversion Probability',
 digits=(1, 4), required=True,
 domain=[
@@ -115,10 +107,10 @@
 'readonly': ~Eval('state').in_(
 ['opportunity', 'lead', 'converted']),
 },
-depends=['state'], help="Percentage between 0 and 100.")
+help="Percentage between 0 and 100.")
 lost_reason = fields.Text('Reason for loss', states={
 'invisible': Eval('state') != 'lost',
-}, depends=['state'])
+})
 sales = fields.One2Many('sale.sale', 'origin', 'Sales')
 
 converted_by = employee_field(
@@ -132,8 +124,8 @@
 ('cancelled', "Cancelled"),
 ], "State", required=True, select=True, sort=False, readonly=True)
 
-del _states_start, _depends_start
-del _states_stop, _depends_stop
+del _states_start

[tryton-commits] changeset in modules/sale_gift_card:default Send only the requir...

2022-04-08 Thread Nicolas Évrard
changeset 8a8af20ea329 in modules/sale_gift_card:default
details: 
https://hg.tryton.org/modules/sale_gift_card?cmd=changeset=8a8af20ea329
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 account.py |   9 +++--
 product.py |   3 +--
 sale.py|  24 
 stock.py   |   4 +---
 4 files changed, 13 insertions(+), 27 deletions(-)

diffs (141 lines):

diff -r 92e0d5732427 -r 8a8af20ea329 account.py
--- a/account.pyWed Apr 06 23:37:43 2022 +0200
+++ b/account.pyFri Apr 08 19:07:14 2022 +0200
@@ -42,16 +42,14 @@
 ('type.gift_card', '=', True),
 ('closed', '!=', True),
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
 gift_card_account_revenue = fields.Many2One(
 'account.account', "Gift Card Revenue",
 domain=[
 ('type.gift_card', '=', True),
 ('closed', '!=', True),
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
 
 
 def AccountTypeMixin(template=False):
@@ -66,8 +64,7 @@
 ],
 states={
 'invisible': Eval('statement') != 'balance',
-},
-depends=['statement'])
+})
 if not template:
 for fname in dir(Mixin):
 field = getattr(Mixin, fname)
diff -r 92e0d5732427 -r 8a8af20ea329 product.py
--- a/product.pyWed Apr 06 23:37:43 2022 +0200
+++ b/product.pyFri Apr 08 19:07:14 2022 +0200
@@ -16,8 +16,7 @@
 "Gift Card",
 states={
 'invisible': ~Eval('type').in_(['service', 'goods']),
-},
-depends=['type'])
+})
 
 @fields.depends('gift_card')
 def on_change_gift_card(self):
diff -r 92e0d5732427 -r 8a8af20ea329 sale.py
--- a/sale.py   Wed Apr 06 23:37:43 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -47,8 +47,7 @@
 ('company', 'in', [Eval('company', -1), None]),
 ('sequence_type', '=', Id(
 'sale_gift_card', 'sequence_type_gift_card')),
-],
-depends=['company'])
+])
 
 
 class GiftCard(ModelSQL, ModelView):
@@ -59,13 +58,11 @@
 _states = {
 'readonly': Bool(Eval('origin')) | Bool(Eval('spent_on')),
 }
-_depends = ['origin']
 
 number = fields.Char(
-"Number", required=True, states=_states, depends=_depends)
+"Number", required=True, states=_states)
 company = fields.Many2One(
-'company.company', "Company", required=True,
-states=_states, depends=_depends)
+'company.company', "Company", required=True, states=_states)
 product = fields.Many2One(
 'product.product', "Product", required=True,
 domain=[
@@ -74,13 +71,12 @@
 context={
 'company': Eval('company', -1),
 },
-states=_states, depends=_depends + ['company'])
+states=_states, depends={'company'})
 value = Monetary(
 "Value", currency='currency', digits='currency', required=True,
-states=_states, depends=_depends)
+states=_states)
 currency = fields.Many2One(
-'currency.currency', "Currency", required=True,
-states=_states, depends=_depends)
+'currency.currency', "Currency", required=True, states=_states)
 
 origin = fields.Reference(
 "Origin", selection='get_origin', select=True, readonly=True)
@@ -88,7 +84,6 @@
 "Spent On", selection='get_spent_on', select=True, readonly=True)
 
 del _states
-del _depends
 
 @classmethod
 def __setup__(cls):
@@ -269,8 +264,7 @@
 ],
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['state', 'company', 'currency'])
+})
 
 @classmethod
 @ModelView.button
@@ -339,8 +333,7 @@
 ],
 states={
 'readonly': Eval('state') != 'draft',
-},
-depends=['state', 'company', 'currency'])
+})
 
 @fields.depends('state', 'gift_cards')
 def on_change_with_total(self, name=None):
@@ -410,7 +403,6 @@
 states={
 'invisible': ~Eval('is_gift_card_service', False),
 },
-depends=['is_gift_card_service'],
 help="Leave empty for the customer email.")
 
 @fields.depends('product')
diff -r 92e0d5732427 -r 8a8af20ea329 stock.py
--- a/stock.py  Wed Apr 06 23:37:43 2022 +0200
+++ b/stock.py  Fri Apr 08 19:07:14 2022 +0200
@@ -29,9 +29,7 @@
 & (Eval('state') == 'done')),
 'readonly': Eval('state').in_(['cancel', 'done']),
 },
-depends=[
-'gift_cards_required', 'internal_quantity', 'company', 'product',
-'state'])
+depends={'internal_quantity'})
  

[tryton-commits] changeset in modules/sale_extra:default Send only the required f...

2022-04-08 Thread Nicolas Évrard
changeset 5c6647fd6bd6 in modules/sale_extra:default
details: 
https://hg.tryton.org/modules/sale_extra?cmd=changeset=5c6647fd6bd6
description:
Send only the required fields when fetching a readonly view definition

issue11134
review380081002
diffstat:

 sale.py |  12 
 1 files changed, 4 insertions(+), 8 deletions(-)

diffs (39 lines):

diff -r 951ff9252f4c -r 5c6647fd6bd6 sale.py
--- a/sale.py   Wed Apr 06 23:37:43 2022 +0200
+++ b/sale.py   Fri Apr 08 19:07:14 2022 +0200
@@ -77,22 +77,19 @@
 datetime.date.max,
 Eval('end_date', datetime.date.max))),
 ('start_date', '=', None),
-],
-depends=['end_date'])
+])
 end_date = fields.Date('End Date',
 domain=['OR',
 ('end_date', '>=', If(~Eval('start_date', None),
 datetime.date.min,
 Eval('start_date', datetime.date.min))),
 ('end_date', '=', None),
-],
-depends=['start_date'])
+])
 price_list = fields.Many2One('product.price_list', 'Price List',
 ondelete='CASCADE',
 domain=[
 ('company', '=', Eval('company', -1)),
-],
-depends=['company'])
+])
 sale_amount = Monetary(
 "Sale Amount", currency='currency', digits='currency')
 currency = fields.Function(fields.Many2One(
@@ -209,8 +206,7 @@
 unit = fields.Many2One('product.uom', 'Unit', required=True,
 domain=[
 ('category', '=', Eval('product_uom_category', -1)),
-],
-depends=['product_uom_category'])
+])
 free = fields.Boolean('Free')
 currency = fields.Function(fields.Many2One(
 'currency.currency', "Currency"),



  1   2   3   4   5   >