[tryton-commits] changeset in modules/account_payment:default Add identical party...

2022-07-17 Thread Cédric Krier
changeset 06559019ac3c in modules/account_payment:default
details: 
https://hg.tryton.org/modules/account_payment?cmd=changeset&node=06559019ac3c
description:
Add identical party from payments

issue11385
review380731002
diffstat:

 CHANGELOG |  2 ++
 party.py  |  9 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diffs (33 lines):

diff -r 51e072e56608 -r 06559019ac3c CHANGELOG
--- a/CHANGELOG Tue Jun 21 10:27:43 2022 +0200
+++ b/CHANGELOG Sun Jul 17 19:07:38 2022 +0200
@@ -1,3 +1,5 @@
+* Add identical party from payments
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Allow only lines with maturity date to be paid
diff -r 51e072e56608 -r 06559019ac3c party.py
--- a/party.py  Tue Jun 21 10:27:43 2022 +0200
+++ b/party.py  Sun Jul 17 19:07:38 2022 +0200
@@ -22,11 +22,20 @@
 reception_direct_debits = fields.One2Many(
 'party.party.reception_direct_debit', 'party', "Direct Debits",
 help="Fill to debit automatically the customer.")
+payment_identical_parties = fields.Function(
+fields.Many2Many('party.party', None, None, "Identical Parties"),
+'get_payment_identical_parties')
 
 @classmethod
 def default_payment_direct_debit(cls, **pattern):
 return False
 
+def get_payment_identical_parties(self, name):
+return [p.id for p in self._payment_identical_parties()]
+
+def _payment_identical_parties(self):
+return set()
+
 @classmethod
 def copy(cls, parties, default=None):
 if default is None:



[tryton-commits] changeset in modules/account_payment_braintree:default Add ident...

2022-07-17 Thread Cédric Krier
changeset d4631b7445d7 in modules/account_payment_braintree:default
details: 
https://hg.tryton.org/modules/account_payment_braintree?cmd=changeset&node=d4631b7445d7
description:
Add identical party from payments

issue11385
review380731002
diffstat:

 __init__.py|   1 +
 account.py |  37 +
 party.py   |   7 +++
 view/customer_form.xml |   2 ++
 4 files changed, 47 insertions(+), 0 deletions(-)

diffs (106 lines):

diff -r b92a36815954 -r d4631b7445d7 __init__.py
--- a/__init__.py   Mon May 02 17:23:00 2022 +0200
+++ b/__init__.py   Sun Jul 17 19:07:38 2022 +0200
@@ -17,6 +17,7 @@
 account.PaymentBraintreeRefund,
 account.PaymentBraintreeAccount,
 account.PaymentBraintreeCustomer,
+account.PaymentBraintreeCustomerIdentical,
 account.PaymentBraintreeCustomerPaymentMethodDeleteAsk,
 party.Party,
 party.PartyReceptionDirectDebit,
diff -r b92a36815954 -r d4631b7445d7 account.py
--- a/account.pyMon May 02 17:23:00 2022 +0200
+++ b/account.pySun Jul 17 19:07:38 2022 +0200
@@ -7,6 +7,7 @@
 import braintree
 from braintree.exceptions import GatewayTimeoutError, TooManyRequestsError
 from braintree.exceptions.braintree_error import BraintreeError
+from sql import Literal
 
 from trytond.cache import Cache
 from trytond.config import config
@@ -21,6 +22,7 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Bool, Eval
 from trytond.report import Report
+from trytond.tools import sql_pairing
 from trytond.transaction import Transaction
 from trytond.url import http_host
 from trytond.wizard import (
@@ -916,6 +918,13 @@
 'invisible': ~Eval('braintree_error_message'),
 })
 
+identical_customers = fields.Many2Many(
+'account.payment.braintree.customer.identical',
+'source', 'target', "Identical Customers", readonly=True,
+states={
+'invisible': ~Eval('identical_customers'),
+})
+
 _payment_methods_cache = Cache(
 'account_payment_braintree_customer.payment_methods',
 duration=config.getint(
@@ -1146,6 +1155,34 @@
 self._payment_methods_cache.clear()
 
 
+class PaymentBraintreeCustomerIdentical(ModelSQL):
+"Braintree Customer Identical"
+__name__ = 'account.payment.braintree.customer.identical'
+source = fields.Many2One('account.payment.braintree.customer', "Source")
+target = fields.Many2One('account.payment.braintree.customer', "Target")
+
+@classmethod
+def table_query(cls):
+pool = Pool()
+Customer = pool.get('account.payment.braintree.customer')
+source = Customer.__table__()
+target = Customer.__table__()
+return (
+source
+.join(target, condition=(
+source.braintree_customer_id
+== target.braintree_customer_id))
+.select(
+Literal(0).as_('create_uid'),
+source.create_date.as_('create_date'),
+Literal(None).as_('write_uid'),
+Literal(None).as_('write_date'),
+sql_pairing(source.id, target.id).as_('id'),
+source.id.as_('source'),
+target.id.as_('target'),
+where=source.id != target.id))
+
+
 class PaymentBraintreeCustomerPaymentMethodDelete(Wizard):
 "Delete Customer Payment Method"
 __name__ = 'account.payment.braintree.customer.payment_method.delete'
diff -r b92a36815954 -r d4631b7445d7 party.py
--- a/party.py  Mon May 02 17:23:00 2022 +0200
+++ b/party.py  Sun Jul 17 19:07:38 2022 +0200
@@ -13,6 +13,13 @@
 braintree_customers = fields.One2Many(
 'account.payment.braintree.customer', 'party', "Braintree Customers")
 
+def _payment_identical_parties(self):
+parties = super()._payment_identical_parties()
+for customer in self.braintree_customers:
+for other_customer in customer.identical_customers:
+parties.add(other_customer.party)
+return parties
+
 @classmethod
 def write(cls, *args):
 pool = Pool()
diff -r b92a36815954 -r d4631b7445d7 view/customer_form.xml
--- a/view/customer_form.xmlMon May 02 17:23:00 2022 +0200
+++ b/view/customer_form.xmlSun Jul 17 19:07:38 2022 +0200
@@ -21,4 +21,6 @@
 
 
 
+
+
 



[tryton-commits] changeset in modules/account_payment_stripe:default Add identica...

2022-07-17 Thread Cédric Krier
changeset 990b40c7b2e0 in modules/account_payment_stripe:default
details: 
https://hg.tryton.org/modules/account_payment_stripe?cmd=changeset&node=990b40c7b2e0
description:
Add identical party from payments

issue11385
review380731002
diffstat:

 __init__.py |2 +
 message.xml |3 +
 party.py|7 +
 payment.py  |  104 ++-
 payment.xml |5 +
 tests/scenario_account_payment_stripe_identical.rst |  109 
 view/customer_form.xml  |3 +
 7 files changed, 232 insertions(+), 1 deletions(-)

diffs (355 lines):

diff -r 5443f5e69731 -r 990b40c7b2e0 __init__.py
--- a/__init__.py   Mon May 02 17:23:53 2022 +0200
+++ b/__init__.py   Sun Jul 17 19:07:38 2022 +0200
@@ -13,6 +13,8 @@
 payment.Account,
 payment.Refund,
 payment.Customer,
+payment.CustomerFingerprint,
+payment.CustomerIdentical,
 payment.Journal,
 payment.Group,
 payment.Payment,
diff -r 5443f5e69731 -r 990b40c7b2e0 message.xml
--- a/message.xml   Mon May 02 17:23:53 2022 +0200
+++ b/message.xml   Sun Jul 17 19:07:38 2022 +0200
@@ -9,5 +9,8 @@
 
 To pay "%(payment)s", you cannot use a stripe 
journal "%(journal)s".
 
+
+The fingerprint must be unique by 
customer.
+
 
 
diff -r 5443f5e69731 -r 990b40c7b2e0 party.py
--- a/party.py  Mon May 02 17:23:53 2022 +0200
+++ b/party.py  Sun Jul 17 19:07:38 2022 +0200
@@ -13,6 +13,13 @@
 stripe_customers = fields.One2Many(
 'account.payment.stripe.customer', 'party', "Stripe Customers")
 
+def _payment_identical_parties(self):
+parties = super()._payment_identical_parties()
+for customer in self.stripe_customers:
+for other_customer in customer.identical_customers:
+parties.add(other_customer.party)
+return parties
+
 @classmethod
 def write(cls, *args):
 pool = Pool()
diff -r 5443f5e69731 -r 990b40c7b2e0 payment.py
--- a/payment.pyMon May 02 17:23:53 2022 +0200
+++ b/payment.pySun Jul 17 19:07:38 2022 +0200
@@ -10,12 +10,14 @@
 from operator import attrgetter
 
 import stripe
+from sql import Literal
 
 from trytond.cache import Cache
 from trytond.config import config
 from trytond.i18n import gettext
 from trytond.model import (
-DeactivableMixin, ModelSQL, ModelView, Workflow, dualmethod, fields)
+DeactivableMixin, ModelSQL, ModelView, Unique, Workflow, dualmethod,
+fields)
 from trytond.modules.account_payment.exceptions import (
 PaymentValidationError, ProcessError)
 from trytond.modules.company.model import (
@@ -26,6 +28,7 @@
 from trytond.report import Report, get_email
 from trytond.rpc import RPC
 from trytond.sendmail import sendmail_transactional
+from trytond.tools import sql_pairing
 from trytond.tools.email_ import set_from_header
 from trytond.transaction import Transaction
 from trytond.url import http_host
@@ -436,6 +439,8 @@
 
 The transaction is committed after each payment charge.
 """
+pool = Pool()
+Customer = pool.get('account.payment.stripe.customer')
 if payments is None:
 payments = cls.search([
 ('state', '=', 'processing'),
@@ -508,6 +513,10 @@
 continue
 Transaction().commit()
 
+customers = [p.stripe_customer for p in payments if p.stripe_customer]
+if customers:
+Customer.__queue__.find_identical(customers)
+
 def _charge_parameters(self):
 source, customer = None, None
 if self.stripe_token:
@@ -1332,6 +1341,16 @@
 'invisible': ~Eval('stripe_error_param'),
 })
 
+identical_customers = fields.Many2Many(
+'account.payment.stripe.customer.identical',
+'source', 'target', "Identical Customers", readonly=True,
+states={
+'invisible': ~Eval('identical_customers'),
+})
+fingerprints = fields.One2Many(
+'account.payment.stripe.customer.fingerprint', 'customer',
+"Fingerprints", readonly=True)
+
 _sources_cache = Cache(
 'account_payment_stripe_customer.sources',
 duration=config.getint(
@@ -1355,6 +1374,10 @@
 'invisible': ~Eval('stripe_customer_id'),
 'depends': ['stripe_customer_id'],
 },
+'find_identical': {
+'invisible': ~Eval('stripe_customer_id'),
+'depends': ['stripe_customer_id'],
+},
 })
 
 def get_stripe_checkout_needed(self, name):
@@ -1446,6 +1469,7 @@
 # TODO add card
 customer.save()
   

[tryton-commits] changeset in modules/sale_promotion_coupon:default Support many ...

2022-07-17 Thread Cédric Krier
changeset 7a20a31b7662 in modules/sale_promotion_coupon:default
details: 
https://hg.tryton.org/modules/sale_promotion_coupon?cmd=changeset&node=7a20a31b7662
description:
Support many parties to count coupon

issue11385
review380731002
diffstat:

 CHANGELOG |   2 ++
 sale.py   |  22 +++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r fdfd810c38ad -r 7a20a31b7662 CHANGELOG
--- a/CHANGELOG Mon May 02 17:44:28 2022 +0200
+++ b/CHANGELOG Sun Jul 17 19:09:16 2022 +0200
@@ -1,3 +1,5 @@
+* Support many parties to count coupon
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Add support for Python 3.10
diff -r fdfd810c38ad -r 7a20a31b7662 sale.py
--- a/sale.py   Mon May 02 17:44:28 2022 +0200
+++ b/sale.py   Sun Jul 17 19:09:16 2022 +0200
@@ -92,6 +92,8 @@
 sale_number = Sale_Number.__table__()
 context = Transaction().context
 party = context.get('party')
+if isinstance(party, int):
+party = [party]
 
 query = (table
 .join(sale_number, 'LEFT',
@@ -101,7 +103,7 @@
 if party:
 query = query.join(sale, 'LEFT',
 condition=(sale_number.sale == sale.id)
-& (sale.party == party))
+& (sale.party.in_(party)))
 active = Case(
 ((coupon.number_of_use > 0) & (coupon.per_party),
 Count(sale.id) < coupon.number_of_use),
@@ -182,12 +184,26 @@
 ('coupon.promotion.company', '=', Eval('company', -1)),
 ],
 context={
-'party': Eval('party', -1),
+'party': Eval('coupon_parties', []),
 },
 states={
 'readonly': Eval('state') != 'draft',
 },
-depends={'party'})
+depends={'coupon_parties'})
+coupon_parties = fields.Function(fields.Many2Many(
+'party.party', None, None, "Coupon Parties"),
+'on_change_with_coupon_parties')
+
+@fields.depends(methods=['_coupon_parties'])
+def on_change_with_coupon_parties(self, name=None):
+return [p.id for p in self._coupon_parties()]
+
+@fields.depends('party')
+def _coupon_parties(self):
+parties = set()
+if self.party:
+parties.add(self.party)
+return parties
 
 @classmethod
 @ModelView.button



[tryton-commits] changeset in modules/sale_promotion_coupon_payment:default Add s...

2022-07-17 Thread Cédric Krier
changeset ecaaa3b88fd2 in modules/sale_promotion_coupon_payment:default
details: 
https://hg.tryton.org/modules/sale_promotion_coupon_payment?cmd=changeset&node=ecaaa3b88fd2
description:
Add sale_promotion_coupon_payment module

issue11385
review380731002
diffstat:

 .drone.yml   |   73 +
 .flake8  |2 +
 .isort.cfg   |3 +
 COPYRIGHT|   15 +
 LICENSE  |  674 +++
 MANIFEST.in  |5 +
 README.rst   |1 +
 __init__.py  |   14 +
 doc/conf.py  |   61 
 doc/index.rst|6 +
 sale.py  |   16 +
 setup.py |  158 +++
 tests/__init__.py|2 +
 tests/test_module.py |   12 +
 tox.ini  |   18 +
 tryton.cfg   |7 +
 16 files changed, 1067 insertions(+), 0 deletions(-)

diffs (1132 lines):

diff -r  -r ecaaa3b88fd2 .drone.yml
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/.drone.ymlSun Jul 17 19:09:44 2022 +0200
@@ -0,0 +1,73 @@
+clone:
+hg:
+image: plugins/hg
+environment:
+- HG_SHARE_POOL=/root/.cache/hg
+volumes:
+- cache:/root/.cache
+
+pipeline:
+tox:
+image: ${IMAGE}
+environment:
+- CFLAGS=-O0
+- DB_CACHE=/cache
+- TOX_TESTENV_PASSENV=CFLAGS DB_CACHE CI_BUILD_NUMBER 
CI_JOB_NUMBER CI_JOB_ID
+- POSTGRESQL_URI=postgresql://postgres@postgresql:5432/
+commands:
+- echo "[extensions]" >> /root/.hgrc
+- echo "hgext.share =" >> /root/.hgrc
+- echo "[share]" >> /root/.hgrc
+- echo "pool = /root/.cache/hg" >> /root/.hgrc
+- pip install tox
+- tox -e "${TOXENV}-${DATABASE}"
+volumes:
+- cache:/root/.cache
+check_dist:
+image: ${IMAGE}
+commands:
+- pip install twine
+- python setup.py sdist
+- twine check dist/*
+check_doc:
+image: ${IMAGE]
+commands:
+- pip install sphinx
+- python -m sphinx -T -E -W -n -b html doc _build/html
+
+services:
+postgresql:
+image: postgres
+environment:
+- POSTGRES_HOST_AUTH_METHOD=trust
+command: "-c fsync=off -c synchronous_commit=off -c 
full_page_writes=off"
+when:
+matrix:
+DATABASE: postgresql
+
+matrix:
+include:
+- IMAGE: python:3.7
+  TOXENV: py37
+  DATABASE: sqlite
+- IMAGE: python:3.7
+  TOXENV: py37
+  DATABASE: postgresql
+- IMAGE: python:3.8
+  TOXENV: py38
+  DATABASE: sqlite
+- IMAGE: python:3.8
+  TOXENV: py38
+  DATABASE: postgresql
+- IMAGE: python:3.9
+  TOXENV: py39
+  DATABASE: sqlite
+- IMAGE: python:3.9
+  TOXENV: py39
+  DATABASE: postgresql
+- IMAGE: python:3.10
+  TOXENV: py310
+  DATABASE: sqlite
+- IMAGE: python:3.10
+  TOXENV: py310
+  DATABASE: postgresql
diff -r  -r ecaaa3b88fd2 .flake8
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/.flake8   Sun Jul 17 19:09:44 2022 +0200
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,E741,W503
diff -r  -r ecaaa3b88fd2 .isort.cfg
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/.isort.cfgSun Jul 17 19:09:44 2022 +0200
@@ -0,0 +1,3 @@
+[settings]
+multi_line_output=4
+known_first_party=trytond
diff -r  -r ecaaa3b88fd2 COPYRIGHT
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/COPYRIGHT Sun Jul 17 19:09:44 2022 +0200
@@ -0,0 +1,15 @@
+Copyright (C) 2022 B2CK
+Copyright (C) 2022 Cédric Krier
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see .
diff -r  -r ecaaa3b88fd2 LICENSE
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/LICENSE   Sun Jul 17 19:09:44 2022 +0200
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+   Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. 
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+Preamble
+
+  The GNU General Public License 

[tryton-commits] changeset in readthedocs:default Add sale_promotion_coupon_payme...

2022-07-17 Thread Cédric Krier
changeset bdd665a32a8c in readthedocs:default
details: https://hg.tryton.org/readthedocs?cmd=changeset&node=bdd665a32a8c
description:
Add sale_promotion_coupon_payment module

issue11385
review380731002
diffstat:

 sale.rst |  3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diffs (13 lines):

diff -r b2c59f12cbef -r bdd665a32a8c sale.rst
--- a/sale.rst  Tue Apr 12 10:10:24 2022 +0200
+++ b/sale.rst  Sun Jul 17 19:09:44 2022 +0200
@@ -59,6 +59,9 @@
 `Promotion Coupon `_
 Applies promotions with coupons.
 
+`Promotion Coupon Payment 
`_
+Count coupon per identical payment party.
+
 `Shipment Cost `_
 Computes shipment cost.
 



[tryton-commits] changeset in modules/sale_promotion_coupon_payment:default Fix i...

2022-07-17 Thread Cédric Krier
changeset 6fa97093a1c8 in modules/sale_promotion_coupon_payment:default
details: 
https://hg.tryton.org/modules/sale_promotion_coupon_payment?cmd=changeset&node=6fa97093a1c8
description:
Fix image name and add linkcheck and volumes to drone
diffstat:

 .drone.yml |  7 ++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (21 lines):

diff -r ecaaa3b88fd2 -r 6fa97093a1c8 .drone.yml
--- a/.drone.ymlSun Jul 17 19:09:44 2022 +0200
+++ b/.drone.ymlSun Jul 17 19:20:12 2022 +0200
@@ -29,11 +29,16 @@
 - pip install twine
 - python setup.py sdist
 - twine check dist/*
+volumes:
+- cache:/root/.cache
 check_doc:
-image: ${IMAGE]
+image: ${IMAGE}
 commands:
 - pip install sphinx
 - python -m sphinx -T -E -W -n -b html doc _build/html
+- python -m sphinx -T -E -W -n -b linkcheck doc _build
+volumes:
+- cache:/root/.cache
 
 services:
 postgresql:



[tryton-commits] changeset in weblate:default Add sale_promotion_coupon_payment m...

2022-07-17 Thread Cédric Krier
changeset 72f04eb8c4f7 in weblate:default
details: https://hg.tryton.org/weblate?cmd=changeset&node=72f04eb8c4f7
description:
Add sale_promotion_coupon_payment module



[tryton-commits] changeset in modules/account:6.4 Do not compare debit or credit ...

2022-07-17 Thread Adrià Tarroja Caubet
changeset 1de89b5bb246 in modules/account:6.4
details: https://hg.tryton.org/modules/account?cmd=changeset&node=1de89b5bb246
description:
Do not compare debit or credit to None when searching

issue11568
review417441003
(grafted from 6d06c13574dddb21e36970afd27ea674ddaf4de6)
diffstat:

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

diffs (21 lines):

diff -r 0da16af7d520 -r 1de89b5bb246 account.py
--- a/account.pyFri Jun 03 19:38:58 2022 +0200
+++ b/account.pyFri Jun 24 09:19:13 2022 +0200
@@ -1952,7 +1952,7 @@
 break
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, fname), operand)]
+if operand is not None and operator_(getattr(a, fname), operand)]
 return [('id', 'in', ids)]
 
 @classmethod
@@ -2000,7 +2000,7 @@
 }.get(operator_, lambda v, l: False)
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, name), operand)]
+if operand is not None and operator_(getattr(a, name), operand)]
 return [('id', 'in', ids)]
 
 def get_currency(self, name):



[tryton-commits] changeset in modules/account:6.2 Do not compare debit or credit ...

2022-07-17 Thread Adrià Tarroja Caubet
changeset b8f51d159001 in modules/account:6.2
details: https://hg.tryton.org/modules/account?cmd=changeset&node=b8f51d159001
description:
Do not compare debit or credit to None when searching

issue11568
review417441003
(grafted from 6d06c13574dddb21e36970afd27ea674ddaf4de6)
diffstat:

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

diffs (21 lines):

diff -r 745eac45f8e1 -r b8f51d159001 account.py
--- a/account.pyFri Jun 03 19:39:33 2022 +0200
+++ b/account.pyFri Jun 24 09:19:13 2022 +0200
@@ -1762,7 +1762,7 @@
 break
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, fname), operand)]
+if operand is not None and operator_(getattr(a, fname), operand)]
 return [('id', 'in', ids)]
 
 @classmethod
@@ -1810,7 +1810,7 @@
 }.get(operator_, lambda v, l: False)
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, name), operand)]
+if operand is not None and operator_(getattr(a, name), operand)]
 return [('id', 'in', ids)]
 
 def get_currency(self, name):



[tryton-commits] changeset in modules/account:6.0 Do not compare debit or credit ...

2022-07-17 Thread Adrià Tarroja Caubet
changeset 9a6dadee9e9b in modules/account:6.0
details: https://hg.tryton.org/modules/account?cmd=changeset&node=9a6dadee9e9b
description:
Do not compare debit or credit to None when searching

issue11568
review417441003
(grafted from 6d06c13574dddb21e36970afd27ea674ddaf4de6)
diffstat:

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

diffs (21 lines):

diff -r f6ab5fe8c4cd -r 9a6dadee9e9b account.py
--- a/account.pyFri Jun 03 19:41:06 2022 +0200
+++ b/account.pyFri Jun 24 09:19:13 2022 +0200
@@ -1832,7 +1832,7 @@
 break
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, fname), operand)]
+if operand is not None and operator_(getattr(a, fname), operand)]
 return [('id', 'in', ids)]
 
 @classmethod
@@ -1880,7 +1880,7 @@
 }.get(operator_, lambda v, l: False)
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, name), operand)]
+if operand is not None and operator_(getattr(a, name), operand)]
 return [('id', 'in', ids)]
 
 def get_currency(self, name):



[tryton-commits] changeset in modules/account:5.0 Do not compare debit or credit ...

2022-07-17 Thread Adrià Tarroja Caubet
changeset 330ed6684e82 in modules/account:5.0
details: https://hg.tryton.org/modules/account?cmd=changeset&node=330ed6684e82
description:
Do not compare debit or credit to None when searching

issue11568
review417441003
(grafted from 6d06c13574dddb21e36970afd27ea674ddaf4de6)
diffstat:

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

diffs (21 lines):

diff -r 037869b1e733 -r 330ed6684e82 account.py
--- a/account.pyFri Jun 03 19:41:54 2022 +0200
+++ b/account.pyFri Jun 24 09:19:13 2022 +0200
@@ -1468,7 +1468,7 @@
 break
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, fname), operand)]
+if operand is not None and operator_(getattr(a, fname), operand)]
 return [('id', 'in', ids)]
 
 @classmethod
@@ -1518,7 +1518,7 @@
 }.get(operator_, lambda v, l: False)
 
 ids = [a.id for a in accounts
-if operator_(getattr(a, name), operand)]
+if operand is not None and operator_(getattr(a, name), operand)]
 return [('id', 'in', ids)]
 
 def get_currency_digits(self, name):



[tryton-commits] changeset in modules/account_invoice:6.4 Ensure unique taxes whe...

2022-07-17 Thread Cédric Krier
changeset 8fffa57bd1f8 in modules/account_invoice:6.4
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=8fffa57bd1f8
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 33d9a972aec917661ddff1f8c7bf6e478b3a57ba)
diffstat:

 invoice.py |  24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (77 lines):

diff -r c6deb0205155 -r 8fffa57bd1f8 invoice.py
--- a/invoice.pyMon May 02 17:06:15 2022 +0200
+++ b/invoice.pySun Jul 17 00:00:56 2022 +0200
@@ -2271,19 +2271,19 @@
 if type_ == 'in':
 with Transaction().set_context(date=date):
 self.account = self.product.account_expense_used
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.supplier_taxes_used:
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax)
+taxes.add(tax.id)
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 self.taxes = taxes
 
 if self.company and self.company.purchase_taxes_expense:
@@ -2294,19 +2294,19 @@
 else:
 with Transaction().set_context(date=date):
 self.account = self.product.account_revenue_used
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.customer_taxes_used:
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 self.taxes = taxes
 
 category = self.product.default_uom.category
@@ -2325,7 +2325,7 @@
 def on_change_account(self):
 if self.product:
 return
-taxes = []
+taxes = set()
 party = None
 if self.invoice and self.invoice.party:
 party = self.invoice.party
@@ -2350,13 +2350,13 @@
 if tax_rule:
 tax_ids = tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax)
+taxes.add(tax.id)
 if tax_rule:
 tax_ids = tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 self.taxes = taxes
 
 @classmethod



[tryton-commits] changeset in modules/account_invoice:6.2 Ensure unique taxes whe...

2022-07-17 Thread Cédric Krier
changeset 32b96d770e06 in modules/account_invoice:6.2
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=32b96d770e06
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 33d9a972aec917661ddff1f8c7bf6e478b3a57ba)
diffstat:

 invoice.py |  24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (77 lines):

diff -r f942f615b808 -r 32b96d770e06 invoice.py
--- a/invoice.pyFri Apr 15 23:36:32 2022 +0200
+++ b/invoice.pySun Jul 17 00:00:56 2022 +0200
@@ -2199,19 +2199,19 @@
 if type_ == 'in':
 with Transaction().set_context(date=date):
 self.account = self.product.account_expense_used
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.supplier_taxes_used:
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax)
+taxes.add(tax.id)
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 self.taxes = taxes
 
 if self.company and self.company.purchase_taxes_expense:
@@ -,19 +,19 @@
 else:
 with Transaction().set_context(date=date):
 self.account = self.product.account_revenue_used
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.customer_taxes_used:
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 self.taxes = taxes
 
 category = self.product.default_uom.category
@@ -2253,7 +2253,7 @@
 def on_change_account(self):
 if self.product:
 return
-taxes = []
+taxes = set()
 party = None
 if self.invoice and self.invoice.party:
 party = self.invoice.party
@@ -2278,13 +2278,13 @@
 if tax_rule:
 tax_ids = tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax)
+taxes.add(tax.id)
 if tax_rule:
 tax_ids = tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 self.taxes = taxes
 
 @classmethod



[tryton-commits] changeset in modules/incoterm:6.4 Format location name for incot...

2022-07-17 Thread Maxime Richez
changeset 49d34c8cdf02 in modules/incoterm:6.4
details: https://hg.tryton.org/modules/incoterm?cmd=changeset&node=49d34c8cdf02
description:
Format location name for incoterm name

issue11578
review443311003
(grafted from fb0d131ddcc3a8c762fae6774d24e4a4a9fc0e72)
diffstat:

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

diffs (12 lines):

diff -r ceb6e8928d63 -r 49d34c8cdf02 common.py
--- a/common.py Mon May 02 17:58:35 2022 +0200
+++ b/common.py Mon Jul 11 22:07:22 2022 +0200
@@ -55,7 +55,7 @@
 if self.incoterm:
 name = self.incoterm.rec_name
 if self.incoterm_location:
-name += ' %s' + self.incoterm_location.rec_name
+name += ' %s' % self.incoterm_location.rec_name
 return name
 
 



[tryton-commits] changeset in modules/incoterm:6.2 Format location name for incot...

2022-07-17 Thread Maxime Richez
changeset 0620235caa30 in modules/incoterm:6.2
details: https://hg.tryton.org/modules/incoterm?cmd=changeset&node=0620235caa30
description:
Format location name for incoterm name

issue11578
review443311003
(grafted from fb0d131ddcc3a8c762fae6774d24e4a4a9fc0e72)
diffstat:

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

diffs (12 lines):

diff -r 3aea183c7447 -r 0620235caa30 common.py
--- a/common.py Mon Nov 01 17:38:18 2021 +0100
+++ b/common.py Mon Jul 11 22:07:22 2022 +0200
@@ -57,7 +57,7 @@
 if self.incoterm:
 name = self.incoterm.rec_name
 if self.incoterm_location:
-name += ' %s' + self.incoterm_location.rec_name
+name += ' %s' % self.incoterm_location.rec_name
 return name
 
 



[tryton-commits] changeset in modules/incoterm:6.0 Format location name for incot...

2022-07-17 Thread Maxime Richez
changeset 36b5c557dff6 in modules/incoterm:6.0
details: https://hg.tryton.org/modules/incoterm?cmd=changeset&node=36b5c557dff6
description:
Format location name for incoterm name

issue11578
review443311003
(grafted from fb0d131ddcc3a8c762fae6774d24e4a4a9fc0e72)
diffstat:

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

diffs (12 lines):

diff -r 2e793b252885 -r 36b5c557dff6 common.py
--- a/common.py Fri Nov 05 00:14:36 2021 +0100
+++ b/common.py Mon Jul 11 22:07:22 2022 +0200
@@ -57,7 +57,7 @@
 if self.incoterm:
 name = self.incoterm.rec_name
 if self.incoterm_location:
-name += ' %s' + self.incoterm_location.rec_name
+name += ' %s' % self.incoterm_location.rec_name
 return name
 
 



[tryton-commits] changeset in modules/production:6.4 Set unit price to 0 for outp...

2022-07-17 Thread Bernat
changeset 3159886b2f52 in modules/production:6.4
details: 
https://hg.tryton.org/modules/production?cmd=changeset&node=3159886b2f52
description:
Set unit price to 0 for output move with no quantity

issue11520
review417261003
(grafted from b12afbde5a7a0686cc1eab4fe6ad9f843203f53a)
diffstat:

 production.py |  7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (17 lines):

diff -r 110fd44adcf3 -r 3159886b2f52 production.py
--- a/production.py Mon May 02 17:07:06 2022 +0200
+++ b/production.py Tue Jun 28 15:25:29 2022 +0200
@@ -597,8 +597,11 @@
 ratio = prices.get(output, 0) / sum_
 else:
 ratio = Decimal(1) / len(outputs)
-quantity = Decimal(str(output.quantity))
-unit_price = round_price(cost * ratio / quantity)
+if not output.quantity:
+unit_price = Decimal(0)
+else:
+quantity = Decimal(str(output.quantity))
+unit_price = round_price(cost * ratio / quantity)
 if output.unit_price != unit_price:
 output.unit_price = unit_price
 moves.append(output)



[tryton-commits] changeset in modules/production:6.2 Set unit price to 0 for outp...

2022-07-17 Thread Bernat
changeset 4420222e42fd in modules/production:6.2
details: 
https://hg.tryton.org/modules/production?cmd=changeset&node=4420222e42fd
description:
Set unit price to 0 for output move with no quantity

issue11520
review417261003
(grafted from b12afbde5a7a0686cc1eab4fe6ad9f843203f53a)
diffstat:

 production.py |  7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (17 lines):

diff -r bc0b20218469 -r 4420222e42fd production.py
--- a/production.py Sat Jan 01 18:19:39 2022 +0100
+++ b/production.py Tue Jun 28 15:25:29 2022 +0200
@@ -612,8 +612,11 @@
 ratio = prices.get(output, 0) / sum_
 else:
 ratio = Decimal(1) / len(outputs)
-quantity = Decimal(str(output.quantity))
-unit_price = round_price(cost * ratio / quantity)
+if not output.quantity:
+unit_price = Decimal(0)
+else:
+quantity = Decimal(str(output.quantity))
+unit_price = round_price(cost * ratio / quantity)
 if output.unit_price != unit_price:
 output.unit_price = unit_price
 moves.append(output)



[tryton-commits] changeset in modules/production:6.0 Set unit price to 0 for outp...

2022-07-17 Thread Bernat
changeset 932816ac8f53 in modules/production:6.0
details: 
https://hg.tryton.org/modules/production?cmd=changeset&node=932816ac8f53
description:
Set unit price to 0 for output move with no quantity

issue11520
review417261003
(grafted from b12afbde5a7a0686cc1eab4fe6ad9f843203f53a)
diffstat:

 production.py |  7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (17 lines):

diff -r 0a3d99abb8cf -r 932816ac8f53 production.py
--- a/production.py Fri Apr 15 23:29:37 2022 +0200
+++ b/production.py Tue Jun 28 15:25:29 2022 +0200
@@ -615,8 +615,11 @@
 ratio = prices.get(output, 0) / sum_
 else:
 ratio = Decimal(1) / len(outputs)
-quantity = Decimal(str(output.quantity))
-unit_price = round_price(cost * ratio / quantity)
+if not output.quantity:
+unit_price = Decimal(0)
+else:
+quantity = Decimal(str(output.quantity))
+unit_price = round_price(cost * ratio / quantity)
 if output.unit_price != unit_price:
 output.unit_price = unit_price
 moves.append(output)



[tryton-commits] changeset in modules/production:6.4 Set rec_name of default valu...

2022-07-17 Thread Cédric Krier
changeset babef277b5e3 in modules/production:6.4
details: 
https://hg.tryton.org/modules/production?cmd=changeset&node=babef277b5e3
description:
Set rec_name of default values in a dictionary under dotted suffix

This follow the API change of issue7888.

issue11573
review443301003
(grafted from 822b4e7e364838bc7f1cb4a7e131e55d0e8e3daa)
diffstat:

 bom.py |  16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 3159886b2f52 -r babef277b5e3 bom.py
--- a/bom.pyTue Jun 28 15:25:29 2022 +0200
+++ b/bom.pySat Jul 09 23:16:42 2022 +0200
@@ -172,10 +172,14 @@
 childs = cls.tree(input_.product, quantity, input_.uom)
 values = {
 'product': input_.product.id,
-'product.rec_name': input_.product.rec_name,
+'product.': {
+'rec_name': input_.product.rec_name,
+},
 'quantity': quantity,
 'uom': input_.uom.id,
-'uom.rec_name': input_.uom.rec_name,
+'uom.': {
+'rec_name': input_.uom.rec_name,
+},
 'childs': childs,
 }
 result.append(values)
@@ -215,10 +219,14 @@
 childs = Tree.tree(product, quantity, uom, bom=bom)
 bom_tree = [{
 'product': product.id,
-'product.rec_name': product.rec_name,
+'product.': {
+'rec_name': product.rec_name,
+},
 'quantity': quantity,
 'uom': uom.id,
-'uom.rec_name': uom.rec_name,
+'uom.': {
+'rec_name': uom.rec_name,
+},
 'childs': childs,
 }]
 return {



[tryton-commits] changeset in modules/production:6.2 Set rec_name of default valu...

2022-07-17 Thread Cédric Krier
changeset 29320128ff57 in modules/production:6.2
details: 
https://hg.tryton.org/modules/production?cmd=changeset&node=29320128ff57
description:
Set rec_name of default values in a dictionary under dotted suffix

This follow the API change of issue7888.

issue11573
review443301003
(grafted from 822b4e7e364838bc7f1cb4a7e131e55d0e8e3daa)
diffstat:

 bom.py |  16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 4420222e42fd -r 29320128ff57 bom.py
--- a/bom.pyTue Jun 28 15:25:29 2022 +0200
+++ b/bom.pySat Jul 09 23:16:42 2022 +0200
@@ -172,10 +172,14 @@
 childs = cls.tree(input_.product, quantity, input_.uom)
 values = {
 'product': input_.product.id,
-'product.rec_name': input_.product.rec_name,
+'product.': {
+'rec_name': input_.product.rec_name,
+},
 'quantity': quantity,
 'uom': input_.uom.id,
-'uom.rec_name': input_.uom.rec_name,
+'uom.': {
+'rec_name': input_.uom.rec_name,
+},
 'childs': childs,
 }
 result.append(values)
@@ -215,10 +219,14 @@
 childs = Tree.tree(product, quantity, uom, bom=bom)
 bom_tree = [{
 'product': product.id,
-'product.rec_name': product.rec_name,
+'product.': {
+'rec_name': product.rec_name,
+},
 'quantity': quantity,
 'uom': uom.id,
-'uom.rec_name': uom.rec_name,
+'uom.': {
+'rec_name': uom.rec_name,
+},
 'childs': childs,
 }]
 return {



[tryton-commits] changeset in modules/production:6.0 Set rec_name of default valu...

2022-07-17 Thread Cédric Krier
changeset 6e4e4a0232d5 in modules/production:6.0
details: 
https://hg.tryton.org/modules/production?cmd=changeset&node=6e4e4a0232d5
description:
Set rec_name of default values in a dictionary under dotted suffix

This follow the API change of issue7888.

issue11573
review443301003
(grafted from 822b4e7e364838bc7f1cb4a7e131e55d0e8e3daa)
diffstat:

 bom.py |  16 
 1 files changed, 12 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r 932816ac8f53 -r 6e4e4a0232d5 bom.py
--- a/bom.pyTue Jun 28 15:25:29 2022 +0200
+++ b/bom.pySat Jul 09 23:16:42 2022 +0200
@@ -168,10 +168,14 @@
 childs = cls.tree(input_.product, quantity, input_.uom)
 values = {
 'product': input_.product.id,
-'product.rec_name': input_.product.rec_name,
+'product.': {
+'rec_name': input_.product.rec_name,
+},
 'quantity': quantity,
 'uom': input_.uom.id,
-'uom.rec_name': input_.uom.rec_name,
+'uom.': {
+'rec_name': input_.uom.rec_name,
+},
 'unit_digits': input_.uom.digits,
 'childs': childs,
 }
@@ -220,10 +224,14 @@
 childs = Tree.tree(product, quantity, uom, bom=bom)
 bom_tree = [{
 'product': product.id,
-'product.rec_name': product.rec_name,
+'product.': {
+'rec_name': product.rec_name,
+},
 'quantity': quantity,
 'uom': uom.id,
-'uom.rec_name': uom.rec_name,
+'uom.': {
+'rec_name': uom.rec_name,
+},
 'unit_digits': uom.digits,
 'childs': childs,
 }]



[tryton-commits] changeset in modules/purchase:6.4 Do not inherit access rights f...

2022-07-17 Thread Cédric Krier
changeset 653ccb75ea96 in modules/purchase:6.4
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=653ccb75ea96
description:
Do not inherit access rights from product and template for product 
supplier and customer

issue11580
review449121003
(grafted from c9377d520421eb4dd33722e69a42b00552ffa008)
diffstat:

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

diffs (15 lines):

diff -r 56c595af42e6 -r 653ccb75ea96 product.py
--- a/product.pyFri Jun 03 19:20:24 2022 +0200
+++ b/product.pySat Jul 09 23:17:58 2022 +0200
@@ -296,11 +296,6 @@
 fields.Many2One('product.uom', "UOM"), 'on_change_with_uom')
 
 @classmethod
-def __setup__(cls):
-super().__setup__()
-cls.__access__.update(['product', 'template'])
-
-@classmethod
 def __register__(cls, module_name):
 transaction = Transaction()
 cursor = transaction.connection.cursor()



[tryton-commits] changeset in modules/purchase:6.2 Do not inherit access rights f...

2022-07-17 Thread Cédric Krier
changeset c760b6a9159b in modules/purchase:6.2
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=c760b6a9159b
description:
Do not inherit access rights from product and template for product 
supplier and customer

issue11580
review449121003
(grafted from c9377d520421eb4dd33722e69a42b00552ffa008)
diffstat:

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

diffs (15 lines):

diff -r 19564f0e6b45 -r c760b6a9159b product.py
--- a/product.pyFri Jun 03 19:20:57 2022 +0200
+++ b/product.pySat Jul 09 23:17:58 2022 +0200
@@ -300,11 +300,6 @@
 fields.Many2One('product.uom', "UOM"), 'on_change_with_uom')
 
 @classmethod
-def __setup__(cls):
-super().__setup__()
-cls.__access__.update(['product', 'template'])
-
-@classmethod
 def __register__(cls, module_name):
 transaction = Transaction()
 cursor = transaction.connection.cursor()



[tryton-commits] changeset in modules/purchase:6.0 Do not inherit access rights f...

2022-07-17 Thread Cédric Krier
changeset bb5545807748 in modules/purchase:6.0
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=bb5545807748
description:
Do not inherit access rights from product and template for product 
supplier and customer

issue11580
review449121003
(grafted from c9377d520421eb4dd33722e69a42b00552ffa008)
diffstat:

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

diffs (15 lines):

diff -r cc5b530e667e -r bb5545807748 product.py
--- a/product.pySun Jul 17 00:02:22 2022 +0200
+++ b/product.pySat Jul 09 23:17:58 2022 +0200
@@ -298,11 +298,6 @@
 fields.Many2One('product.uom', "UOM"), 'on_change_with_uom')
 
 @classmethod
-def __setup__(cls):
-super().__setup__()
-cls.__access__.update(['product', 'template'])
-
-@classmethod
 def __register__(cls, module_name):
 transaction = Transaction()
 cursor = transaction.connection.cursor()



[tryton-commits] changeset in modules/purchase:6.4 Ensure unique taxes when apply...

2022-07-17 Thread Cédric Krier
changeset 27a1a34ce6ec in modules/purchase:6.4
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=27a1a34ce6ec
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 60fe20c8a4310457cb8e7b97e71c9616f10e13d9)
diffstat:

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

diffs (29 lines):

diff -r 653ccb75ea96 -r 27a1a34ce6ec purchase.py
--- a/purchase.py   Sat Jul 09 23:17:58 2022 +0200
+++ b/purchase.py   Sun Jul 17 00:00:56 2022 +0200
@@ -1332,20 +1332,20 @@
 
 @fields.depends('product', methods=['_get_tax_rule_pattern'])
 def compute_taxes(self, party):
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.supplier_taxes_used:
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
-return taxes
+taxes.update(tax_ids)
+return list(taxes)
 
 @fields.depends('product', 'quantity',
 methods=['_get_context_purchase_price'])



[tryton-commits] changeset in modules/purchase:6.2 Ensure unique taxes when apply...

2022-07-17 Thread Cédric Krier
changeset ef7519ebd9f0 in modules/purchase:6.2
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=ef7519ebd9f0
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 60fe20c8a4310457cb8e7b97e71c9616f10e13d9)
diffstat:

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

diffs (29 lines):

diff -r c760b6a9159b -r ef7519ebd9f0 purchase.py
--- a/purchase.py   Sat Jul 09 23:17:58 2022 +0200
+++ b/purchase.py   Sun Jul 17 00:00:56 2022 +0200
@@ -1339,20 +1339,20 @@
 
 @fields.depends('product', methods=['_get_tax_rule_pattern'])
 def compute_taxes(self, party):
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.supplier_taxes_used:
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if party and party.supplier_tax_rule:
 tax_ids = party.supplier_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
-return taxes
+taxes.update(tax_ids)
+return list(taxes)
 
 @fields.depends('product', 'quantity',
 methods=['_get_context_purchase_price'])



[tryton-commits] changeset in modules/sale:6.4 Ensure unique taxes when applying ...

2022-07-17 Thread Cédric Krier
changeset d50f5ad354e8 in modules/sale:6.4
details: https://hg.tryton.org/modules/sale?cmd=changeset&node=d50f5ad354e8
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 453100758df4109b48b64c5f98643345b946ad4d)
diffstat:

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

diffs (29 lines):

diff -r b9ebf0ef08f0 -r d50f5ad354e8 sale.py
--- a/sale.py   Wed Jun 15 22:03:38 2022 +0200
+++ b/sale.py   Sun Jul 17 00:00:56 2022 +0200
@@ -1345,20 +1345,20 @@
 
 @fields.depends('product', methods=['_get_tax_rule_pattern'])
 def compute_taxes(self, party):
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.customer_taxes_used:
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
-return taxes
+taxes.update(tax_ids)
+return list(taxes)
 
 @fields.depends('product', 'quantity', methods=['_get_context_sale_price'])
 def compute_unit_price(self):



[tryton-commits] changeset in modules/sale:6.2 Ensure unique taxes when applying ...

2022-07-17 Thread Cédric Krier
changeset c7e8c1dfef72 in modules/sale:6.2
details: https://hg.tryton.org/modules/sale?cmd=changeset&node=c7e8c1dfef72
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 453100758df4109b48b64c5f98643345b946ad4d)
diffstat:

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

diffs (29 lines):

diff -r 5a89865a0557 -r c7e8c1dfef72 sale.py
--- a/sale.py   Fri Jul 01 23:22:42 2022 +0200
+++ b/sale.py   Sun Jul 17 00:00:56 2022 +0200
@@ -1333,20 +1333,20 @@
 
 @fields.depends('product', methods=['_get_tax_rule_pattern'])
 def compute_taxes(self, party):
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in self.product.customer_taxes_used:
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if party and party.customer_tax_rule:
 tax_ids = party.customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
-return taxes
+taxes.update(tax_ids)
+return list(taxes)
 
 @fields.depends('product', 'quantity', methods=['_get_context_sale_price'])
 def compute_unit_price(self):



[tryton-commits] changeset in modules/sale_point:6.4 Add empty slots to AbstractM...

2022-07-17 Thread Cédric Krier
changeset c152150e40e8 in modules/sale_point:6.4
details: 
https://hg.tryton.org/modules/sale_point?cmd=changeset&node=c152150e40e8
description:
Add empty slots to AbstractMixin

It is not detected by the standard test because it is registered as 
mixin.
(grafted from d1d6c41e97dd2b785155596a2d1a930d4f295acb)
diffstat:

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

diffs (11 lines):

diff -r 700adef75681 -r c152150e40e8 sale_reporting.py
--- a/sale_reporting.py Mon May 02 17:29:51 2022 +0200
+++ b/sale_reporting.py Fri Jul 01 14:46:34 2022 +0200
@@ -7,6 +7,7 @@
 
 
 class AbstractMixin:
+__slots__ = ()
 
 @classmethod
 def _pos_sale_line(cls, length, index, company_id=None):



[tryton-commits] changeset in modules/sale_product_customer:6.4 Do not inherit ac...

2022-07-17 Thread Cédric Krier
changeset 6a0841360c1d in modules/sale_product_customer:6.4
details: 
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset&node=6a0841360c1d
description:
Do not inherit access rights from product and template for product 
supplier and customer

issue11580
review449121003
(grafted from 68ad207b6db0445910bb7e7e756a37d6d5c29f50)
diffstat:

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

diffs (15 lines):

diff -r 550114ca083c -r 6a0841360c1d product.py
--- a/product.pyWed Jun 15 09:22:51 2022 +0200
+++ b/product.pySat Jul 09 23:17:58 2022 +0200
@@ -36,11 +36,6 @@
 name = fields.Char("Name", translate=True)
 code = fields.Char("Code")
 
-@classmethod
-def __setup__(cls):
-super().__setup__()
-cls.__access__.update(['template', 'product'])
-
 @fields.depends(
 'product', '_parent_product.template')
 def on_change_product(self):



[tryton-commits] changeset in modules/sale_product_customer:6.2 Do not inherit ac...

2022-07-17 Thread Cédric Krier
changeset a76bc3166102 in modules/sale_product_customer:6.2
details: 
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset&node=a76bc3166102
description:
Do not inherit access rights from product and template for product 
supplier and customer

issue11580
review449121003
(grafted from 68ad207b6db0445910bb7e7e756a37d6d5c29f50)
diffstat:

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

diffs (15 lines):

diff -r 4490fea8ae70 -r a76bc3166102 product.py
--- a/product.pyWed Jun 15 09:23:22 2022 +0200
+++ b/product.pySat Jul 09 23:17:58 2022 +0200
@@ -38,11 +38,6 @@
 name = fields.Char("Name", translate=True)
 code = fields.Char("Code")
 
-@classmethod
-def __setup__(cls):
-super().__setup__()
-cls.__access__.update(['template', 'product'])
-
 @fields.depends(
 'product', '_parent_product.template')
 def on_change_product(self):



[tryton-commits] changeset in modules/sale_product_customer:6.0 Do not inherit ac...

2022-07-17 Thread Cédric Krier
changeset 35097b0f2637 in modules/sale_product_customer:6.0
details: 
https://hg.tryton.org/modules/sale_product_customer?cmd=changeset&node=35097b0f2637
description:
Do not inherit access rights from product and template for product 
supplier and customer

issue11580
review449121003
(grafted from 68ad207b6db0445910bb7e7e756a37d6d5c29f50)
diffstat:

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

diffs (15 lines):

diff -r 9dfa60ca95d0 -r 35097b0f2637 product.py
--- a/product.pyWed Jun 15 09:23:52 2022 +0200
+++ b/product.pySat Jul 09 23:17:58 2022 +0200
@@ -38,11 +38,6 @@
 name = fields.Char("Name", translate=True)
 code = fields.Char("Code")
 
-@classmethod
-def __setup__(cls):
-super().__setup__()
-cls.__access__.update(['template', 'product'])
-
 @fields.depends(
 'product', '_parent_product.template')
 def on_change_product(self):



[tryton-commits] changeset in modules/stock_consignment:6.4 Ensure unique taxes w...

2022-07-17 Thread Cédric Krier
changeset 35b0bb152ef0 in modules/stock_consignment:6.4
details: 
https://hg.tryton.org/modules/stock_consignment?cmd=changeset&node=35b0bb152ef0
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 4b2d18f8cd61aa7b2815f60a5d452522825db5ea)
diffstat:

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

diffs (51 lines):

diff -r 59e9b3dc8078 -r 35b0bb152ef0 stock.py
--- a/stock.py  Mon May 02 17:46:34 2022 +0200
+++ b/stock.py  Sun Jul 17 00:00:56 2022 +0200
@@ -186,19 +186,19 @@
 line.stock_moves = [self]
 line.origin = self
 
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in line.product.supplier_taxes_used:
 if line.party.supplier_tax_rule:
 tax_ids = line.party.supplier_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if line.party.supplier_tax_rule:
 tax_ids = line.party.supplier_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 line.taxes = taxes
 
 with Transaction().set_context(
@@ -231,19 +231,19 @@
 line.stock_moves = [self]
 line.origin = self
 
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in line.product.customer_taxes_used:
 if line.party.customer_tax_rule:
 tax_ids = line.party.customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if line.party.customer_tax_rule:
 tax_ids = line.party.customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 line.taxes = taxes
 
 with Transaction().set_context(



[tryton-commits] changeset in modules/stock_consignment:6.2 Ensure unique taxes w...

2022-07-17 Thread Cédric Krier
changeset 855d89552bd6 in modules/stock_consignment:6.2
details: 
https://hg.tryton.org/modules/stock_consignment?cmd=changeset&node=855d89552bd6
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from 4b2d18f8cd61aa7b2815f60a5d452522825db5ea)
diffstat:

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

diffs (51 lines):

diff -r c519577f54bc -r 855d89552bd6 stock.py
--- a/stock.py  Mon Nov 01 17:32:52 2021 +0100
+++ b/stock.py  Sun Jul 17 00:00:56 2022 +0200
@@ -188,19 +188,19 @@
 line.stock_moves = [self]
 line.origin = self
 
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in line.product.supplier_taxes_used:
 if line.party.supplier_tax_rule:
 tax_ids = line.party.supplier_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if line.party.supplier_tax_rule:
 tax_ids = line.party.supplier_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 line.taxes = taxes
 
 with Transaction().set_context(
@@ -233,19 +233,19 @@
 line.stock_moves = [self]
 line.origin = self
 
-taxes = []
+taxes = set()
 pattern = self._get_tax_rule_pattern()
 for tax in line.product.customer_taxes_used:
 if line.party.customer_tax_rule:
 tax_ids = line.party.customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if line.party.customer_tax_rule:
 tax_ids = line.party.customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 line.taxes = taxes
 
 with Transaction().set_context(



[tryton-commits] changeset in modules/web_shop:6.4 Do not copy web shop when copy...

2022-07-17 Thread Cédric Krier
changeset b5b7f1a3af6d in modules/web_shop:6.4
details: https://hg.tryton.org/modules/web_shop?cmd=changeset&node=b5b7f1a3af6d
description:
Do not copy web shop when copying sale

issue11554
review423431008
(grafted from a93de8dacc4ebcf79742bd5243779c77d212d828)
diffstat:

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

diffs (11 lines):

diff -r 9466827b4f01 -r b5b7f1a3af6d sale.py
--- a/sale.py   Mon May 02 17:32:51 2022 +0200
+++ b/sale.py   Sat Jul 09 23:15:20 2022 +0200
@@ -43,6 +43,7 @@
 default = {}
 else:
 default = default.copy()
+default.setdefault('web_shop', None)
 default.setdefault('web_id', None)
 return super().copy(sales, default=default)
 



[tryton-commits] changeset in modules/web_shop:6.2 Do not copy web shop when copy...

2022-07-17 Thread Cédric Krier
changeset 5a9912b329b0 in modules/web_shop:6.2
details: https://hg.tryton.org/modules/web_shop?cmd=changeset&node=5a9912b329b0
description:
Do not copy web shop when copying sale

issue11554
review423431008
(grafted from a93de8dacc4ebcf79742bd5243779c77d212d828)
diffstat:

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

diffs (11 lines):

diff -r 089bc7318c7b -r 5a9912b329b0 sale.py
--- a/sale.py   Mon Nov 01 17:26:13 2021 +0100
+++ b/sale.py   Sat Jul 09 23:15:20 2022 +0200
@@ -53,6 +53,7 @@
 default = {}
 else:
 default = default.copy()
+default.setdefault('web_shop', None)
 default.setdefault('web_id', None)
 return super().copy(sales, default=default)
 



[tryton-commits] changeset in modules/web_shop:6.0 Do not copy web shop when copy...

2022-07-17 Thread Cédric Krier
changeset fee5cc0ece12 in modules/web_shop:6.0
details: https://hg.tryton.org/modules/web_shop?cmd=changeset&node=fee5cc0ece12
description:
Do not copy web shop when copying sale

issue11554
review423431008
(grafted from a93de8dacc4ebcf79742bd5243779c77d212d828)
diffstat:

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

diffs (11 lines):

diff -r 88341b1ac454 -r fee5cc0ece12 sale.py
--- a/sale.py   Sun Jul 17 00:02:22 2022 +0200
+++ b/sale.py   Sat Jul 09 23:15:20 2022 +0200
@@ -53,6 +53,7 @@
 default = {}
 else:
 default = default.copy()
+default.setdefault('web_shop', None)
 default.setdefault('web_id', None)
 return super().copy(sales, default=default)
 



[tryton-commits] changeset in modules/web_shop:6.4 Ensure unique taxes when apply...

2022-07-17 Thread Cédric Krier
changeset bba0c5062c7d in modules/web_shop:6.4
details: https://hg.tryton.org/modules/web_shop?cmd=changeset&node=bba0c5062c7d
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from b31d8703761f6bbf07f4d0116cb949f8f0033b90)
diffstat:

 web.py |  10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (28 lines):

diff -r b5b7f1a3af6d -r bba0c5062c7d web.py
--- a/web.pySat Jul 09 23:15:20 2022 +0200
+++ b/web.pySun Jul 17 00:00:56 2022 +0200
@@ -196,19 +196,19 @@
 customer_tax_rule = self._customer_taxe_rule()
 taxes2products = defaultdict(list)
 for product in all_products:
-taxes = []
+taxes = set()
 for tax in product.customer_taxes_used:
 if customer_tax_rule:
 tax_ids = customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if customer_tax_rule:
 tax_ids = customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
-taxes2products[tuple(taxes)].append(product)
+taxes.update(tax_ids)
+taxes2products[tuple(sorted(taxes))].append(product)
 
 prices, taxes = {}, {}
 for tax_ids, products in taxes2products.items():



[tryton-commits] changeset in modules/web_shop:6.2 Ensure unique taxes when apply...

2022-07-17 Thread Cédric Krier
changeset d58df28746b4 in modules/web_shop:6.2
details: https://hg.tryton.org/modules/web_shop?cmd=changeset&node=d58df28746b4
description:
Ensure unique taxes when applying tax rule

Since issue10841 the taxes must be unique so the tax rule application 
must
result on unique taxes.

issue11230
review419361003
(grafted from b31d8703761f6bbf07f4d0116cb949f8f0033b90)
diffstat:

 web.py |  10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (28 lines):

diff -r 5a9912b329b0 -r d58df28746b4 web.py
--- a/web.pySat Jul 09 23:15:20 2022 +0200
+++ b/web.pySun Jul 17 00:00:56 2022 +0200
@@ -193,19 +193,19 @@
 customer_tax_rule = self._customer_taxe_rule()
 taxes2products = defaultdict(list)
 for product in all_products:
-taxes = []
+taxes = set()
 for tax in product.customer_taxes_used:
 if customer_tax_rule:
 tax_ids = customer_tax_rule.apply(tax, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
+taxes.update(tax_ids)
 continue
-taxes.append(tax.id)
+taxes.add(tax.id)
 if customer_tax_rule:
 tax_ids = customer_tax_rule.apply(None, pattern)
 if tax_ids:
-taxes.extend(tax_ids)
-taxes2products[tuple(taxes)].append(product)
+taxes.update(tax_ids)
+taxes2products[tuple(sorted(taxes))].append(product)
 
 prices, taxes = {}, {}
 for tax_ids, products in taxes2products.items():



[tryton-commits] changeset in modules/sale_promotion_coupon_payment:default Incre...

2022-07-17 Thread Cédric Krier
changeset c3b256eaeadb in modules/sale_promotion_coupon_payment:default
details: 
https://hg.tryton.org/modules/sale_promotion_coupon_payment?cmd=changeset&node=c3b256eaeadb
description:
Increase version number
diffstat:

 tryton.cfg |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (10 lines):

diff -r 6fa97093a1c8 -r c3b256eaeadb tryton.cfg
--- a/tryton.cfgSun Jul 17 19:20:12 2022 +0200
+++ b/tryton.cfgSun Jul 17 20:11:39 2022 +0200
@@ -1,5 +1,5 @@
 [tryton]
-version=6.3.0
+version=6.5.0
 depends:
 account_payment
 ir



[tryton-commits] changeset in trytond:default Add duration and truncate data in l...

2022-07-17 Thread Cédric Krier
changeset 180997544b2e in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=180997544b2e
description:
Add duration and truncate data in logging messages

issue11530
issue5228
review423311003
diffstat:

 trytond/ir/cron.py  |  12 +---
 trytond/protocols/dispatcher.py |  32 +---
 trytond/worker.py   |  21 +++--
 3 files changed, 49 insertions(+), 16 deletions(-)

diffs (168 lines):

diff -r a1491526301b -r 180997544b2e trytond/ir/cron.py
--- a/trytond/ir/cron.pySun Jul 17 00:07:23 2022 +0200
+++ b/trytond/ir/cron.pySun Jul 17 23:52:44 2022 +0200
@@ -159,8 +159,10 @@
 ])
 
 for cron in crons:
+def duration():
+return (time.monotonic() - started) * 1000
+started = time.monotonic()
 name = '' % (cron.id, db_name, cron.method)
-logger.info("%s started", name)
 for count in range(retry, -1, -1):
 if count != retry:
 time.sleep(0.02 * (retry - count))
@@ -172,15 +174,19 @@
 except Exception as e:
 if (isinstance(e, backend.DatabaseOperationalError)
 and count):
+logger.debug("Retry: %i", retry - count + 1)
 continue
 if isinstance(e, (UserError, UserWarning)):
 Error.log(cron, e)
-logger.info('%s failed', name)
+logger.info(
+"%s failed after %i ms", name, duration())
 else:
-logger.critical('%s failed', name, exc_info=True)
+logger.exception(
+"%s failed after %i ms", name, duration())
 cron.next_call = cron.compute_next_call(now)
 cron.save()
 break
+logger.info("%s in %i ms", name, duration())
 while transaction.tasks:
 task_id = transaction.tasks.pop()
 run_task(db_name, task_id)
diff -r a1491526301b -r 180997544b2e trytond/protocols/dispatcher.py
--- a/trytond/protocols/dispatcher.py   Sun Jul 17 00:07:23 2022 +0200
+++ b/trytond/protocols/dispatcher.py   Sun Jul 17 23:52:44 2022 +0200
@@ -32,6 +32,7 @@
 ir_lang = Table('ir_lang')
 ir_module = Table('ir_module')
 res_user = Table('res_user')
+_MAX_LENGTH = 80
 
 
 @app.route('//', methods=['POST'])
@@ -137,6 +138,14 @@
 return pydoc.getdoc(getattr(obj, method))
 
 
+def _safe_repr(args, kwargs, short=False):
+args = args + tuple('%s=%r' % (k, v) for k, v in kwargs.items())
+result = repr(args)
+if not short or len(result) < _MAX_LENGTH:
+return result
+return result[:_MAX_LENGTH] + ' [truncated]...)'
+
+
 @app.auth_required
 @with_pool
 def _dispatch(request, pool, *args, **kwargs):
@@ -157,13 +166,18 @@
 pool.database_name, user, session, context=context):
 abort(HTTPStatus.UNAUTHORIZED)
 
-log_message = '%s.%s(*%s, **%s) from %s@%s%s'
+log_message = '%s.%s%s from %s@%s%s in %i ms'
 username = request.authorization.username
 if isinstance(username, bytes):
 username = username.decode('utf-8')
 log_args = (
-obj, method, args, kwargs, username, request.remote_addr, request.path)
-logger.debug(log_message, *log_args)
+obj.__name__, method,
+_safe_repr(args, kwargs, not logger.isEnabledFor(logging.DEBUG)),
+username, request.remote_addr, request.path)
+
+def duration():
+return (time.monotonic() - started) * 1000
+started = time.monotonic()
 
 retry = config.getint('database', 'retry')
 for count in range(retry, -1, -1):
@@ -190,15 +204,18 @@
 except backend.DatabaseOperationalError:
 if count and not rpc.readonly:
 transaction.rollback()
+logger.debug("Retry: %i", retry - count + 1)
 continue
-logger.error(log_message, *log_args, exc_info=True)
+logger.exception(log_message, *log_args, duration())
 raise
 except (ConcurrencyException, UserError, UserWarning,
 LoginException):
-logger.debug(log_message, *log_args, exc_info=True)
+logger.info(
+log_message, *log_args, duration(),
+exc_info=logger.isEnabledFor(logging.DEBUG))
 raise
 except Exception:
-logger.error(log_message, *log_args, exc_info=True)
+logger.exception(log_message, *log_args, duration())
 raise
 # Need to commit to unlock SQLite da

[tryton-commits] changeset in modules/account:default Use context model for charts

2022-07-17 Thread Cédric Krier
changeset 13b2b39ecd83 in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset&node=13b2b39ecd83
description:
Use context model for charts

issue11496
review443121003
diffstat:

 CHANGELOG   |2 +
 __init__.py |6 +-
 account.py  |   61 ++
 account.xml |   42 +++--
 common.py   |   31 +++
 doc/design/account.rst  |   16 ---
 doc/design/tax.rst  |   17 ---
 doc/usage/view.rst  |   16 +--
 tax.py  |  138 ++-
 tax.xml |   47 +-
 view/account_context_form.xml   |   11 ++
 view/account_tree2.xml  |   12 --
 view/account_tree_chart.xml |   11 ++
 view/open_chart_start_form.xml  |9 --
 view/tax_code_context_form.xml  |   17 +++
 view/tax_code_open_chart_start_form.xml |   10 --
 view/tax_code_tree2.xml |9 --
 view/tax_code_tree_chart.xml|8 +
 18 files changed, 251 insertions(+), 212 deletions(-)

diffs (696 lines):

diff -r 6d06c13574dd -r 13b2b39ecd83 CHANGELOG
--- a/CHANGELOG Fri Jun 24 09:19:13 2022 +0200
+++ b/CHANGELOG Mon Jul 18 00:04:04 2022 +0200
@@ -1,3 +1,5 @@
+* Use context model for chart of accounts and taxes
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Prevent creating fiscal year before closed one
diff -r 6d06c13574dd -r 13b2b39ecd83 __init__.py
--- a/__init__.py   Fri Jun 24 09:19:13 2022 +0200
+++ b/__init__.py   Mon Jul 18 00:04:04 2022 +0200
@@ -24,7 +24,7 @@
 account.AccountParty,
 account.AccountDeferral,
 account.AccountTax,
-account.OpenChartAccountStart,
+account.AccountContext,
 account.GeneralLedgerAccount,
 account.GeneralLedgerAccountContext,
 account.GeneralLedgerAccountParty,
@@ -68,7 +68,7 @@
 tax.TaxCode,
 tax.TaxCodeLineTemplate,
 tax.TaxCodeLine,
-tax.OpenChartTaxCodeStart,
+tax.TaxCodeContext,
 tax.TaxTemplate,
 tax.Tax,
 tax.TaxLine,
@@ -92,7 +92,6 @@
 Pool.register(
 account.OpenType,
 fiscalyear.BalanceNonDeferral,
-account.OpenChartAccount,
 account.CreateChart,
 account.UpdateChart,
 account.OpenGeneralLedgerAccountParty,
@@ -105,7 +104,6 @@
 move.GroupLines,
 move.RescheduleLines,
 move_template.CreateMove,
-tax.OpenChartTaxCode,
 tax.OpenTaxCode,
 tax.TestTax,
 party.PartyReplace,
diff -r 6d06c13574dd -r 13b2b39ecd83 account.py
--- a/account.pyFri Jun 24 09:19:13 2022 +0200
+++ b/account.pyMon Jul 18 00:04:04 2022 +0200
@@ -26,7 +26,7 @@
 from trytond.wizard import (
 Button, StateAction, StateTransition, StateView, Wizard)
 
-from .common import ActivePeriodMixin, PeriodMixin
+from .common import ActivePeriodMixin, ContextCompanyMixin, PeriodMixin
 from .exceptions import (
 AccountValidationError, ChartWarning, SecondCurrencyError)
 
@@ -827,7 +827,9 @@
 ondelete='RESTRICT', select=True, required=True)
 
 
-class Account(AccountMixin(), ActivePeriodMixin, tree(), ModelSQL, ModelView):
+class Account(
+AccountMixin(), ContextCompanyMixin, ActivePeriodMixin, tree(),
+ModelSQL, ModelView):
 'Account'
 __name__ = 'account.account'
 _states = {
@@ -1751,44 +1753,33 @@
 select=True, required=True)
 
 
-class OpenChartAccountStart(ModelView):
-'Open Chart of Accounts'
-__name__ = 'account.open_chart.start'
-fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
-help='Leave empty for all open fiscal year.')
+class AccountContext(ModelView):
+'Account Context'
+__name__ = 'account.account.context'
+
+company = fields.Many2One('company.company', "Company", required=True)
+fiscalyear = fields.Many2One(
+'account.fiscalyear', "Fiscal Year",
+domain=[
+('company', '=', Eval('company', -1)),
+],
+help="Leave empty for all open fiscal year.")
 posted = fields.Boolean('Posted Moves', help="Only include posted moves.")
 
-@staticmethod
-def default_posted():
+@classmethod
+def default_company(cls):
+return Transaction().context.get('company')
+
+@fields.depends('company', 'fiscalyear')
+def on_change_company(self):
+if self.fiscalyear and self.fiscalyear.company != self.company:
+self.fiscalyear = None
+
+@classmethod
+def default_posted(cls):
 return False
 
 
-class OpenChartAccount(Wizard):
-'Open Chart of Accounts'
-__name__ = 'account.open_chart'
-start = StateView('account.open_chart.start',

[tryton-commits] changeset in modules/analytic_account:default Use context model ...

2022-07-17 Thread Cédric Krier
changeset efc1da9c6cff in modules/analytic_account:default
details: 
https://hg.tryton.org/modules/analytic_account?cmd=changeset&node=efc1da9c6cff
description:
Use context model for charts

issue11496
review443121003
diffstat:

 CHANGELOG  |   2 ++
 __init__.py|   3 +--
 account.py |  26 ++
 account.xml|  37 +
 view/account_context_form.xml  |   9 +
 view/account_tree2.xml |  11 ---
 view/account_tree_chart.xml|  11 +++
 view/open_chart_start_form.xml |   9 -
 8 files changed, 42 insertions(+), 66 deletions(-)

diffs (202 lines):

diff -r 49457cdc38b7 -r efc1da9c6cff CHANGELOG
--- a/CHANGELOG Mon May 02 16:52:30 2022 +0200
+++ b/CHANGELOG Mon Jul 18 00:04:04 2022 +0200
@@ -1,3 +1,5 @@
+* Use context model for chart of analytic accounts
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Add support for Python 3.10
diff -r 49457cdc38b7 -r efc1da9c6cff __init__.py
--- a/__init__.py   Mon May 02 16:52:30 2022 +0200
+++ b/__init__.py   Mon Jul 18 00:04:04 2022 +0200
@@ -13,7 +13,7 @@
 Pool.register(
 account.Account,
 account.AccountDistribution,
-account.OpenChartAccountStart,
+account.AccountContext,
 account.AnalyticAccountEntry,
 line.Line,
 line.Move,
@@ -21,6 +21,5 @@
 rule.Rule,
 module='analytic_account', type_='model')
 Pool.register(
-account.OpenChartAccount,
 line.OpenAccount,
 module='analytic_account', type_='wizard')
diff -r 49457cdc38b7 -r efc1da9c6cff account.py
--- a/account.pyMon May 02 16:52:30 2022 +0200
+++ b/account.pyMon Jul 18 00:04:04 2022 +0200
@@ -16,7 +16,6 @@
 from trytond.pyson import Eval, If, PYSONDecoder, PYSONEncoder
 from trytond.tools import lstrip_wildcard
 from trytond.transaction import Transaction
-from trytond.wizard import Button, StateAction, StateView, Wizard
 
 from .exceptions import AccountValidationError
 
@@ -297,34 +296,13 @@
 return result
 
 
-class OpenChartAccountStart(ModelView):
+class AccountContext(ModelView):
 'Open Chart of Accounts'
-__name__ = 'analytic_account.open_chart.start'
+__name__ = 'analytic_account.account.context'
 start_date = fields.Date('Start Date')
 end_date = fields.Date('End Date')
 
 
-class OpenChartAccount(Wizard):
-'Open Chart of Accounts'
-__name__ = 'analytic_account.open_chart'
-start = StateView('analytic_account.open_chart.start',
-'analytic_account.open_chart_start_view_form', [
-Button('Cancel', 'end', 'tryton-cancel'),
-Button('Open', 'open_', 'tryton-ok', default=True),
-])
-open_ = StateAction('analytic_account.act_account_tree2')
-
-def do_open_(self, action):
-action['pyson_context'] = PYSONEncoder().encode({
-'start_date': self.start.start_date,
-'end_date': self.start.end_date,
-})
-return action, {}
-
-def transition_open_(self):
-return 'end'
-
-
 class AccountDistribution(ModelView, ModelSQL):
 "Analytic Account Distribution"
 __name__ = 'analytic_account.account.distribution'
diff -r 49457cdc38b7 -r efc1da9c6cff account.xml
--- a/account.xml   Mon May 02 16:52:30 2022 +0200
+++ b/account.xml   Mon Jul 18 00:04:04 2022 +0200
@@ -77,38 +77,35 @@
 sequence="10"
 id="menu_account_list"/>
 
-
+
 analytic_account.account
 tree
 childs
 
-account_tree2
+account_tree_chart
 
-
-Analytic Accounts
+
+Chart of Analytic Accounts
 analytic_account.account
+analytic_account.account.context
 
 
-
+
 
-
-
+
+
 
-
+
 
 
-
-
-
-Open Chart of Analytic Accounts
-analytic_account.open_chart
+
 
+
 
+id="menu_account_tree_chart"/>
 
 
 User in companies
@@ -169,10 +166,10 @@
 
 
 
-
-analytic_account.open_chart.start
+
+analytic_account.account.context
 form
-open_chart_start_form
+account_context_form
 
 
 
diff -r 49457cdc38b7 -r efc1da9c6cff view/account_context_form.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/view/account_context_form.xml Mon Jul 18 00:04:04 2022 +0200
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
diff -r 49457cdc38b7 -r efc1da9c6cff view/account_tree2.xml
--- a/view/account_tree2.xmlMon May 02 16:52:30 2

[tryton-commits] changeset in modules/account_stock_landed_cost:default Show cost...

2022-07-17 Thread Cédric Krier
changeset 66c33dbf6f53 in modules/account_stock_landed_cost:default
details: 
https://hg.tryton.org/modules/account_stock_landed_cost?cmd=changeset&node=66c33dbf6f53
description:
Show cost allocation before and after posting

issue11558
review413301003
diffstat:

 CHANGELOG|2 +
 __init__.py  |6 +
 account.py   |  129 --
 account.xml  |   32 ++-
 tests/scenario_account_stock_landed_cost.rst |   16 +++-
 view/landed_cost_form.xml|3 +-
 view/landed_cost_show_form.xml   |9 +
 view/landed_cost_show_move_list.xml  |7 +
 8 files changed, 188 insertions(+), 16 deletions(-)

diffs (345 lines):

diff -r bbcd99537680 -r 66c33dbf6f53 CHANGELOG
--- a/CHANGELOG Wed May 11 11:26:36 2022 +0200
+++ b/CHANGELOG Mon Jul 18 00:16:26 2022 +0200
@@ -1,3 +1,5 @@
+* Show cost allocation before and after posting
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Add support for Python 3.10
diff -r bbcd99537680 -r 66c33dbf6f53 __init__.py
--- a/__init__.py   Wed May 11 11:26:36 2022 +0200
+++ b/__init__.py   Mon Jul 18 00:16:26 2022 +0200
@@ -16,6 +16,12 @@
 account.LandedCost_Shipment,
 account.LandedCost_ProductCategory,
 account.LandedCost_Product,
+account.LandedCostShow,
+account.LandedCostShowMove,
 account.InvoiceLine,
 stock.Move,
 module='account_stock_landed_cost', type_='model')
+Pool.register(
+account.PostLandedCost,
+account.ShowLandedCost,
+module='account_stock_landed_cost', type_='wizard')
diff -r bbcd99537680 -r 66c33dbf6f53 account.py
--- a/account.pyWed May 11 11:26:36 2022 +0200
+++ b/account.pyMon Jul 18 00:16:26 2022 +0200
@@ -8,11 +8,12 @@
 from trytond.i18n import gettext
 from trytond.model import MatchMixin, ModelSQL, ModelView, Workflow, fields
 from trytond.modules.company.model import CompanyValueMixin
-from trytond.modules.product import round_price
+from trytond.modules.product import price_digits, round_price
 from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Eval, Id
 from trytond.tools.multivalue import migrate_property
 from trytond.transaction import Transaction
+from trytond.wizard import Button, StateTransition, StateView, Wizard
 
 from .exceptions import FilterUnusedWarning, NoMoveWarning
 
@@ -169,10 +170,14 @@
 'invisible': Eval('state') != 'cancelled',
 'depends': ['state'],
 },
-'post': {
+'post_wizard': {
 'invisible': Eval('state') != 'draft',
 'depends': ['state'],
 },
+'show': {
+'invisible': Eval('state').in_(['draft', 'cancelled']),
+'depends': ['state']
+},
 })
 
 @classmethod
@@ -290,13 +295,18 @@
 product=product.rec_name))
 
 def allocate_cost_by_value(self):
-self.factors = self._get_value_factors()
+self.factors = self._get_factors('value')
 self._allocate_cost(self.factors)
 
 def unallocate_cost_by_value(self):
-factors = self.factors or self._get_value_factors()
+factors = self.factors or self._get_factors('value')
 self._allocate_cost(factors, sign=-1)
 
+def _get_factors(self, method=None):
+if method is None:
+method = self.allocation_method
+return getattr(self, '_get_%s_factors' % method)()
+
 def _get_value_factors(self):
 "Return the factor for each move based on value"
 pool = Pool()
@@ -325,17 +335,10 @@
 quantity * unit_prices[move.id] / sum_value)
 return factors
 
-def _allocate_cost(self, factors, sign=1):
-"Allocate cost on moves using factors"
+def _costs_to_allocate(self, moves, factors):
 pool = Pool()
 Move = pool.get('stock.move')
-Currency = pool.get('currency.currency')
-assert sign in {1, -1}
-
 cost = self.cost
-currency = self.company.currency
-moves = [m for m in self.stock_moves() if m.quantity]
-
 costs = []
 digit = Move.unit_price.digits[1]
 exp = Decimal(str(10.0 ** -digit))
@@ -360,6 +363,18 @@
 difference -= exp * quantity
 if difference < exp:
 break
+return costs
+
+def _allocate_cost(self, factors, sign=1):
+"Allocate cost on moves using factors"
+pool = Pool()
+Move = pool.get('stock.move')
+Currency = pool.get('currency.currency')
+assert sign in {1, -1}
+
+currency = self.company.currency
+moves = [m for m in self.stock_moves() if

[tryton-commits] changeset in modules/account_stock_landed_cost_weight:default Sh...

2022-07-17 Thread Cédric Krier
changeset c80554e87db3 in modules/account_stock_landed_cost_weight:default
details: 
https://hg.tryton.org/modules/account_stock_landed_cost_weight?cmd=changeset&node=c80554e87db3
description:
Show cost allocation before and after posting

issue11558
review413301003
diffstat:

 account.py  |  4 ++--
 tests/scenario_account_stock_landed_cost_weight.rst |  9 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 8ccdf96c5e98 -r c80554e87db3 account.py
--- a/account.pyMon May 02 17:56:52 2022 +0200
+++ b/account.pyMon Jul 18 00:16:26 2022 +0200
@@ -14,11 +14,11 @@
 cls.allocation_method.selection.append(('weight', 'By Weight'))
 
 def allocate_cost_by_weight(self):
-self.factors = self._get_weight_factors()
+self.factors = self._get_factors('weight')
 self._allocate_cost(self.factors)
 
 def unallocate_cost_by_weight(self):
-factors = self.factors or self._get_weight_factors()
+factors = self.factors or self._get_factors('weight')
 self._allocate_cost(factors, sign=-1)
 
 def _get_weight_factors(self):
diff -r 8ccdf96c5e98 -r c80554e87db3 
tests/scenario_account_stock_landed_cost_weight.rst
--- a/tests/scenario_account_stock_landed_cost_weight.rst   Mon May 02 
17:56:52 2022 +0200
+++ b/tests/scenario_account_stock_landed_cost_weight.rst   Mon Jul 18 
00:16:26 2022 +0200
@@ -167,11 +167,16 @@
 >>> landed_cost.save()
 >>> landed_cost.state
 'draft'
->>> landed_cost.click('post')
+>>> post_landed_cost = Wizard('account.landed_cost.post', [landed_cost])
+>>> post_landed_cost.form.cost
+Decimal('30.')
+>>> sorted([m.cost for m in post_landed_cost.form.moves])
+[Decimal('1.'), Decimal('2.')]
+>>> post_landed_cost.execute('post')
 >>> landed_cost.state
 'posted'
 
-Check move unit price is 101::
+Check move unit price is 153::
 
 >>> sorted([m.unit_price for m in shipment.incoming_moves])
 [Decimal('51.'), Decimal('102.')]



[tryton-commits] changeset in modules/account_stock_shipment_cost:default Show co...

2022-07-17 Thread Cédric Krier
changeset b33da97e4687 in modules/account_stock_shipment_cost:default
details: 
https://hg.tryton.org/modules/account_stock_shipment_cost?cmd=changeset&node=b33da97e4687
description:
Show cost allocation before and after posting

issue11558
review413301003
diffstat:

 CHANGELOG  |2 +
 __init__.py|6 +-
 account.py |  111 +++-
 account.xml|   32 ++-
 tests/scenario_account_stock_shipment_cost.rst |   25 -
 view/shipment_cost_form.xml|3 +-
 view/shipment_cost_show_form.xml   |9 ++
 view/shipment_cost_show_shipment_list.xml  |7 +
 8 files changed, 183 insertions(+), 12 deletions(-)

diffs (332 lines):

diff -r ff1179530c06 -r b33da97e4687 CHANGELOG
--- a/CHANGELOG Wed Jun 15 22:05:41 2022 +0200
+++ b/CHANGELOG Mon Jul 18 00:16:26 2022 +0200
@@ -1,3 +1,5 @@
+* Show cost allocation before and after posting
+
 Version 6.4.0 - 2022-05-02
 * Bug fixes (see mercurial logs for details)
 * Add allocation method
diff -r ff1179530c06 -r b33da97e4687 __init__.py
--- a/__init__.py   Wed Jun 15 22:05:41 2022 +0200
+++ b/__init__.py   Mon Jul 18 00:16:26 2022 +0200
@@ -17,11 +17,13 @@
 account.ShipmentCost,
 account.ShipmentCost_Shipment,
 account.ShipmentCost_ShipmentReturn,
+account.ShipmentCostShow,
+account.ShipmentCostShowShipment,
 account.InvoiceLine,
 stock.ShipmentOut,
 stock.ShipmentOutReturn,
 module='account_stock_shipment_cost', type_='model')
 Pool.register(
+account.PostShipmentCost,
+account.ShowShipmentCost,
 module='account_stock_shipment_cost', type_='wizard')
-Pool.register(
-module='account_stock_shipment_cost', type_='report')
diff -r ff1179530c06 -r b33da97e4687 account.py
--- a/account.pyWed Jun 15 22:05:41 2022 +0200
+++ b/account.pyMon Jul 18 00:16:26 2022 +0200
@@ -6,10 +6,11 @@
 from trytond.i18n import gettext
 from trytond.model import ModelSQL, ModelView, Workflow, fields
 from trytond.modules.company.model import CompanyValueMixin
-from trytond.modules.product import round_price
+from trytond.modules.product import price_digits, round_price
 from trytond.pool import Pool, PoolMeta
 from trytond.pyson import Eval, Id
 from trytond.transaction import Transaction
+from trytond.wizard import Button, StateTransition, StateView, Wizard
 
 from .exceptions import NoShipmentWarning, SamePartiesWarning
 
@@ -138,10 +139,14 @@
 'invisible': Eval('state') != 'cancelled',
 'depends': ['state'],
 },
-'post': {
+'post_wizard': {
 'invisible': Eval('state') != 'draft',
 'depends': ['state'],
 },
+'show': {
+'invisible': Eval('state').in_(['draft', 'cancelled']),
+'depends': ['state']
+},
 })
 
 @classmethod
@@ -199,13 +204,18 @@
 return {l.invoice.party for l in self.invoice_lines}
 
 def allocate_cost_by_shipment(self):
-self.factors = self._get_shipment_factors()
+self.factors = self._get_factors('shipment')
 self._allocate_cost(self.factors)
 
 def unallocate_cost_by_shipment(self):
-factors = self.factors or self._get_shipment_factors()
+factors = self.factors or self._get_factors('shipment')
 self._allocate_cost(factors, sign=-1)
 
+def _get_factors(self, method=None):
+if method is None:
+method = self.allocation_method
+return getattr(self, '_get_%s_factors' % method)()
+
 def _get_shipment_factors(self):
 shipments = self.all_shipments
 length = Decimal(len(shipments))
@@ -239,7 +249,18 @@
 klass.set_shipment_cost(shipments)
 
 @classmethod
-@ModelView.button
+@ModelView.button_action(
+'account_stock_shipment_cost.wizard_shipment_cost_post')
+def post_wizard(cls, shipment_costs):
+pass
+
+@classmethod
+@ModelView.button_action(
+'account_stock_shipment_cost.wizard_shipment_cost_show')
+def show(cls, shipment_costs):
+pass
+
+@classmethod
 @Workflow.transition('posted')
 def post(cls, shipment_costs):
 pool = Pool()
@@ -322,6 +343,86 @@
 required=True, ondelete='CASCADE')
 
 
+class ShowShipmentCostMixin(Wizard):
+start_state = 'show'
+show = StateView('account.shipment_cost.show',
+'account_stock_shipment_cost.shipment_cost_show_view_form', [])
+
+@property
+def factors(self):
+return self.record._get_factors()
+
+def default_show(self, fields):
+shipments = []
+cost = self.record.cost
+default = {
+

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

2022-07-17 Thread Cédric Krier
changeset 43a97a30bdf0 in modules/account_stock_shipment_cost_weight:default
details: 
https://hg.tryton.org/modules/account_stock_shipment_cost_weight?cmd=changeset&node=43a97a30bdf0
description:
Show cost allocation before and after posting

issue11558
review413301003
diffstat:

 account.py|  4 ++--
 tests/scenario_account_stock_shipment_cost_weight.rst |  7 ++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 72fb25e40b43 -r 43a97a30bdf0 account.py
--- a/account.pyWed Jun 15 22:05:41 2022 +0200
+++ b/account.pyMon Jul 18 00:16:26 2022 +0200
@@ -14,11 +14,11 @@
 cls.allocation_method.selection.append(('weight', "By Weight"))
 
 def allocate_cost_by_weight(self):
-self.factors = self._get_weight_factors()
+self.factors = self._get_factors('weight')
 self._allocate_cost(self.factors)
 
 def unallocate_cost_by_weight(self):
-factors = self.factors or self._get_weight_factors()
+factors = self.factors or self._get_factors('weight')
 self._allocate_cost(factors, sign=-1)
 
 def _get_weight_factors(self):
diff -r 72fb25e40b43 -r 43a97a30bdf0 
tests/scenario_account_stock_shipment_cost_weight.rst
--- a/tests/scenario_account_stock_shipment_cost_weight.rst Wed Jun 15 
22:05:41 2022 +0200
+++ b/tests/scenario_account_stock_shipment_cost_weight.rst Mon Jul 18 
00:16:26 2022 +0200
@@ -149,7 +149,12 @@
 >>> shipment_cost.save()
 >>> shipment_cost.state
 'draft'
->>> shipment_cost.click('post')
+>>> post_shipment_cost = Wizard('account.shipment_cost.post', 
[shipment_cost])
+>>> post_shipment_cost.form.cost
+Decimal('20.')
+>>> sorted([s.cost for s in post_shipment_cost.form.shipments])
+[Decimal('5.'), Decimal('15.')]
+>>> post_shipment_cost.execute('post')
 >>> shipment_cost.state
 'posted'
 >>> bool(shipment_cost.posted_date)



[tryton-commits] changeset in trytond:default Add implicit join clause to subquer...

2022-07-17 Thread Cédric Krier
changeset b63c91efe03a in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=b63c91efe03a
description:
Add implicit join clause to subquery of where clause on Many2One

This modify the complexity of the SubPlan from O(n^2) to O(n log(n)) 
thanks to
the index on the primary key.

issue11486
review415121003
diffstat:

 trytond/model/fields/many2one.py |  2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diffs (12 lines):

diff -r 180997544b2e -r b63c91efe03a trytond/model/fields/many2one.py
--- a/trytond/model/fields/many2one.py  Sun Jul 17 23:52:44 2022 +0200
+++ b/trytond/model/fields/many2one.py  Mon Jul 18 00:18:41 2022 +0200
@@ -241,6 +241,8 @@
 # Used for Many2Many where clause
 if operator.endswith('where'):
 query = Target.search(value, order=[], query=True)
+target_id, = query.columns
+query.where &= target_id == column
 expression = column.in_(query)
 if operator.startswith('not'):
 return ~expression



[tryton-commits] changeset in trytond:default Do not copy ids in reduce_ids

2022-07-17 Thread Cédric Krier
changeset acaa8d722fa1 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=acaa8d722fa1
description:
Do not copy ids in reduce_ids

issue11576
review413331003
diffstat:

 trytond/tools/misc.py |  12 
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (24 lines):

diff -r b63c91efe03a -r acaa8d722fa1 trytond/tools/misc.py
--- a/trytond/tools/misc.py Mon Jul 18 00:18:41 2022 +0200
+++ b/trytond/tools/misc.py Mon Jul 18 00:23:38 2022 +0200
@@ -107,12 +107,16 @@
 '''
 Return a small SQL expression for the list of ids and the sql column
 '''
-ids = list(ids)
+if __debug__:
+def strict_int(value):
+assert not isinstance(value, float) or value.is_integer(), \
+"ids must be integer"
+return int(value)
+else:
+strict_int = int
+ids = list(map(strict_int, ids))
 if not ids:
 return Literal(False)
-assert all(x.is_integer() for x in ids if isinstance(x, float)), \
-'ids must be integer'
-ids = list(map(int, ids))
 ids.sort()
 prev = ids.pop(0)
 continue_list = [prev, prev]



[tryton-commits] changeset in trytond:default Support not sized iterable in group...

2022-07-17 Thread Cédric Krier
changeset c68efc32f275 in trytond:default
details: https://hg.tryton.org/trytond?cmd=changeset&node=c68efc32f275
description:
Support not sized iterable in grouped_slice

issue11575
review431301003
diffstat:

 trytond/tests/test_tools.py |  25 +
 trytond/tools/misc.py   |   3 +++
 2 files changed, 24 insertions(+), 4 deletions(-)

diffs (62 lines):

diff -r acaa8d722fa1 -r c68efc32f275 trytond/tests/test_tools.py
--- a/trytond/tests/test_tools.py   Mon Jul 18 00:23:38 2022 +0200
+++ b/trytond/tests/test_tools.py   Mon Jul 18 00:25:45 2022 +0200
@@ -11,10 +11,10 @@
 import sql.operators
 
 from trytond.tools import (
-decimal_, escape_wildcard, file_open, firstline, is_full_text,
-is_instance_method, lstrip_wildcard, reduce_domain, reduce_ids,
-remove_forbidden_chars, rstrip_wildcard, slugify, sortable_values,
-strip_wildcard, unescape_wildcard)
+decimal_, escape_wildcard, file_open, firstline, grouped_slice,
+is_full_text, is_instance_method, lstrip_wildcard, reduce_domain,
+reduce_ids, remove_forbidden_chars, rstrip_wildcard, slugify,
+sortable_values, strip_wildcard, unescape_wildcard)
 from trytond.tools.domain_inversion import (
 concat, domain_inversion, eval_domain, extract_reference_models,
 localize_domain, merge, parse, prepare_reference_domain, simplify,
@@ -100,6 +100,23 @@
 self.assertEqual(reduce_domain(i), j,
 '%s -> %s != %s' % (i, reduce_domain(i), j))
 
+def test_grouped_slice(self):
+"Test grouped slice"
+for (values, count, result) in [
+(list(range(10)), 5, [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]),
+(list(range(5)), 5, [[0, 1, 2, 3, 4]]),
+(list(range(5)), 2, [[0, 1], [2, 3], [4]]),
+]:
+with self.subTest(values=values, count=count):
+self.assertEqual(
+list(map(list, grouped_slice(values, count))), result)
+
+def test_grouped_slice_generator(self):
+"Test grouped slice"
+self.assertEqual(
+list(map(list, grouped_slice((x for x in range(10)), 5))),
+[[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]])
+
 def test_is_instance_method(self):
 'Test is_instance_method'
 
diff -r acaa8d722fa1 -r c68efc32f275 trytond/tools/misc.py
--- a/trytond/tools/misc.py Mon Jul 18 00:23:38 2022 +0200
+++ b/trytond/tools/misc.py Mon Jul 18 00:25:45 2022 +0200
@@ -13,6 +13,7 @@
 import unicodedata
 import warnings
 from array import array
+from collections.abc import Sized
 from functools import wraps
 from itertools import islice
 
@@ -182,6 +183,8 @@
 if count is None:
 count = Transaction().database.IN_MAX
 count = max(1, count)
+if not isinstance(records, Sized):
+records = list(records)
 for i in range(0, len(records), count):
 yield islice(records, i, i + count)