diff --git a/cookiecutter-module/{{ cookiecutter.module_name }}/tox.ini b/cookiecutter-module/{{ cookiecutter.module_name }}/tox.ini index 9101514096..c63eebb4f3 100644 --- a/cookiecutter-module/{{ cookiecutter.module_name }}/tox.ini +++ b/cookiecutter-module/{{ cookiecutter.module_name }}/tox.ini @@ -16,7 +16,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account/company.py b/modules/account/company.py index 88ac83dfe0..0d1fff085c 100644 --- a/modules/account/company.py +++ b/modules/account/company.py @@ -117,10 +117,13 @@ class Company(metaclass=PoolMeta): # Need to cast numeric for sqlite cast_ = MoveLine.debit.sql_cast amount = cast_(Sum(Coalesce(line.debit, 0) - Coalesce(line.credit, 0))) - if operator in {'in', 'not in'}: - value = [cast_(Literal(Decimal(v or 0))) for v in value] - else: - value = cast_(Literal(Decimal(value or 0))) + + if backend.name == 'sqlite': + if operator in {'in', 'not in'}: + value = [cast_(Literal(Decimal(v or 0))) for v in value] + else: + value = cast_(Literal(Decimal(value or 0))) + query = (line .join(account, condition=account.id == line.account) .join(account_type, condition=account.type == account_type.id) diff --git a/modules/account/tox.ini b/modules/account/tox.ini index 841903e689..be9958c85b 100644 --- a/modules/account/tox.ini +++ b/modules/account/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_asset/tox.ini b/modules/account_asset/tox.ini index e5d67618a2..abca91f281 100644 --- a/modules/account_asset/tox.ini +++ b/modules/account_asset/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_be/tox.ini b/modules/account_be/tox.ini index d8b5e663bf..15bdf89c8c 100644 --- a/modules/account_be/tox.ini +++ b/modules/account_be/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_budget/tox.ini b/modules/account_budget/tox.ini index 79c3126472..7e8f8e04d9 100644 --- a/modules/account_budget/tox.ini +++ b/modules/account_budget/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_cash_rounding/tox.ini b/modules/account_cash_rounding/tox.ini index 183506d28a..6421de0a50 100644 --- a/modules/account_cash_rounding/tox.ini +++ b/modules/account_cash_rounding/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_consolidation/tox.ini b/modules/account_consolidation/tox.ini index 2f4bf0833d..f8016db356 100644 --- a/modules/account_consolidation/tox.ini +++ b/modules/account_consolidation/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_credit_limit/tox.ini b/modules/account_credit_limit/tox.ini index ae782533ac..eab353b850 100644 --- a/modules/account_credit_limit/tox.ini +++ b/modules/account_credit_limit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_de_skr03/tox.ini b/modules/account_de_skr03/tox.ini index 8125c67b17..b3ac187658 100644 --- a/modules/account_de_skr03/tox.ini +++ b/modules/account_de_skr03/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_deposit/tox.ini b/modules/account_deposit/tox.ini index cdfd1815b3..cc304f85ec 100644 --- a/modules/account_deposit/tox.ini +++ b/modules/account_deposit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_dunning/tox.ini b/modules/account_dunning/tox.ini index a6520f6670..34af8fbb53 100644 --- a/modules/account_dunning/tox.ini +++ b/modules/account_dunning/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_dunning_email/tox.ini b/modules/account_dunning_email/tox.ini index 9ef216fa61..91dd015afa 100644 --- a/modules/account_dunning_email/tox.ini +++ b/modules/account_dunning_email/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_dunning_fee/tox.ini b/modules/account_dunning_fee/tox.ini index c66258eae1..d41f415ce0 100644 --- a/modules/account_dunning_fee/tox.ini +++ b/modules/account_dunning_fee/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_dunning_letter/tox.ini b/modules/account_dunning_letter/tox.ini index ade8885f90..7975f38dab 100644 --- a/modules/account_dunning_letter/tox.ini +++ b/modules/account_dunning_letter/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_es/reporting_tax.py b/modules/account_es/reporting_tax.py index c75bb526aa..144adc81ae 100644 --- a/modules/account_es/reporting_tax.py +++ b/modules/account_es/reporting_tax.py @@ -196,7 +196,9 @@ class AEATPartyReport(AEATReport): from_ = convert_from(None, tables) cursor.execute(*from_.select( - expression, where=where, group_by=(expression,)) + expression.as_('aeat'), + where=where, + group_by=[expression.as_('aeat')]) .select(Count())) row = cursor.fetchone() if row: @@ -880,7 +882,7 @@ class ESVATBook(ModelSQL, ModelView): invoice.party, invoice.invoice_date, invoice.party_tax_identifier, - Coalesce(tax.es_reported_with, tax.id), + Coalesce(tax.es_reported_with, tax.id).as_('tax'), ])) return query diff --git a/modules/account_es/tox.ini b/modules/account_es/tox.ini index 357593bf8b..18b05b76bc 100644 --- a/modules/account_es/tox.ini +++ b/modules/account_es/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_es_sii/tox.ini b/modules/account_es_sii/tox.ini index c3ba811696..a431c7c28d 100644 --- a/modules/account_es_sii/tox.ini +++ b/modules/account_es_sii/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_eu/tox.ini b/modules/account_eu/tox.ini index 92205ff2ca..302c445d6c 100644 --- a/modules/account_eu/tox.ini +++ b/modules/account_eu/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_export/tox.ini b/modules/account_export/tox.ini index 8720950dd6..59785f6fa2 100644 --- a/modules/account_export/tox.ini +++ b/modules/account_export/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_export_winbooks/tox.ini b/modules/account_export_winbooks/tox.ini index 433af2c7eb..d7a5b71047 100644 --- a/modules/account_export_winbooks/tox.ini +++ b/modules/account_export_winbooks/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_fr/tox.ini b/modules/account_fr/tox.ini index d28adeb8d4..164afd4a8b 100644 --- a/modules/account_fr/tox.ini +++ b/modules/account_fr/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_fr_chorus/tox.ini b/modules/account_fr_chorus/tox.ini index 88c45279c7..d2cc824cf8 100644 --- a/modules/account_fr_chorus/tox.ini +++ b/modules/account_fr_chorus/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice/tox.ini b/modules/account_invoice/tox.ini index 261a2a4bb6..d8da3889cf 100644 --- a/modules/account_invoice/tox.ini +++ b/modules/account_invoice/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_correction/tox.ini b/modules/account_invoice_correction/tox.ini index fe0c49c461..85704bfb53 100644 --- a/modules/account_invoice_correction/tox.ini +++ b/modules/account_invoice_correction/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_defer/tox.ini b/modules/account_invoice_defer/tox.ini index 87db8f50a8..b3276838f1 100644 --- a/modules/account_invoice_defer/tox.ini +++ b/modules/account_invoice_defer/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_history/tox.ini b/modules/account_invoice_history/tox.ini index 5a51b7abec..fdffc7bb6b 100644 --- a/modules/account_invoice_history/tox.ini +++ b/modules/account_invoice_history/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_line_standalone/tox.ini b/modules/account_invoice_line_standalone/tox.ini index f7a5ea7c44..7fa9078e95 100644 --- a/modules/account_invoice_line_standalone/tox.ini +++ b/modules/account_invoice_line_standalone/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_secondary_unit/tox.ini b/modules/account_invoice_secondary_unit/tox.ini index afdd9fb8f6..ab7d31f535 100644 --- a/modules/account_invoice_secondary_unit/tox.ini +++ b/modules/account_invoice_secondary_unit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_stock/tox.ini b/modules/account_invoice_stock/tox.ini index d213915964..791e6e99ce 100644 --- a/modules/account_invoice_stock/tox.ini +++ b/modules/account_invoice_stock/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_invoice_watermark/tox.ini b/modules/account_invoice_watermark/tox.ini index af378a640f..01c9c06341 100644 --- a/modules/account_invoice_watermark/tox.ini +++ b/modules/account_invoice_watermark/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_move_line_grouping/tox.ini b/modules/account_move_line_grouping/tox.ini index 842b03e1c8..d3802e0b59 100644 --- a/modules/account_move_line_grouping/tox.ini +++ b/modules/account_move_line_grouping/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_payment/tox.ini b/modules/account_payment/tox.ini index 7a8f8590b5..c091e2fdf5 100644 --- a/modules/account_payment/tox.ini +++ b/modules/account_payment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_payment_braintree/tox.ini b/modules/account_payment_braintree/tox.ini index 61af27ad90..05e900291d 100644 --- a/modules/account_payment_braintree/tox.ini +++ b/modules/account_payment_braintree/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_payment_clearing/tox.ini b/modules/account_payment_clearing/tox.ini index d98ac5808b..291087eef2 100644 --- a/modules/account_payment_clearing/tox.ini +++ b/modules/account_payment_clearing/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_payment_sepa/tox.ini b/modules/account_payment_sepa/tox.ini index c304dd9660..cfcf4bdfb6 100644 --- a/modules/account_payment_sepa/tox.ini +++ b/modules/account_payment_sepa/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_payment_sepa_cfonb/tox.ini b/modules/account_payment_sepa_cfonb/tox.ini index 385178ae6b..78839b0bc2 100644 --- a/modules/account_payment_sepa_cfonb/tox.ini +++ b/modules/account_payment_sepa_cfonb/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_payment_stripe/tox.ini b/modules/account_payment_stripe/tox.ini index 3403307109..28cb9dd582 100644 --- a/modules/account_payment_stripe/tox.ini +++ b/modules/account_payment_stripe/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_product/tox.ini b/modules/account_product/tox.ini index ef9253adf9..827af488d8 100644 --- a/modules/account_product/tox.ini +++ b/modules/account_product/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_receivable_rule/tox.ini b/modules/account_receivable_rule/tox.ini index a01a0b50e0..e065dc0e6b 100644 --- a/modules/account_receivable_rule/tox.ini +++ b/modules/account_receivable_rule/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_rule/tox.ini b/modules/account_rule/tox.ini index 9344398102..383847f281 100644 --- a/modules/account_rule/tox.ini +++ b/modules/account_rule/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement/tox.ini b/modules/account_statement/tox.ini index e5f266a65d..b3d87346e7 100644 --- a/modules/account_statement/tox.ini +++ b/modules/account_statement/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement_aeb43/tox.ini b/modules/account_statement_aeb43/tox.ini index 2be65e3637..ba30a238ef 100644 --- a/modules/account_statement_aeb43/tox.ini +++ b/modules/account_statement_aeb43/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement_coda/tox.ini b/modules/account_statement_coda/tox.ini index 647e754d6a..17572ec62f 100644 --- a/modules/account_statement_coda/tox.ini +++ b/modules/account_statement_coda/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement_mt940/tox.ini b/modules/account_statement_mt940/tox.ini index fd99b9422f..3708e16d57 100644 --- a/modules/account_statement_mt940/tox.ini +++ b/modules/account_statement_mt940/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement_ofx/tox.ini b/modules/account_statement_ofx/tox.ini index 332931662d..984e781ccc 100644 --- a/modules/account_statement_ofx/tox.ini +++ b/modules/account_statement_ofx/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement_rule/tox.ini b/modules/account_statement_rule/tox.ini index 6ecb94e64c..1be6f5d809 100644 --- a/modules/account_statement_rule/tox.ini +++ b/modules/account_statement_rule/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_statement_sepa/tox.ini b/modules/account_statement_sepa/tox.ini index d7def42fd9..6428a3ab60 100644 --- a/modules/account_statement_sepa/tox.ini +++ b/modules/account_statement_sepa/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_anglo_saxon/tox.ini b/modules/account_stock_anglo_saxon/tox.ini index e1d38d0431..08633e4c62 100644 --- a/modules/account_stock_anglo_saxon/tox.ini +++ b/modules/account_stock_anglo_saxon/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_continental/tox.ini b/modules/account_stock_continental/tox.ini index 1f72160e9e..a51f98ebce 100644 --- a/modules/account_stock_continental/tox.ini +++ b/modules/account_stock_continental/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_eu/tox.ini b/modules/account_stock_eu/tox.ini index 28f398ddb3..a16b947de3 100644 --- a/modules/account_stock_eu/tox.ini +++ b/modules/account_stock_eu/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_landed_cost/tox.ini b/modules/account_stock_landed_cost/tox.ini index b7d3ee10d0..f78d6e6649 100644 --- a/modules/account_stock_landed_cost/tox.ini +++ b/modules/account_stock_landed_cost/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_landed_cost_weight/tox.ini b/modules/account_stock_landed_cost_weight/tox.ini index b75bf21211..3622dd1300 100644 --- a/modules/account_stock_landed_cost_weight/tox.ini +++ b/modules/account_stock_landed_cost_weight/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_shipment_cost/tox.ini b/modules/account_stock_shipment_cost/tox.ini index e62916b530..48796c16c9 100644 --- a/modules/account_stock_shipment_cost/tox.ini +++ b/modules/account_stock_shipment_cost/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_stock_shipment_cost_weight/tox.ini b/modules/account_stock_shipment_cost_weight/tox.ini index ebb27cda45..5b0f52d315 100644 --- a/modules/account_stock_shipment_cost_weight/tox.ini +++ b/modules/account_stock_shipment_cost_weight/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_syscohada/tox.ini b/modules/account_syscohada/tox.ini index e78b7b8620..cb5811c3d6 100644 --- a/modules/account_syscohada/tox.ini +++ b/modules/account_syscohada/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_tax_cash/tox.ini b/modules/account_tax_cash/tox.ini index 182cc806c9..b14afbc195 100644 --- a/modules/account_tax_cash/tox.ini +++ b/modules/account_tax_cash/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_tax_non_deductible/tox.ini b/modules/account_tax_non_deductible/tox.ini index 8151adffb0..3f3d92c674 100644 --- a/modules/account_tax_non_deductible/tox.ini +++ b/modules/account_tax_non_deductible/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/account_tax_rule_country/tox.ini b/modules/account_tax_rule_country/tox.ini index b05205c685..dc0ae503a5 100644 --- a/modules/account_tax_rule_country/tox.ini +++ b/modules/account_tax_rule_country/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/analytic_account/tox.ini b/modules/analytic_account/tox.ini index 3670452c76..522f0e731f 100644 --- a/modules/analytic_account/tox.ini +++ b/modules/analytic_account/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/analytic_budget/tox.ini b/modules/analytic_budget/tox.ini index b15b05fd18..6247832331 100644 --- a/modules/analytic_budget/tox.ini +++ b/modules/analytic_budget/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/analytic_invoice/tox.ini b/modules/analytic_invoice/tox.ini index 1466b769e8..b63d68e56a 100644 --- a/modules/analytic_invoice/tox.ini +++ b/modules/analytic_invoice/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/analytic_purchase/tox.ini b/modules/analytic_purchase/tox.ini index 4124ea10e5..c7f8914eba 100644 --- a/modules/analytic_purchase/tox.ini +++ b/modules/analytic_purchase/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/analytic_sale/tox.ini b/modules/analytic_sale/tox.ini index f56fb0578d..8d02caf731 100644 --- a/modules/analytic_sale/tox.ini +++ b/modules/analytic_sale/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/attendance/tox.ini b/modules/attendance/tox.ini index bb9d318cba..39cd960ceb 100644 --- a/modules/attendance/tox.ini +++ b/modules/attendance/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/authentication_saml/tox.ini b/modules/authentication_saml/tox.ini index 0acb17d45b..19bd946f6a 100644 --- a/modules/authentication_saml/tox.ini +++ b/modules/authentication_saml/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/authentication_sms/tox.ini b/modules/authentication_sms/tox.ini index 6a43fee354..551807aeb2 100644 --- a/modules/authentication_sms/tox.ini +++ b/modules/authentication_sms/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/bank/tox.ini b/modules/bank/tox.ini index df34d65318..c12a1f37ed 100644 --- a/modules/bank/tox.ini +++ b/modules/bank/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/carrier/tox.ini b/modules/carrier/tox.ini index 9610bc866c..2d24357616 100644 --- a/modules/carrier/tox.ini +++ b/modules/carrier/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/carrier_carriage/tox.ini b/modules/carrier_carriage/tox.ini index 699eccbc09..642aa57f81 100644 --- a/modules/carrier_carriage/tox.ini +++ b/modules/carrier_carriage/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/carrier_percentage/tox.ini b/modules/carrier_percentage/tox.ini index 27091bf613..cbd9b082b4 100644 --- a/modules/carrier_percentage/tox.ini +++ b/modules/carrier_percentage/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/carrier_subdivision/tox.ini b/modules/carrier_subdivision/tox.ini index b9a04068cc..201bfdaddb 100644 --- a/modules/carrier_subdivision/tox.ini +++ b/modules/carrier_subdivision/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/carrier_weight/tox.ini b/modules/carrier_weight/tox.ini index 99ce5df457..58cd76930c 100644 --- a/modules/carrier_weight/tox.ini +++ b/modules/carrier_weight/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/commission/commission_reporting.py b/modules/commission/commission_reporting.py index 50943610d3..897e11577b 100644 --- a/modules/commission/commission_reporting.py +++ b/modules/commission/commission_reporting.py @@ -177,7 +177,7 @@ class AgentTimeseries(Agent): @classmethod def _group_by(cls, tables, withs): return super()._group_by(tables, withs) + [ - cls._column_date(tables, withs)] + cls._column_date(tables, withs).as_('date')] class Context(ModelView): diff --git a/modules/commission/tox.ini b/modules/commission/tox.ini index f6249d699b..36c58e975e 100644 --- a/modules/commission/tox.ini +++ b/modules/commission/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/commission_waiting/tox.ini b/modules/commission_waiting/tox.ini index 30838d227a..0f847d9364 100644 --- a/modules/commission_waiting/tox.ini +++ b/modules/commission_waiting/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/company/tox.ini b/modules/company/tox.ini index 575da1d9c2..21b01e062a 100644 --- a/modules/company/tox.ini +++ b/modules/company/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/company_work_time/tox.ini b/modules/company_work_time/tox.ini index 39845ce320..c87690a9bb 100644 --- a/modules/company_work_time/tox.ini +++ b/modules/company_work_time/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/country/tox.ini b/modules/country/tox.ini index a0e7e9e240..5b3d817be6 100644 --- a/modules/country/tox.ini +++ b/modules/country/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/currency/tox.ini b/modules/currency/tox.ini index 78e70de0ff..b0309cb42f 100644 --- a/modules/currency/tox.ini +++ b/modules/currency/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/currency_ro/tox.ini b/modules/currency_ro/tox.ini index 9bf4ae2819..139396a96d 100644 --- a/modules/currency_ro/tox.ini +++ b/modules/currency_ro/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/currency_rs/tox.ini b/modules/currency_rs/tox.ini index 92fbdee6a9..b5bf9cb89f 100644 --- a/modules/currency_rs/tox.ini +++ b/modules/currency_rs/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/customs/tox.ini b/modules/customs/tox.ini index e42cc53abe..b1bf4c096e 100644 --- a/modules/customs/tox.ini +++ b/modules/customs/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/dashboard/tox.ini b/modules/dashboard/tox.ini index 5d5435d36b..1ff74d46c4 100644 --- a/modules/dashboard/tox.ini +++ b/modules/dashboard/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/document_incoming/tox.ini b/modules/document_incoming/tox.ini index 404240491b..f09690738f 100644 --- a/modules/document_incoming/tox.ini +++ b/modules/document_incoming/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/document_incoming_invoice/tox.ini b/modules/document_incoming_invoice/tox.ini index 78b01a8b69..0abe1710f9 100644 --- a/modules/document_incoming_invoice/tox.ini +++ b/modules/document_incoming_invoice/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/document_incoming_ocr/tox.ini b/modules/document_incoming_ocr/tox.ini index e4a36d6e3d..b5e8bcccc3 100644 --- a/modules/document_incoming_ocr/tox.ini +++ b/modules/document_incoming_ocr/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/document_incoming_ocr_typless/tox.ini b/modules/document_incoming_ocr_typless/tox.ini index d18e2cd838..a951bc8893 100644 --- a/modules/document_incoming_ocr_typless/tox.ini +++ b/modules/document_incoming_ocr_typless/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/edocument_peppol/tox.ini b/modules/edocument_peppol/tox.ini index 72d0fbbc53..f1daac460e 100644 --- a/modules/edocument_peppol/tox.ini +++ b/modules/edocument_peppol/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/edocument_peppol_peppyrus/tox.ini b/modules/edocument_peppol_peppyrus/tox.ini index 41e183b83a..2e66bc5af8 100644 --- a/modules/edocument_peppol_peppyrus/tox.ini +++ b/modules/edocument_peppol_peppyrus/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/edocument_ubl/tox.ini b/modules/edocument_ubl/tox.ini index b97bda7a20..fc5b09306a 100644 --- a/modules/edocument_ubl/tox.ini +++ b/modules/edocument_ubl/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/edocument_uncefact/tox.ini b/modules/edocument_uncefact/tox.ini index fb934ec5bd..9b75784f81 100644 --- a/modules/edocument_uncefact/tox.ini +++ b/modules/edocument_uncefact/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/edocument_unece/tox.ini b/modules/edocument_unece/tox.ini index 9a15d82071..5ade05389b 100644 --- a/modules/edocument_unece/tox.ini +++ b/modules/edocument_unece/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/google_maps/tox.ini b/modules/google_maps/tox.ini index 3eaf365c71..0ffd13c9bf 100644 --- a/modules/google_maps/tox.ini +++ b/modules/google_maps/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/inbound_email/tox.ini b/modules/inbound_email/tox.ini index bb5af96277..64fd8824ea 100644 --- a/modules/inbound_email/tox.ini +++ b/modules/inbound_email/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/incoterm/tox.ini b/modules/incoterm/tox.ini index 7f1f30d2d2..1f5f34b937 100644 --- a/modules/incoterm/tox.ini +++ b/modules/incoterm/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/ldap_authentication/tox.ini b/modules/ldap_authentication/tox.ini index 537942b489..30bbd4442b 100644 --- a/modules/ldap_authentication/tox.ini +++ b/modules/ldap_authentication/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/marketing/tox.ini b/modules/marketing/tox.ini index 38c4a091ff..0dcc77d0c0 100644 --- a/modules/marketing/tox.ini +++ b/modules/marketing/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/marketing_automation/marketing_automation_reporting.py b/modules/marketing_automation/marketing_automation_reporting.py index 0fa619d367..86aedbd988 100644 --- a/modules/marketing_automation/marketing_automation_reporting.py +++ b/modules/marketing_automation/marketing_automation_reporting.py @@ -127,7 +127,7 @@ class Scenario(Abstract): @classmethod def _group_by(cls, tables, withs): record = tables['record'] - return [record.scenario, cls._column_date(tables, withs)] + return [record.scenario, cls._column_date(tables, withs).as_('date')] @classmethod def _where(cls, tables, withs): @@ -239,7 +239,9 @@ class Activity(Abstract): @classmethod def _group_by(cls, tables, withs): record_activity = tables['record_activity'] - return [record_activity.activity, cls._column_date(tables, withs)] + return [ + record_activity.activity, + cls._column_date(tables, withs).as_('date')] @classmethod def _where(cls, tables, withs): diff --git a/modules/marketing_automation/tox.ini b/modules/marketing_automation/tox.ini index c589be9a6b..9b0b473f07 100644 --- a/modules/marketing_automation/tox.ini +++ b/modules/marketing_automation/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/marketing_campaign/tox.ini b/modules/marketing_campaign/tox.ini index 6c9465ca85..958d3ce78e 100644 --- a/modules/marketing_campaign/tox.ini +++ b/modules/marketing_campaign/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/marketing_email/tox.ini b/modules/marketing_email/tox.ini index 96604668e7..2747f0cd7d 100644 --- a/modules/marketing_email/tox.ini +++ b/modules/marketing_email/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/notification_email/tox.ini b/modules/notification_email/tox.ini index 552db48e96..a4e62e0002 100644 --- a/modules/notification_email/tox.ini +++ b/modules/notification_email/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/party/tox.ini b/modules/party/tox.ini index df310e0e0a..f7158bfec8 100644 --- a/modules/party/tox.ini +++ b/modules/party/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/party_avatar/tox.ini b/modules/party_avatar/tox.ini index 4a1c8658ba..9ed8e3b8eb 100644 --- a/modules/party_avatar/tox.ini +++ b/modules/party_avatar/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/party_relationship/tox.ini b/modules/party_relationship/tox.ini index 3142e6db54..e55f70c6df 100644 --- a/modules/party_relationship/tox.ini +++ b/modules/party_relationship/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/party_siret/tox.ini b/modules/party_siret/tox.ini index 39c5f0b810..0d136b76d1 100644 --- a/modules/party_siret/tox.ini +++ b/modules/party_siret/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product/tox.ini b/modules/product/tox.ini index 28bdede4f1..ddb6835067 100644 --- a/modules/product/tox.ini +++ b/modules/product/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_attribute/tox.ini b/modules/product_attribute/tox.ini index 3a53d2c463..b9cec4152b 100644 --- a/modules/product_attribute/tox.ini +++ b/modules/product_attribute/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_classification/tox.ini b/modules/product_classification/tox.ini index a21d7913ba..099bb250bd 100644 --- a/modules/product_classification/tox.ini +++ b/modules/product_classification/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_classification_taxonomic/tox.ini b/modules/product_classification_taxonomic/tox.ini index 7c321d23dc..2329fb333f 100644 --- a/modules/product_classification_taxonomic/tox.ini +++ b/modules/product_classification_taxonomic/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_cost_fifo/tox.ini b/modules/product_cost_fifo/tox.ini index 015716f3ee..c3dd7b5a7e 100644 --- a/modules/product_cost_fifo/tox.ini +++ b/modules/product_cost_fifo/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_cost_history/tox.ini b/modules/product_cost_history/tox.ini index e3b8987735..057f9bd1ed 100644 --- a/modules/product_cost_history/tox.ini +++ b/modules/product_cost_history/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_cost_warehouse/tox.ini b/modules/product_cost_warehouse/tox.ini index d89ecee1d5..33885731e7 100644 --- a/modules/product_cost_warehouse/tox.ini +++ b/modules/product_cost_warehouse/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_image/tox.ini b/modules/product_image/tox.ini index 47c9024fdd..06c4fe1fbb 100644 --- a/modules/product_image/tox.ini +++ b/modules/product_image/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_image_attribute/tox.ini b/modules/product_image_attribute/tox.ini index 8a402f792d..7a5878d842 100644 --- a/modules/product_image_attribute/tox.ini +++ b/modules/product_image_attribute/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_kit/tox.ini b/modules/product_kit/tox.ini index 880883a264..4510d0a8a7 100644 --- a/modules/product_kit/tox.ini +++ b/modules/product_kit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_measurements/tox.ini b/modules/product_measurements/tox.ini index 26b714bdfd..a477d60c78 100644 --- a/modules/product_measurements/tox.ini +++ b/modules/product_measurements/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_price_list/tox.ini b/modules/product_price_list/tox.ini index a473f195d3..1913be2a2b 100644 --- a/modules/product_price_list/tox.ini +++ b/modules/product_price_list/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_price_list_cache/tox.ini b/modules/product_price_list_cache/tox.ini index 034383e688..817f62d25c 100644 --- a/modules/product_price_list_cache/tox.ini +++ b/modules/product_price_list_cache/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_price_list_dates/tox.ini b/modules/product_price_list_dates/tox.ini index 971576d3f9..d1b9bca1d6 100644 --- a/modules/product_price_list_dates/tox.ini +++ b/modules/product_price_list_dates/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/product_price_list_parent/tox.ini b/modules/product_price_list_parent/tox.ini index f03559239b..fc4ab41fe0 100644 --- a/modules/product_price_list_parent/tox.ini +++ b/modules/product_price_list_parent/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/production/tox.ini b/modules/production/tox.ini index abbc046ccb..ee898f7b8d 100644 --- a/modules/production/tox.ini +++ b/modules/production/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/production_outsourcing/tox.ini b/modules/production_outsourcing/tox.ini index 24fc98581f..0fdbf6e94c 100644 --- a/modules/production_outsourcing/tox.ini +++ b/modules/production_outsourcing/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/production_routing/tox.ini b/modules/production_routing/tox.ini index ad0b52efe8..fa7de3b3ef 100644 --- a/modules/production_routing/tox.ini +++ b/modules/production_routing/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/production_split/tox.ini b/modules/production_split/tox.ini index d6ba7e4ec2..86ff73de0f 100644 --- a/modules/production_split/tox.ini +++ b/modules/production_split/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/production_work/tox.ini b/modules/production_work/tox.ini index cf2468f701..d745139d37 100644 --- a/modules/production_work/tox.ini +++ b/modules/production_work/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/production_work_timesheet/tox.ini b/modules/production_work_timesheet/tox.ini index 5f9a0c5a46..7997fd2350 100644 --- a/modules/production_work_timesheet/tox.ini +++ b/modules/production_work_timesheet/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/project/tox.ini b/modules/project/tox.ini index 872149e814..7ff7ce480a 100644 --- a/modules/project/tox.ini +++ b/modules/project/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/project_invoice/tox.ini b/modules/project_invoice/tox.ini index fc5f8def2d..93ee761ba8 100644 --- a/modules/project_invoice/tox.ini +++ b/modules/project_invoice/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/project_plan/tox.ini b/modules/project_plan/tox.ini index 8f99b0d32d..afeeb9f248 100644 --- a/modules/project_plan/tox.ini +++ b/modules/project_plan/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/project_revenue/tox.ini b/modules/project_revenue/tox.ini index 3992a9175a..f3bdc74fb6 100644 --- a/modules/project_revenue/tox.ini +++ b/modules/project_revenue/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase/purchase_reporting.py b/modules/purchase/purchase_reporting.py index ad8fab8d1d..eff5ff2c74 100644 --- a/modules/purchase/purchase_reporting.py +++ b/modules/purchase/purchase_reporting.py @@ -157,7 +157,8 @@ class AbstractTimeseries(Abstract): @classmethod def _group_by(cls, tables): - return super()._group_by(tables) + [cls._column_date(tables)] + return super()._group_by(tables) + [ + cls._column_date(tables).as_('date')] class Context(ModelView): diff --git a/modules/purchase/tox.ini b/modules/purchase/tox.ini index fdae0af6a9..056e34c6ba 100644 --- a/modules/purchase/tox.ini +++ b/modules/purchase/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_amendment/tox.ini b/modules/purchase_amendment/tox.ini index 7defba2065..290c9ee255 100644 --- a/modules/purchase_amendment/tox.ini +++ b/modules/purchase_amendment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_blanket_agreement/tox.ini b/modules/purchase_blanket_agreement/tox.ini index 951d87704e..9402725934 100644 --- a/modules/purchase_blanket_agreement/tox.ini +++ b/modules/purchase_blanket_agreement/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_history/tox.ini b/modules/purchase_history/tox.ini index 0eb9508502..0a222e53a7 100644 --- a/modules/purchase_history/tox.ini +++ b/modules/purchase_history/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_invoice_line_standalone/tox.ini b/modules/purchase_invoice_line_standalone/tox.ini index a2280af7ba..69d6ab4093 100644 --- a/modules/purchase_invoice_line_standalone/tox.ini +++ b/modules/purchase_invoice_line_standalone/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_price_list/tox.ini b/modules/purchase_price_list/tox.ini index e2247dee5c..99e5b54c98 100644 --- a/modules/purchase_price_list/tox.ini +++ b/modules/purchase_price_list/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_product_quantity/tox.ini b/modules/purchase_product_quantity/tox.ini index 5f4475b0ef..9a89d0bc17 100644 --- a/modules/purchase_product_quantity/tox.ini +++ b/modules/purchase_product_quantity/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_request/tox.ini b/modules/purchase_request/tox.ini index d69a7e80f6..7aad5425ea 100644 --- a/modules/purchase_request/tox.ini +++ b/modules/purchase_request/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_request_quotation/tox.ini b/modules/purchase_request_quotation/tox.ini index aa18b65645..b6173d6184 100644 --- a/modules/purchase_request_quotation/tox.ini +++ b/modules/purchase_request_quotation/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_requisition/tox.ini b/modules/purchase_requisition/tox.ini index 9d865960aa..5dd6e9b74a 100644 --- a/modules/purchase_requisition/tox.ini +++ b/modules/purchase_requisition/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_secondary_unit/tox.ini b/modules/purchase_secondary_unit/tox.ini index ca334cc450..108ee98910 100644 --- a/modules/purchase_secondary_unit/tox.ini +++ b/modules/purchase_secondary_unit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/purchase_shipment_cost/tox.ini b/modules/purchase_shipment_cost/tox.ini index 77d5d01ab4..8f1464d2b1 100644 --- a/modules/purchase_shipment_cost/tox.ini +++ b/modules/purchase_shipment_cost/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/quality/tox.ini b/modules/quality/tox.ini index 07098a7648..b9070f8d7a 100644 --- a/modules/quality/tox.ini +++ b/modules/quality/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale/sale_reporting.py b/modules/sale/sale_reporting.py index 52ba369255..4161d4cddb 100644 --- a/modules/sale/sale_reporting.py +++ b/modules/sale/sale_reporting.py @@ -228,7 +228,7 @@ class AbstractTimeseries(Abstract): @classmethod def _group_by(cls, tables, withs): return super()._group_by(tables, withs) + [ - cls._column_date(tables, withs)] + cls._column_date(tables, withs).as_('date')] class Context(ModelView): diff --git a/modules/sale/tox.ini b/modules/sale/tox.ini index 50ec8f3b21..e6e38e63c4 100644 --- a/modules/sale/tox.ini +++ b/modules/sale/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_advance_payment/tox.ini b/modules/sale_advance_payment/tox.ini index 13149080be..e9286677c5 100644 --- a/modules/sale_advance_payment/tox.ini +++ b/modules/sale_advance_payment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_amendment/tox.ini b/modules/sale_amendment/tox.ini index d2cc9aaf7a..77eec440b8 100644 --- a/modules/sale_amendment/tox.ini +++ b/modules/sale_amendment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_blanket_agreement/tox.ini b/modules/sale_blanket_agreement/tox.ini index 112b064b10..b8fd3b55b0 100644 --- a/modules/sale_blanket_agreement/tox.ini +++ b/modules/sale_blanket_agreement/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_complaint/tox.ini b/modules/sale_complaint/tox.ini index b8c90184d2..7f4b00da05 100644 --- a/modules/sale_complaint/tox.ini +++ b/modules/sale_complaint/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_credit_limit/tox.ini b/modules/sale_credit_limit/tox.ini index e208757e40..4092cb8315 100644 --- a/modules/sale_credit_limit/tox.ini +++ b/modules/sale_credit_limit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_discount/tox.ini b/modules/sale_discount/tox.ini index 295383df0d..7629187365 100644 --- a/modules/sale_discount/tox.ini +++ b/modules/sale_discount/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_extra/tox.ini b/modules/sale_extra/tox.ini index 4c75fd5ed7..cef1f35811 100644 --- a/modules/sale_extra/tox.ini +++ b/modules/sale_extra/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_gift_card/tox.ini b/modules/sale_gift_card/tox.ini index 72bc1bd80c..05c8e10d9c 100644 --- a/modules/sale_gift_card/tox.ini +++ b/modules/sale_gift_card/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_history/tox.ini b/modules/sale_history/tox.ini index b8614d6072..bab32346ff 100644 --- a/modules/sale_history/tox.ini +++ b/modules/sale_history/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_invoice_date/tox.ini b/modules/sale_invoice_date/tox.ini index 9b4bf63216..fd0bbe98b3 100644 --- a/modules/sale_invoice_date/tox.ini +++ b/modules/sale_invoice_date/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_invoice_grouping/tox.ini b/modules/sale_invoice_grouping/tox.ini index c7296ede2d..0cc8e3db9b 100644 --- a/modules/sale_invoice_grouping/tox.ini +++ b/modules/sale_invoice_grouping/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_opportunity/tox.ini b/modules/sale_opportunity/tox.ini index b097239a7b..918a50a457 100644 --- a/modules/sale_opportunity/tox.ini +++ b/modules/sale_opportunity/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_payment/tox.ini b/modules/sale_payment/tox.ini index db2a49dbb8..54cea3b226 100644 --- a/modules/sale_payment/tox.ini +++ b/modules/sale_payment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_point/tox.ini b/modules/sale_point/tox.ini index 58280f0d62..ade6268651 100644 --- a/modules/sale_point/tox.ini +++ b/modules/sale_point/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_price_list/tox.ini b/modules/sale_price_list/tox.ini index e60ee10ceb..2064dfa151 100644 --- a/modules/sale_price_list/tox.ini +++ b/modules/sale_price_list/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_product_customer/tox.ini b/modules/sale_product_customer/tox.ini index bfd577ce00..771743d79b 100644 --- a/modules/sale_product_customer/tox.ini +++ b/modules/sale_product_customer/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_product_quantity/tox.ini b/modules/sale_product_quantity/tox.ini index 69da005f5c..f4d557d5fc 100644 --- a/modules/sale_product_quantity/tox.ini +++ b/modules/sale_product_quantity/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_product_recommendation/tox.ini b/modules/sale_product_recommendation/tox.ini index f44a97f7ad..47f19ba0ad 100644 --- a/modules/sale_product_recommendation/tox.ini +++ b/modules/sale_product_recommendation/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_product_recommendation_association_rule/tox.ini b/modules/sale_product_recommendation_association_rule/tox.ini index 56865d562e..1ecf69a423 100644 --- a/modules/sale_product_recommendation_association_rule/tox.ini +++ b/modules/sale_product_recommendation_association_rule/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_promotion/tox.ini b/modules/sale_promotion/tox.ini index ec89164d14..b134e5c31e 100644 --- a/modules/sale_promotion/tox.ini +++ b/modules/sale_promotion/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_promotion_coupon/tox.ini b/modules/sale_promotion_coupon/tox.ini index cd8e6ba6c7..bf33253527 100644 --- a/modules/sale_promotion_coupon/tox.ini +++ b/modules/sale_promotion_coupon/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_promotion_coupon_payment/tox.ini b/modules/sale_promotion_coupon_payment/tox.ini index cdeca1c8a9..aa532db55d 100644 --- a/modules/sale_promotion_coupon_payment/tox.ini +++ b/modules/sale_promotion_coupon_payment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_rental/tox.ini b/modules/sale_rental/tox.ini index 12a4b16c0a..5aa3d97a70 100644 --- a/modules/sale_rental/tox.ini +++ b/modules/sale_rental/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_rental_progress_invoice/tox.ini b/modules/sale_rental_progress_invoice/tox.ini index b7133337c9..38ea6c58fc 100644 --- a/modules/sale_rental_progress_invoice/tox.ini +++ b/modules/sale_rental_progress_invoice/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_secondary_unit/tox.ini b/modules/sale_secondary_unit/tox.ini index 6ab1541e90..8e4d8c8748 100644 --- a/modules/sale_secondary_unit/tox.ini +++ b/modules/sale_secondary_unit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_shipment_cost/tox.ini b/modules/sale_shipment_cost/tox.ini index c6366c362f..d05ffeb601 100644 --- a/modules/sale_shipment_cost/tox.ini +++ b/modules/sale_shipment_cost/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_shipment_grouping/tox.ini b/modules/sale_shipment_grouping/tox.ini index f163afb100..3fd9ce0a1d 100644 --- a/modules/sale_shipment_grouping/tox.ini +++ b/modules/sale_shipment_grouping/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_shipment_tolerance/tox.ini b/modules/sale_shipment_tolerance/tox.ini index 83d7fd0afb..b2ed475129 100644 --- a/modules/sale_shipment_tolerance/tox.ini +++ b/modules/sale_shipment_tolerance/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_stock_quantity/tox.ini b/modules/sale_stock_quantity/tox.ini index 34031f08e6..afd7c2e6b4 100644 --- a/modules/sale_stock_quantity/tox.ini +++ b/modules/sale_stock_quantity/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_subscription/tox.ini b/modules/sale_subscription/tox.ini index 72e82b5575..ab914cedb0 100644 --- a/modules/sale_subscription/tox.ini +++ b/modules/sale_subscription/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_subscription_asset/tox.ini b/modules/sale_subscription_asset/tox.ini index a3b2c5c564..f3b12061f1 100644 --- a/modules/sale_subscription_asset/tox.ini +++ b/modules/sale_subscription_asset/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_supply/tox.ini b/modules/sale_supply/tox.ini index 59a1fa0dfb..2c4e5141aa 100644 --- a/modules/sale_supply/tox.ini +++ b/modules/sale_supply/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_supply_drop_shipment/tox.ini b/modules/sale_supply_drop_shipment/tox.ini index c205c82745..9951cbf3e6 100644 --- a/modules/sale_supply_drop_shipment/tox.ini +++ b/modules/sale_supply_drop_shipment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/sale_supply_production/tox.ini b/modules/sale_supply_production/tox.ini index e6a928efa8..3fd5553f58 100644 --- a/modules/sale_supply_production/tox.ini +++ b/modules/sale_supply_production/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock/move.py b/modules/stock/move.py index 563c191f1c..f6ac9f9d87 100644 --- a/modules/stock/move.py +++ b/modules/stock/move.py @@ -7,7 +7,7 @@ from collections import defaultdict from decimal import Decimal from itertools import groupby -from sql import Column, For, Literal, Null, Union +from sql import Column, For, Literal, Null, Table, Union from sql.aggregate import Max, Sum from sql.conditionals import Case, Coalesce from sql.functions import Round @@ -1411,7 +1411,7 @@ class Move(Workflow, ModelSQL, ModelView): company = User(transaction.user).company def get_column(name, table): - if name == 'date': + if name == 'date' and isinstance(table, Table): return cls.effective_date.sql_cast( Coalesce( table.effective_date, @@ -1659,8 +1659,7 @@ class Move(Workflow, ModelSQL, ModelView): # One that sums incoming moves towards locations, one that sums # outgoing moves and one for the period cache. UNION ALL is used # because we already know that there will be no duplicates. - move_keys_alias = [get_column(key, move).as_(key) for key in grouping] - move_keys = [get_column(key, move) for key in grouping] + move_keys = [get_column(key, move).as_(key) for key in grouping] if company: company_clause = move.company == company.id @@ -1670,22 +1669,22 @@ class Move(Workflow, ModelSQL, ModelView): company_clause = Literal(False) query = move.select(move.to_location.as_('location'), Sum(move.internal_quantity).as_('quantity'), - *move_keys_alias, + *move_keys, where=state_date_clause_in & where & move.to_location.in_(location_query) & company_clause & dest_clause_from, - group_by=[move.to_location] + move_keys) + group_by=[move.to_location.as_('location')] + move_keys) query = Union(query, move.select(move.from_location.as_('location'), (-Sum(move.internal_quantity)).as_('quantity'), - *move_keys_alias, + *move_keys, where=state_date_clause_out & where & move.from_location.in_(location_query) & company_clause & dest_clause_to, - group_by=[move.from_location] + move_keys), + group_by=[move.from_location.as_('location')] + move_keys), all_=True) if PeriodCache and period: period_keys = [Column(period_cache, key).as_(key) @@ -1707,7 +1706,7 @@ class Move(Workflow, ModelSQL, ModelView): + query_keys + [quantity.as_('quantity')]) query = query.select(*columns, - group_by=[query.location] + query_keys) + group_by=[query.location.as_('location')] + query_keys) return query @classmethod diff --git a/modules/stock/product.py b/modules/stock/product.py index 0757dc5d44..dccc6bdf5d 100644 --- a/modules/stock/product.py +++ b/modules/stock/product.py @@ -730,7 +730,11 @@ class ProductQuantitiesByWarehouse(ModelSQL, ModelView): warehouse.select(warehouse.id)))) & ((date_column < today) & (move.state == 'done') | (date_column > today)), - group_by=(date_column, product_column, move.company), + group_by=[ + date_column.as_('date'), + product_column.as_('product'), + move.company.as_('company'), + ], with_=warehouse)) for model, id_ in products: gap = ['product.template', 'product.product'].index(model) + 1 diff --git a/modules/stock/stock_reporting.py b/modules/stock/stock_reporting.py index 2d42083f80..3313bfa017 100644 --- a/modules/stock/stock_reporting.py +++ b/modules/stock/stock_reporting.py @@ -4,7 +4,7 @@ import datetime as dt from dateutil.relativedelta import relativedelta -from sql import Literal, Null, Window +from sql import Column, Literal, Null, Window from sql.aggregate import Min, Sum from sql.conditionals import Case, Coalesce, Greatest, Least, NullIf from sql.functions import Function, NthValue, Round @@ -165,38 +165,32 @@ class _InventoryMixin: date_column = Greatest(move_date, from_date) if context.get('product_type') == 'product.product': - partition = [move.product] + partition = move.product else: - partition = [product_table.template] - - # Use NthValue instead of LastValue to get NULL for the last row - next_date_column = NthValue( - date_column, 2, window=Window( - partition, - order_by=[date_column.asc], - frame='ROWS', start=0, end=1)) + partition = product_table.template state_clause = cls._state_clause(move, to_date) + quantities_columns = list(cls._quantities_columns(move, product_table)) quantities = quantities.select( Min(move.id).as_('id'), product_reference.as_('product_reference'), product_template.as_('product_template'), product.as_('product'), date_column.as_('date'), - next_date_column.as_('next_date'), + partition.as_('partition'), start_quantity.as_('start_quantity'), input_quantity.as_('input_quantity'), output_quantity.as_('output_quantity'), - *cls._quantities_columns(move, product_table), + *quantities_columns, where=(((input_clause & ~output_clause) | (output_clause & ~input_clause)) & (move_date <= to_date) & state_clause & (move.company == company)), group_by=[ - *partition, - date_column, + partition.as_('partition'), + date_column.as_('date'), *cls._quantities_group_by(move, product_table), ], ) @@ -222,14 +216,18 @@ class _InventoryMixin: period_cache_product.template.as_('product'), Sum(period_cache.internal_quantity ).as_('quantity'), - group_by=[period_cache_product.template])) + group_by=[ + period_cache_product.template.as_('product'), + ])) else: cache = ( period_cache .select( period_cache.product.as_('product'), Sum(period_cache.internal_quantity).as_('quantity'), - group_by=[period_cache.product])) + group_by=[ + period_cache.product.as_('product'), + ])) location_cache = Location.__table__() cache.where = ( (period_cache.period == period.id) @@ -247,20 +245,40 @@ class _InventoryMixin: else: query = quantities + query = query.select( + quantities.id.as_('id'), + Literal(company).as_('company'), + quantities.product_reference.as_('product_reference'), + quantities.product_template.as_('product_template'), + quantities.product.as_('product'), + quantities.date.as_('date'), + # Use NthValue instead of LastValue to get NULL for the last row + NthValue( + quantities.date, 2, window=Window( + [quantities.partition], + order_by=[quantities.date.asc], + frame='ROWS', start=0, end=1)).as_('next_date'), + quantities.input_quantity.as_('input_quantity'), + quantities.output_quantity.as_('output_quantity'), + quantity.as_('quantity'), + *[Column(quantities, col.output_name).as_(col.output_name) + for col in quantities_columns], + ) + return (query .select( - quantities.id.as_('id'), + query.id.as_('id'), Literal(company).as_('company'), - quantities.product_reference.as_('product_reference'), - quantities.product_template.as_('product_template'), - quantities.product.as_('product'), - quantities.input_quantity.as_('input_quantity'), - quantities.output_quantity.as_('output_quantity'), - quantity.as_('quantity'), - *cls._columns(quantities), + query.product_reference.as_('product_reference'), + query.product_template.as_('product_template'), + query.product.as_('product'), + query.input_quantity.as_('input_quantity'), + query.output_quantity.as_('output_quantity'), + query.quantity.as_('quantity'), + *cls._columns(query), where=( - (Coalesce(quantities.next_date, dt.date.max) >= from_date) - | (quantities.date >= from_date)))) + (Coalesce(query.next_date, dt.date.max) >= from_date) + | (query.date >= from_date)))) @classmethod def _quantities_columns(cls, move, product): @@ -414,10 +432,10 @@ class InventoryMove(_InventoryMixin, ModelSQL, ModelView): yield from super()._quantities_group_by(move, product) yield Case( (move_date < from_date, Null), - else_=move.id) + else_=move.id).as_('move') yield Case( (move_date < from_date, Null), - else_=move.origin) + else_=move.origin).as_('origin') @classmethod def _columns(cls, quantities): @@ -594,9 +612,9 @@ class InventoryTurnover(ModelSQL, ModelView): output_quantity / NullIf(average_quantity, 0), cls.turnover.digits[1]).as_('turnover'), group_by=[ - inventory.product_reference, - inventory.product_template, - inventory.product, + inventory.product_reference.as_('product_reference'), + inventory.product_template.as_('product_template'), + inventory.product.as_('product'), ])) @fields.depends('product_reference') diff --git a/modules/stock/stock_reporting_margin.py b/modules/stock/stock_reporting_margin.py index fc17f73b51..f446dc6cf4 100644 --- a/modules/stock/stock_reporting_margin.py +++ b/modules/stock/stock_reporting_margin.py @@ -254,7 +254,7 @@ class AbstractTimeseries(Abstract): @classmethod def _group_by(cls, tables, withs): return super()._group_by(tables, withs) + [ - cls._column_date(tables, withs)] + cls._column_date(tables, withs).as_('date')] class Context(ModelView): diff --git a/modules/stock/tox.ini b/modules/stock/tox.ini index 02300332ec..cd39b24d87 100644 --- a/modules/stock/tox.ini +++ b/modules/stock/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_assign_manual/tox.ini b/modules/stock_assign_manual/tox.ini index e78c80ff61..d7ce03adad 100644 --- a/modules/stock_assign_manual/tox.ini +++ b/modules/stock_assign_manual/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_consignment/tox.ini b/modules/stock_consignment/tox.ini index 33754bc5f7..33efa6a71c 100644 --- a/modules/stock_consignment/tox.ini +++ b/modules/stock_consignment/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_forecast/tox.ini b/modules/stock_forecast/tox.ini index 1c7d753116..2ba5f4206d 100644 --- a/modules/stock_forecast/tox.ini +++ b/modules/stock_forecast/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_inventory_location/tox.ini b/modules/stock_inventory_location/tox.ini index 15f206d942..95025a5a2c 100644 --- a/modules/stock_inventory_location/tox.ini +++ b/modules/stock_inventory_location/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_location_move/tox.ini b/modules/stock_location_move/tox.ini index 7bf1302d2d..14ab73858e 100644 --- a/modules/stock_location_move/tox.ini +++ b/modules/stock_location_move/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_location_sequence/tox.ini b/modules/stock_location_sequence/tox.ini index c855bd12b6..279b549dbe 100644 --- a/modules/stock_location_sequence/tox.ini +++ b/modules/stock_location_sequence/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_lot/tox.ini b/modules/stock_lot/tox.ini index a038f87314..b33d2cd0f1 100644 --- a/modules/stock_lot/tox.ini +++ b/modules/stock_lot/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_lot_sled/tox.ini b/modules/stock_lot_sled/tox.ini index 46b428112d..76a963035c 100644 --- a/modules/stock_lot_sled/tox.ini +++ b/modules/stock_lot_sled/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_lot_unit/tox.ini b/modules/stock_lot_unit/tox.ini index 0b5b7207ed..2a855eac0f 100644 --- a/modules/stock_lot_unit/tox.ini +++ b/modules/stock_lot_unit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_package/tox.ini b/modules/stock_package/tox.ini index b83ff6ea9c..b957df7a0c 100644 --- a/modules/stock_package/tox.ini +++ b/modules/stock_package/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_package_shipping/tox.ini b/modules/stock_package_shipping/tox.ini index 046746084c..07ebde149d 100644 --- a/modules/stock_package_shipping/tox.ini +++ b/modules/stock_package_shipping/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_package_shipping_dpd/tox.ini b/modules/stock_package_shipping_dpd/tox.ini index fd9e188461..7dc96a5479 100644 --- a/modules/stock_package_shipping_dpd/tox.ini +++ b/modules/stock_package_shipping_dpd/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_package_shipping_mygls/tox.ini b/modules/stock_package_shipping_mygls/tox.ini index 20b6ee7165..1fdc72f8ca 100644 --- a/modules/stock_package_shipping_mygls/tox.ini +++ b/modules/stock_package_shipping_mygls/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_package_shipping_sendcloud/tox.ini b/modules/stock_package_shipping_sendcloud/tox.ini index 9258812d11..ec2b49f927 100644 --- a/modules/stock_package_shipping_sendcloud/tox.ini +++ b/modules/stock_package_shipping_sendcloud/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_package_shipping_ups/tox.ini b/modules/stock_package_shipping_ups/tox.ini index 7db330b94d..17b0a71429 100644 --- a/modules/stock_package_shipping_ups/tox.ini +++ b/modules/stock_package_shipping_ups/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_product_location/tox.ini b/modules/stock_product_location/tox.ini index 337a2f0acc..c4c7222c27 100644 --- a/modules/stock_product_location/tox.ini +++ b/modules/stock_product_location/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_product_location_place/tox.ini b/modules/stock_product_location_place/tox.ini index 10f46c79a0..8998c81d26 100644 --- a/modules/stock_product_location_place/tox.ini +++ b/modules/stock_product_location_place/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_quantity_early_planning/tox.ini b/modules/stock_quantity_early_planning/tox.ini index e5e88b3b58..3a1ec11324 100644 --- a/modules/stock_quantity_early_planning/tox.ini +++ b/modules/stock_quantity_early_planning/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_quantity_issue/tox.ini b/modules/stock_quantity_issue/tox.ini index 530a87edb6..b6c8d01d63 100644 --- a/modules/stock_quantity_issue/tox.ini +++ b/modules/stock_quantity_issue/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_secondary_unit/tox.ini b/modules/stock_secondary_unit/tox.ini index eabde99267..38fa702828 100644 --- a/modules/stock_secondary_unit/tox.ini +++ b/modules/stock_secondary_unit/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_shipment_cost/tox.ini b/modules/stock_shipment_cost/tox.ini index c8050441d1..628fa26a0e 100644 --- a/modules/stock_shipment_cost/tox.ini +++ b/modules/stock_shipment_cost/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_shipment_cost_weight/tox.ini b/modules/stock_shipment_cost_weight/tox.ini index e8ceb2c89a..44c95a4014 100644 --- a/modules/stock_shipment_cost_weight/tox.ini +++ b/modules/stock_shipment_cost_weight/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_shipment_customs/tox.ini b/modules/stock_shipment_customs/tox.ini index 26d77721fd..7ee4fb6252 100644 --- a/modules/stock_shipment_customs/tox.ini +++ b/modules/stock_shipment_customs/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_shipment_measurements/tox.ini b/modules/stock_shipment_measurements/tox.ini index 98d8c20595..1f11998392 100644 --- a/modules/stock_shipment_measurements/tox.ini +++ b/modules/stock_shipment_measurements/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_shipping_point/tox.ini b/modules/stock_shipping_point/tox.ini index 94ffb6a482..2e31d34c99 100644 --- a/modules/stock_shipping_point/tox.ini +++ b/modules/stock_shipping_point/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_split/tox.ini b/modules/stock_split/tox.ini index c97eeac040..6d6fe31c47 100644 --- a/modules/stock_split/tox.ini +++ b/modules/stock_split/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_supply/tox.ini b/modules/stock_supply/tox.ini index d9e3554b40..745772e26f 100644 --- a/modules/stock_supply/tox.ini +++ b/modules/stock_supply/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_supply_day/tox.ini b/modules/stock_supply_day/tox.ini index 3db394eed0..a26c3ef965 100644 --- a/modules/stock_supply_day/tox.ini +++ b/modules/stock_supply_day/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_supply_forecast/tox.ini b/modules/stock_supply_forecast/tox.ini index 1b794859e8..0ee7e15a94 100644 --- a/modules/stock_supply_forecast/tox.ini +++ b/modules/stock_supply_forecast/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/stock_supply_production/tox.ini b/modules/stock_supply_production/tox.ini index 24b28594bc..47d73243ec 100644 --- a/modules/stock_supply_production/tox.ini +++ b/modules/stock_supply_production/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/timesheet/tox.ini b/modules/timesheet/tox.ini index fa63842e0f..0bf84732c4 100644 --- a/modules/timesheet/tox.ini +++ b/modules/timesheet/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/timesheet_cost/tox.ini b/modules/timesheet_cost/tox.ini index 0cb33484ba..dd95c40159 100644 --- a/modules/timesheet_cost/tox.ini +++ b/modules/timesheet_cost/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/user_role/tox.ini b/modules/user_role/tox.ini index a60f5d052f..7be1b59b01 100644 --- a/modules/user_role/tox.ini +++ b/modules/user_role/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_shop/tox.ini b/modules/web_shop/tox.ini index 1f72c14f30..eb53dd7322 100644 --- a/modules/web_shop/tox.ini +++ b/modules/web_shop/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_shop_product_data_feed/tox.ini b/modules/web_shop_product_data_feed/tox.ini index c736c0479a..ff6933e340 100644 --- a/modules/web_shop_product_data_feed/tox.ini +++ b/modules/web_shop_product_data_feed/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_shop_shopify/tox.ini b/modules/web_shop_shopify/tox.ini index 5116bc59d6..c49f6eec20 100644 --- a/modules/web_shop_shopify/tox.ini +++ b/modules/web_shop_shopify/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_shop_vue_storefront/tox.ini b/modules/web_shop_vue_storefront/tox.ini index 8781c9ce2e..f213777409 100644 --- a/modules/web_shop_vue_storefront/tox.ini +++ b/modules/web_shop_vue_storefront/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_shop_vue_storefront_stripe/tox.ini b/modules/web_shop_vue_storefront_stripe/tox.ini index 6703ba781d..8e93b79a79 100644 --- a/modules/web_shop_vue_storefront_stripe/tox.ini +++ b/modules/web_shop_vue_storefront_stripe/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_shortener/tox.ini b/modules/web_shortener/tox.ini index b80f477f0b..4e13a1214c 100644 --- a/modules/web_shortener/tox.ini +++ b/modules/web_shortener/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/modules/web_user/tox.ini b/modules/web_user/tox.ini index b3b0c2d259..900aca96de 100644 --- a/modules/web_user/tox.ini +++ b/modules/web_user/tox.ini @@ -12,7 +12,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/trytond-gis/pyproject.toml b/trytond-gis/pyproject.toml index d334118493..b0cea7996f 100644 --- a/trytond-gis/pyproject.toml +++ b/trytond-gis/pyproject.toml @@ -46,7 +46,7 @@ packages = ['trytond_gis'] [tool.hatch.metadata.hooks.tryton] dependencies = [ 'geomet', - 'psycopg2 >= 2.0.14', + 'psycopg[pool] >= 3', ] tryton_dependencies = ['trytond'] copyright = 'COPYRIGHT' diff --git a/trytond-gis/trytond_gis/postgis/database.py b/trytond-gis/trytond_gis/postgis/database.py index 8bb69537d9..651464a457 100644 --- a/trytond-gis/trytond_gis/postgis/database.py +++ b/trytond-gis/trytond_gis/postgis/database.py @@ -1,20 +1,41 @@ # This file is part of trytond_gis. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. import binascii +from functools import cache from geomet import wkb -from psycopg2.extensions import ( - Binary, new_type, register_adapter, register_type) +from psycopg.adapt import Dumper, Loader +from psycopg.postgres import adapters +from psycopg.pq import Format +from psycopg.types import TypeInfo from trytond.backend.postgresql.database import Database as PGDatabase from trytond.config import parse_uri from trytond_gis import _GeoJSON -def ewkb2geojson(value, cursor): - if value is None: - return None - return wkb.loads(binascii.a2b_hex(value)) +class GeometryBinaryLoader(Loader): + format = Format.BINARY + + def load(self, data): + return wkb.loads(binascii.a2b_hex(data)) + + +class GeometryLoader(Loader): + def load(self, data): + return wkb.loads(binascii.a2b_hex(data)) + + +class BaseGeometryBinaryDumper(Dumper): + format = Format.BINARY + + def dump(self, obj): + return wkb.dumps(obj) + + +class BaseGeometryDumper(Dumper): + def dump(self, obj): + return wkb.dumps(obj).encode() class Database(PGDatabase): @@ -33,8 +54,8 @@ class Database(PGDatabase): @classmethod def _connection_params(cls, name): params = super()._connection_params(name) - uri = parse_uri(params['dsn']) - params['dsn'] = uri._replace(scheme='postgresql').geturl() + uri = parse_uri(params['conninfo']) + params['conninfo'] = uri._replace(scheme='postgresql').geturl() return params def get_connection( @@ -48,21 +69,35 @@ class Database(PGDatabase): cursor.execute( "SELECT 1 FROM pg_extension WHERE extname='postgis'") if cursor.fetchone(): - cursor.execute('SELECT NULL::geometry, NULL::geography') - geometry_oid = cursor.description[0][1] - geography_oid = cursor.description[1][1] + geometry_info = TypeInfo.fetch(conn, 'geometry') + geometry_info.register() + + adapters.register_loader( + geometry_info.oid, GeometryBinaryLoader) + adapters.register_loader(geometry_info.oid, GeometryLoader) + + adapters.register_dumper( + _GeoJSON, _make_dumper(geometry_info.oid)) + adapters.register_dumper( + _GeoJSON, _make_binary_dumper(geometry_info.oid)) + self._GIS_OIDS = { - 'geometry': geometry_oid, - 'geography': geography_oid, + 'geometry': geometry_info.oid, } - - GEOMETRY = new_type((geometry_oid,), 'GEOMETRY', ewkb2geojson) - register_type(GEOMETRY) - GEOGRAPHY = new_type( - (geography_oid,), 'GEOGRAPHY', ewkb2geojson) - register_type(GEOGRAPHY) - return conn -register_adapter(_GeoJSON, lambda value: Binary(wkb.dumps(value))) +@cache +def _make_dumper(oid_in): + class GeometryDumper(BaseGeometryDumper): + oid = oid_in + + return GeometryDumper + + +@cache +def _make_binary_dumper(oid_in): + class GeometryBinaryDumper(BaseGeometryBinaryDumper): + oid = oid_in + + return GeometryBinaryDumper diff --git a/trytond/CHANGELOG b/trytond/CHANGELOG index 139dd48a06..62da8a43d3 100644 --- a/trytond/CHANGELOG +++ b/trytond/CHANGELOG @@ -1,3 +1,4 @@ +* Update to Psycopg 3 * Add support for Python 3.14 * Remove support for Python 3.9 * Support fmany2one based on Function fields diff --git a/trytond/doc/ref/backend.rst b/trytond/doc/ref/backend.rst index 2ffadf356c..01e42665b9 100644 --- a/trytond/doc/ref/backend.rst +++ b/trytond/doc/ref/backend.rst @@ -33,10 +33,9 @@ Database If autocommit is set, the connection is committed after each statement. If readonly is set, the connection is read only. -.. method:: Database.put_connection(connection[, close]) +.. method:: Database.put_connection(connection) Release the connection. - If close is set, the connection is discarded. .. method:: Database.close() diff --git a/trytond/doc/ref/transaction.rst b/trytond/doc/ref/transaction.rst index 6008a66141..87c2872c43 100644 --- a/trytond/doc/ref/transaction.rst +++ b/trytond/doc/ref/transaction.rst @@ -83,7 +83,7 @@ Transaction Return a monotonic time used to populate :attr:`~Transaction.started_at`. -.. method:: Transaction.start(database_name, user[, readonly[, context[, close[, autocommit, \**extras]]]]) +.. method:: Transaction.start(database_name, user[, readonly[, context[, autocommit, \**extras]]]) Start a new transaction and return a `context manager`_. The non-readonly transaction will be committed when exiting the ``with`` diff --git a/trytond/doc/topics/configuration.rst b/trytond/doc/topics/configuration.rst index 3d46e8ae67..f8d32b2314 100644 --- a/trytond/doc/topics/configuration.rst +++ b/trytond/doc/topics/configuration.rst @@ -155,15 +155,15 @@ The available databases are: PostgreSQL ********** -``psycopg2`` supports two type of connections: +``psycopg`` supports two type of connections: - TCP/IP connection: ``postgresql://user:password@localhost:5432/`` - Unix domain connection: - with password authentication: ``postgresql://username:password`` - with operating system user name: ``postgresql://`` -Please refer to `psycopg2 for the complete specification of the URI -`_. +Please refer to `psycopg for the complete specification of the URI +`_. A list of parameters supported by PostgreSQL can be found in the `documentation diff --git a/trytond/pyproject.toml b/trytond/pyproject.toml index 5dc6cfd9a7..34f07e341b 100644 --- a/trytond/pyproject.toml +++ b/trytond/pyproject.toml @@ -13,7 +13,7 @@ dependencies = [ 'polib', 'pwdlib[argon2] >= 0.2', 'python-dateutil', - 'python-sql >= 1.5', + 'python-sql >= 1.8', 'pytz; python_version < "3.9"', 'relatorio[fodt] >= 0.7.0', 'simpleeval', @@ -39,7 +39,7 @@ classifiers = [ [project.optional-dependencies] Levenshtein = ['python-Levenshtein'] -PostgreSQL = ['psycopg2 >= 2.7.0'] +PostgreSQL = ['psycopg[pool] >= 3'] barcode = ['python-barcode[images]'] completion = ['argcomplete'] coroutine = ['gevent >= 1.1'] diff --git a/trytond/tox.ini b/trytond/tox.ini index a7f79e0044..2722bd60a9 100644 --- a/trytond/tox.ini +++ b/trytond/tox.ini @@ -17,7 +17,7 @@ commands_post = deps = coverage unittest-xml-reporting - postgresql: psycopg2 >= 2.7.0 + postgresql: psycopg[pool] >= 3 passenv = * setenv = sqlite: TRYTOND_DATABASE_URI={env:SQLITE_URI:sqlite://} diff --git a/trytond/trytond/backend/database.py b/trytond/trytond/backend/database.py index e9b1e15ffe..a1d23608bf 100644 --- a/trytond/trytond/backend/database.py +++ b/trytond/trytond/backend/database.py @@ -31,7 +31,7 @@ class DatabaseInterface(object): self, autocommit=False, readonly=False, statement_timeout=None): raise NotImplementedError - def put_connection(self, connection, close=False): + def put_connection(self, connection): raise NotImplementedError def close(self): diff --git a/trytond/trytond/backend/postgresql/database.py b/trytond/trytond/backend/postgresql/database.py index 1f3ceafab6..15710d6f15 100644 --- a/trytond/trytond/backend/postgresql/database.py +++ b/trytond/trytond/backend/postgresql/database.py @@ -7,40 +7,29 @@ import time import warnings from collections import defaultdict from datetime import datetime -from decimal import Decimal from itertools import chain, repeat from threading import RLock -from psycopg2 import Binary, connect -from psycopg2.extensions import ( - ISOLATION_LEVEL_REPEATABLE_READ, UNICODE, AsIs, cursor, register_adapter, - register_type) -from psycopg2.pool import PoolError, ThreadedConnectionPool -from psycopg2.sql import SQL, Identifier -from sql.operators import NotEqual - -try: - from psycopg2.extensions import PYDATE, PYDATETIME, PYINTERVAL, PYTIME -except ImportError: - PYDATE, PYDATETIME, PYTIME, PYINTERVAL = None, None, None, None -from psycopg2 import DataError as DatabaseDataError -from psycopg2 import IntegrityError as DatabaseIntegrityError -from psycopg2 import InterfaceError -from psycopg2 import OperationalError as DatabaseOperationalError -from psycopg2.errors import QueryCanceled as DatabaseTimeoutError -from psycopg2.errors import UndefinedColumn -from psycopg2.extras import register_default_json, register_default_jsonb +import psycopg +from psycopg import Binary, ClientCursor, Cursor +from psycopg import DataError as DatabaseDataError +from psycopg import IntegrityError as DatabaseIntegrityError +from psycopg import IsolationLevel +from psycopg import OperationalError as DatabaseOperationalError +from psycopg import connect +from psycopg.errors import QueryCanceled as DatabaseTimeoutError +from psycopg.sql import SQL, Identifier +from psycopg_pool import ConnectionPool from sql import Cast, Flavor, For, Literal, Table from sql.aggregate import Count from sql.conditionals import Coalesce from sql.functions import Function -from sql.operators import BinaryOperator, Concat +from sql.operators import BinaryOperator, Concat, NotEqual from trytond import __series__, config from trytond.backend.database import DatabaseInterface, SQLType from trytond.sql.operators import RangeOperator from trytond.tools import grouped_slice, reduce_ids -from trytond.tools.gevent import is_gevent_monkey_patched from .table import index_method @@ -67,11 +56,12 @@ def replace_special_values(s, **mapping): return s -class LoggingCursor(cursor): - def execute(self, sql, args=None): +class LoggingCursor(Cursor): + + def execute(self, query, params=None, *, prepare=None, binary=None): if logger.isEnabledFor(logging.DEBUG): - logger.debug('query: %s', self.mogrify(sql, args).decode()) - cursor.execute(self, sql, args) + logger.debug(ClientCursor(self.connection).mogrify(query, params)) + return super().execute(query, params, prepare=prepare, binary=binary) class ForSkipLocked(For): @@ -223,8 +213,7 @@ class Database(DatabaseInterface): timeout = config.getint('database', 'timeout') for database in list(databases.values()): if ((now - database._last_use).total_seconds() > timeout - and database.name != name - and not database._connpool._used): + and database.name != name): database.close() if name in databases: inst = databases[name] @@ -232,10 +221,16 @@ class Database(DatabaseInterface): inst = DatabaseInterface.__new__(cls, name=name) minconn = config.getint('database', 'minconn', default=1) maxconn = config.getint('database', 'maxconn', default=64) + kwargs = cls._connection_params(name) + kwargs['cursor_factory'] = LoggingCursor + conninfo = kwargs.pop('conninfo') try: - inst._connpool = ThreadedConnectionPool( - minconn, maxconn, **cls._connection_params(name), - cursor_factory=LoggingCursor) + inst._connpool = ConnectionPool( + conninfo, + kwargs=kwargs, + open=True, + check=ConnectionPool.check_connection, + min_size=minconn, max_size=maxconn) except Exception: logger.error( 'connection to "%s" failed', name, exc_info=True) @@ -254,63 +249,35 @@ class Database(DatabaseInterface): uri = config.parse_uri(config.get('database', 'uri')) if uri.path and uri.path != '/': warnings.warn("The path specified in the URI will be overridden") - params = { - 'dsn': uri._replace(path='/' + name).geturl(), + return { + 'conninfo': uri._replace( + scheme='postgresql', path='/' + name).geturl(), 'fallback_application_name': os.environ.get( 'TRYTOND_APPNAME', 'trytond'), } - return params def connect(self): return self def get_connection( self, autocommit=False, readonly=False, statement_timeout=None): - retry = max( - config.getint('database', 'retry'), - config.getint('database', 'maxconn', default=64)) - for count in range(retry, -1, -1): - try: - conn = self._connpool.getconn() - except (PoolError, DatabaseOperationalError): - if count and not self._connpool.closed: - logger.info('waiting a connection') - time.sleep(1) - continue - raise - except Exception: - logger.error( - 'connection to "%s" failed', self.name, exc_info=True) - raise - try: - conn.set_session( - isolation_level=ISOLATION_LEVEL_REPEATABLE_READ, - readonly=readonly, - autocommit=autocommit) - with conn.cursor() as cur: - if statement_timeout: - cur.execute('SET statement_timeout=%s' % - (statement_timeout * 1000)) - else: - # Detect disconnection - cur.execute('SELECT 1') - except DatabaseOperationalError: - self._connpool.putconn(conn, close=True) - continue - break + conn = self._connpool.getconn() + conn.isolation_level = IsolationLevel.REPEATABLE_READ + conn.read_only = readonly + conn.autocommit = autocommit + if statement_timeout: + with conn.cursor() as cur: + cur.execute('SET statement_timeout=%s' % + (statement_timeout * 1000)) return conn - def put_connection(self, connection, close=False): - try: - connection.reset() - except InterfaceError: - pass - self._connpool.putconn(connection, close=close) + def put_connection(self, connection): + self._connpool.putconn(connection) def close(self): with self._lock: logger.info('disconnection from "%s"', self.name) - self._connpool.closeall() + self._connpool.close() self._databases[os.getpid()].pop(self.name) @classmethod @@ -346,7 +313,7 @@ class Database(DatabaseInterface): cls._search_full_text_languages.clear() def get_version(self, connection): - version = connection.server_version + version = connection.info.server_version major, rest = divmod(int(version), 10000) minor, patch = divmod(rest, 100) return (major, minor, patch) @@ -359,28 +326,29 @@ class Database(DatabaseInterface): if res and abs(timestamp - now) < timeout: return res - res = [] connection = self.get_connection() try: - cursor = connection.cursor() - cursor.execute('SELECT datname FROM pg_database ' - 'WHERE datistemplate = false ORDER BY datname') - for db_name, in cursor: - try: - conn = connect(**self._connection_params(db_name)) + with connection.cursor() as cursor: + cursor.execute('SELECT datname FROM pg_database ' + 'WHERE datistemplate = false ORDER BY datname') + res = [] + for db_name, in cursor: + params = self._connection_params(db_name) try: - with conn: - if self._test( - conn, hostname=hostname, series=True): - res.append(db_name) - finally: - conn.close() - except Exception: - logger.debug( - 'Test failed for "%s"', db_name, exc_info=True) - continue + conn = connect(params['conninfo']) + try: + with conn: + if self._test(conn, hostname=hostname): + res.append(db_name) + finally: + conn.close() + except Exception: + logger.debug( + 'Test failed for "%s"', db_name, exc_info=True) + continue finally: - self.put_connection(connection, close=True) + connection.rollback() + self.put_connection(connection) self.__class__._list_cache[hostname] = res self.__class__._list_cache_timestamp[hostname] = now @@ -391,26 +359,26 @@ class Database(DatabaseInterface): connection = self.get_connection() try: - cursor = connection.cursor() - sql_file = os.path.join(os.path.dirname(__file__), 'init.sql') - with open(sql_file) as fp: - for line in fp.read().split(';'): - if (len(line) > 0) and (not line.isspace()): - cursor.execute(line) + with connection.cursor() as cursor: + sql_file = os.path.join(os.path.dirname(__file__), 'init.sql') + with open(sql_file) as fp: + for line in fp.read().split(';'): + if line and not line.isspace(): + cursor.execute(line) - for module in ['ir', 'res']: - info = get_module_info(module) - cursor.execute('INSERT INTO ir_module ' - '(create_uid, create_date, name, state) ' - 'VALUES (%s, now(), %s, %s) ' - 'RETURNING id', - (0, module, 'to activate')) - module_id = cursor.fetchone()[0] - for dependency in info.get('depends', []): - cursor.execute('INSERT INTO ir_module_dependency ' - '(create_uid, create_date, module, name) ' - 'VALUES (%s, now(), %s, %s)', - (0, module_id, dependency)) + for module in ['ir', 'res']: + info = get_module_info(module) + cursor.execute('INSERT INTO ir_module ' + '(create_uid, create_date, name, state) ' + 'VALUES (%s, now(), %s, %s) ' + 'RETURNING id', + (0, module, 'to activate')) + module_id = cursor.fetchone()[0] + for dependency in info.get('depends', []): + cursor.execute('INSERT INTO ir_module_dependency ' + '(create_uid, create_date, module, name) ' + 'VALUES (%s, now(), %s, %s)', + (0, module_id, dependency)) connection.commit() finally: @@ -425,36 +393,35 @@ class Database(DatabaseInterface): try: return self._test(connection, hostname=hostname, series=series) finally: - self.put_connection(connection, close=True) + connection.rollback() + self.put_connection(connection) @classmethod def _test(cls, connection, hostname=None, series=False): - cursor = connection.cursor() - cursor.execute( - 'SELECT table_name FROM information_schema.tables ' - 'WHERE table_name = %s', ('ir_configuration',)) - if not cursor.rowcount: - return False - try: + with connection.cursor() as cursor: + cursor.execute( + 'SELECT table_name FROM information_schema.tables ' + 'WHERE table_name = %s', ('ir_configuration',)) + if not cursor.rowcount: + return False if series: cursor.execute('SELECT series FROM ir_configuration') config_series = {s for s, in cursor if s} if config_series and __series__ not in config_series: return False if hostname: - cursor.execute('SELECT hostname FROM ir_configuration') + cursor.execute( + 'SELECT hostname FROM ir_configuration') hostnames = {h for h, in cursor if h} if hostnames and hostname not in hostnames: return False - except UndefinedColumn: - return False - return True + return True def nextid(self, connection, table, count=1): column = 'id' if not table.endswith('__history') else '__id' cursor = connection.cursor() cursor.execute( - "SELECT nextval(pg_get_serial_sequence(format(%s, %s), %s)) " + "SELECT nextval(pg_get_serial_sequence(format(%s, %s::text), %s)) " "FROM generate_series(1, %s)", ('%I', table, column, count)) if count == 1: @@ -468,14 +435,15 @@ class Database(DatabaseInterface): column = 'id' if not table.endswith('__history') else '__id' cursor = connection.cursor() cursor.execute( - "SELECT setval(pg_get_serial_sequence(format(%s, %s), %s), %s)", + "SELECT setval(" + "pg_get_serial_sequence(format(%s, %s::text), %s), %s)", ('%I', table, column, value)) def currid(self, connection, table): column = 'id' if not table.endswith('__history') else '__id' cursor = connection.cursor() cursor.execute( - "SELECT pg_get_serial_sequence(format(%s, %s), %s)", + "SELECT pg_get_serial_sequence(format(%s, %s::text), %s)", ('%I', table, column)) sequence_name, = cursor.fetchone() cursor.execute(f"SELECT last_value FROM {sequence_name}") @@ -494,14 +462,12 @@ class Database(DatabaseInterface): def notify(self, connection, channel, payload): cursor = connection.cursor() - cursor.execute('NOTIFY "%s", %%s' % channel, (payload,)) + cursor.execute('SELECT pg_notify(%s, %s)', (channel, payload)) def get_notifications(self, connection): - connection.poll() - return connection.notifies + return list(connection.notifies(timeout=2)) - @classmethod - def lock(cls, connection, table): + def lock(self, connection, table): cursor = connection.cursor() cursor.execute(SQL('LOCK {} IN EXCLUSIVE MODE NOWAIT').format( Identifier(table))) @@ -563,10 +529,12 @@ class Database(DatabaseInterface): if self._current_user is None: connection = self.get_connection() try: - cursor = connection.cursor() - cursor.execute('SELECT current_user') - self._current_user = cursor.fetchone()[0] + with connection.cursor() as cursor: + cursor.execute('SELECT current_user') + self._current_user = cursor.fetchone()[0] + return self._current_user finally: + connection.rollback() self.put_connection(connection) return self._current_user @@ -575,17 +543,18 @@ class Database(DatabaseInterface): if self._search_path is None: connection = self.get_connection() try: - cursor = connection.cursor() - cursor.execute('SHOW search_path') - path, = cursor.fetchone() - special_values = { - 'user': self.current_user, - } - self._search_path = [ - unescape_quote(replace_special_values( - p.strip(), **special_values)) - for p in path.split(',')] + with connection.cursor() as cursor: + cursor.execute('SHOW search_path') + path, = cursor.fetchone() + special_values = { + 'user': self.current_user, + } + self._search_path = [ + unescape_quote(replace_special_values( + p.strip(), **special_values)) + for p in path.split(',')] finally: + connection.rollback() self.put_connection(connection) return self._search_path @@ -596,6 +565,7 @@ class Database(DatabaseInterface): # RETURNING clause is available since PostgreSQL 8.2 self._has_returning = self.get_version(connection) >= (8, 2) finally: + connection.rollback() self.put_connection(connection) return self._has_returning @@ -609,6 +579,7 @@ class Database(DatabaseInterface): self._has_insert_on_conflict = ( self.get_version(connection) >= (9, 5)) finally: + connection.rollback() self.put_connection(connection) return self._has_insert_on_conflict @@ -620,6 +591,7 @@ class Database(DatabaseInterface): self._has_select_for_skip_locked = ( self.get_version(connection) >= (9, 5)) finally: + connection.rollback() self.put_connection(connection) if self._has_select_for_skip_locked: return ForSkipLocked @@ -637,14 +609,15 @@ class Database(DatabaseInterface): connection = self.get_connection() result = False try: - cursor = connection.cursor() - cursor.execute( - SQL('SELECT {} FROM pg_proc WHERE proname=%s').format( - Identifier(property)), (name,)) - result = cursor.fetchone() - if result: - result, = result + with connection.cursor() as cursor: + cursor.execute( + SQL('SELECT {} FROM pg_proc WHERE proname=%s').format( + Identifier(property)), (name,)) + result = cursor.fetchone() + if result: + result, = result finally: + connection.rollback() self.put_connection(connection) self._has_proc[self.name][name][property] = result return result @@ -670,13 +643,14 @@ class Database(DatabaseInterface): lang = Table('ir_lang') connection = self.get_connection() try: - cursor = connection.cursor() - cursor.execute(*lang.select( - Coalesce(lang.pg_text_search, 'simple'), - where=lang.code == language, - limit=1)) - config_name, = cursor.fetchone() + with connection.cursor() as cursor: + cursor.execute(*lang.select( + Coalesce(lang.pg_text_search, 'simple'), + where=lang.code == language, + limit=1)) + config_name, = cursor.fetchone() finally: + connection.rollback() self.put_connection(connection) languages[language] = config_name else: @@ -715,6 +689,7 @@ class Database(DatabaseInterface): try: version = self.get_version(connection) finally: + connection.rollback() self.put_connection(connection) if not isinstance(query, TsQuery): if version >= (11, 0): @@ -778,7 +753,7 @@ class Database(DatabaseInterface): def sequence_create( self, connection, name, number_increment=1, start_value=1): - cursor = connection.cursor() + cursor = ClientCursor(connection) cursor.execute( SQL("CREATE SEQUENCE {} INCREMENT BY %s START WITH %s").format( @@ -787,14 +762,14 @@ class Database(DatabaseInterface): def sequence_update( self, connection, name, number_increment=1, start_value=1): - cursor = connection.cursor() + cursor = ClientCursor(connection) cursor.execute( SQL("ALTER SEQUENCE {} INCREMENT BY %s RESTART WITH %s").format( Identifier(name)), (number_increment, start_value)) def sequence_rename(self, connection, old_name, new_name): - cursor = connection.cursor() + cursor = ClientCursor(connection) if (self.sequence_exist(connection, old_name) and not self.sequence_exist(connection, new_name)): cursor.execute( @@ -804,16 +779,15 @@ class Database(DatabaseInterface): def sequence_delete(self, connection, name): cursor = connection.cursor() - cursor.execute(SQL("DROP SEQUENCE {}").format( - Identifier(name))) + cursor.execute(SQL("DROP SEQUENCE {}").format(Identifier(name))) def sequence_nextval(self, connection, name): - cursor = connection.cursor() + cursor = ClientCursor(connection) cursor.execute('SELECT NEXTVAL(%s)', (name,)) return cursor.fetchone()[0] def sequence_nextvals(self, connection, name, n): - cursor = connection.cursor() + cursor = ClientCursor(connection) cursor.execute( 'SELECT NEXTVAL(%s) FROM generate_series(1, %s)', (name, n)) for val, in cursor: @@ -853,14 +827,16 @@ class Database(DatabaseInterface): return self._extensions[self.name][extension_name] connection = self.get_connection() - result = False try: - cursor = connection.cursor() - cursor.execute( - "SELECT 1 FROM pg_extension WHERE extname=%s", - (extension_name,)) - result = bool(cursor.rowcount) + result = False + with connection.cursor() as cursor: + cursor = connection.cursor() + cursor.execute( + "SELECT 1 FROM pg_extension WHERE extname=%s", + (extension_name,)) + result = bool(cursor.rowcount) finally: + connection.rollback() self.put_connection(connection) self._extensions[self.name][extension_name] = result return result @@ -914,28 +890,9 @@ class Database(DatabaseInterface): )) -register_type(UNICODE) -if PYDATE: - register_type(PYDATE) -if PYDATETIME: - register_type(PYDATETIME) -if PYTIME: - register_type(PYTIME) -if PYINTERVAL: - register_type(PYINTERVAL) -register_adapter(float, lambda value: AsIs(repr(value))) -register_adapter(Decimal, lambda value: AsIs(str(value))) - - def convert_json(value): from trytond.protocols.jsonrpc import JSONDecoder return json.loads(value, object_hook=JSONDecoder()) -register_default_json(loads=convert_json) -register_default_jsonb(loads=convert_json) - -if is_gevent_monkey_patched(): - from psycopg2.extensions import set_wait_callback - from psycopg2.extras import wait_select - set_wait_callback(wait_select) +psycopg.types.json.set_json_loads(convert_json) diff --git a/trytond/trytond/backend/postgresql/table.py b/trytond/trytond/backend/postgresql/table.py index c69f700d82..8c2b7e6f37 100644 --- a/trytond/trytond/backend/postgresql/table.py +++ b/trytond/trytond/backend/postgresql/table.py @@ -3,7 +3,8 @@ import logging import re -from psycopg2.sql import SQL, Identifier +from psycopg import ClientCursor +from psycopg.sql import SQL, Identifier from sql import Column from sql.operators import NotEqual @@ -30,7 +31,7 @@ class TableHandler(TableHandlerInterface): self.__indexes = None transaction = Transaction() - cursor = transaction.connection.cursor() + cursor = ClientCursor(transaction.connection) # Create new table if necessary if (not (view_exists := self.view_exist(self.table_name)) @@ -146,7 +147,7 @@ class TableHandler(TableHandlerInterface): @classmethod def table_rename(cls, old_name, new_name): transaction = Transaction() - cursor = transaction.connection.cursor() + cursor = ClientCursor(transaction.connection) # Rename table if (cls.table_exist(old_name) and not cls.table_exist(new_name)): @@ -175,7 +176,7 @@ class TableHandler(TableHandlerInterface): return column_name in self._columns def column_rename(self, old_name, new_name): - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) if self.column_exist(old_name): if not self.column_exist(new_name): cursor.execute(SQL( @@ -283,7 +284,7 @@ class TableHandler(TableHandlerInterface): self.__fk_deltypes = None def alter_size(self, column_name, column_type): - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) cursor.execute( SQL("ALTER TABLE {} ALTER COLUMN {} TYPE {}").format( Identifier(self.table_name), @@ -292,7 +293,7 @@ class TableHandler(TableHandlerInterface): self._update_definitions(columns=True) def alter_type(self, column_name, column_type): - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) cursor.execute(SQL('ALTER TABLE {} ALTER {} TYPE {}').format( Identifier(self.table_name), Identifier(column_name), @@ -317,16 +318,14 @@ class TableHandler(TableHandlerInterface): else: test = value if self._columns[column_name]['default'] != test: - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) cursor.execute( - SQL( - 'ALTER TABLE {} ALTER COLUMN {} SET DEFAULT %s').format( - Identifier(self.table_name), - Identifier(column_name)), + SQL('ALTER TABLE {} ALTER COLUMN {} SET DEFAULT %s') + .format(Identifier(self.table_name), Identifier(column_name)), (value,)) def add_column(self, column_name, sql_type, default=None, comment=''): - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) database = Transaction().database column_type = database.sql_type(sql_type) @@ -435,7 +434,7 @@ class TableHandler(TableHandlerInterface): if isinstance(columns, str): columns = [columns] - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) if ref_columns: ref_columns_name = '_' + '_'.join(ref_columns) else: @@ -489,7 +488,7 @@ class TableHandler(TableHandlerInterface): if not self.column_exist(column_name): return - with Transaction().connection.cursor() as cursor: + with ClientCursor(Transaction().connection) as cursor: if action == 'add': if self._columns[column_name]['notnull']: return @@ -534,7 +533,7 @@ class TableHandler(TableHandlerInterface): if ident in self._constraints: # This constrain already exist return - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) if isinstance(constraint, Exclude): definition = constraint.__str__(using=index_method(constraint)) else: @@ -551,14 +550,14 @@ class TableHandler(TableHandlerInterface): ident = self.convert_name((table or self.table_name) + "_" + ident) if ident not in self._constraints: return - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) cursor.execute( SQL('ALTER TABLE {} DROP CONSTRAINT {} CASCADE').format( Identifier(self.table_name), Identifier(ident))) self._update_definitions(constraints=True) def set_indexes(self, indexes, concurrently=False): - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) old = set(self._indexes) for index in indexes: translator = self.index_translator_for(index) @@ -592,7 +591,7 @@ class TableHandler(TableHandlerInterface): def drop_column(self, column_name): if not self.column_exist(column_name): return - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) cursor.execute(SQL('ALTER TABLE {} DROP COLUMN {}').format( Identifier(self.table_name), Identifier(column_name))) @@ -600,7 +599,7 @@ class TableHandler(TableHandlerInterface): @classmethod def drop_table(cls, model, table, cascade=False): - cursor = Transaction().connection.cursor() + cursor = ClientCursor(Transaction().connection) cursor.execute('DELETE FROM ir_model_data WHERE model = %s', (model,)) query = 'DROP TABLE {}' diff --git a/trytond/trytond/backend/sqlite/database.py b/trytond/trytond/backend/sqlite/database.py index 2406f8daa2..3e546de9ed 100644 --- a/trytond/trytond/backend/sqlite/database.py +++ b/trytond/trytond/backend/sqlite/database.py @@ -391,7 +391,11 @@ def div(a, b): return a // b -def trunc(value, digits): +def trunc(value, digits=0): + if isinstance(value, bytes): + value = value.decode() + if isinstance(value, str): + value = Decimal(value) return math.trunc(value * 10 ** digits) / 10 ** digits @@ -493,7 +497,7 @@ class Database(DatabaseInterface): self._conn.create_function('radians', 1, math.radians) self._conn.create_function('sign', 1, sign) self._conn.create_function('sqrt', 1, math.sqrt) - self._conn.create_function('trunc', 1, math.trunc) + self._conn.create_function('trunc', 1, trunc) self._conn.create_function('trunc', 2, trunc) # Trigonomentric functions @@ -563,16 +567,8 @@ class Database(DatabaseInterface): self._conn.isolation_level = 'IMMEDIATE' return self._conn - def put_connection(self, connection=None, close=False): + def put_connection(self, connection=None): assert connection == self._conn or self._conn is None - if self.name == ':memory:': - if (self._local.memory_database._conn is None - and connection and close): - connection.close() - self._conn = None - elif close: - connection.close() - self._conn = None def close(self): if self.name == ':memory:': diff --git a/trytond/trytond/tests/test_backend.py b/trytond/trytond/tests/test_backend.py index 383f8819c3..94cb47a32b 100644 --- a/trytond/trytond/tests/test_backend.py +++ b/trytond/trytond/tests/test_backend.py @@ -110,12 +110,12 @@ class BackendTestCase(TestCase): (functions.Pi(), math.pi), (functions.Power(9, 3), 729), (functions.Radians(45.), math.pi / 4), - (functions.Round(42.4), 42), - (functions.Round(42.4382, 2), 42.44), + (functions.Round(Decimal('42.4')), 42), + (functions.Round(Decimal('42.4382'), 2), 42.44), (functions.Sign(-8.4), -1), (functions.Sqrt(2.), 1.4142135623731), - (functions.Trunc(42.8), 42), - (functions.Trunc(42.4348, 2), 42.43), + (functions.Trunc(Decimal('42.8')), 42), + (functions.Trunc(Decimal('42.4348'), 2), 42.43), (functions.Acos(0.5), 1.0471975511965979), (functions.Asin(0.5), 0.5235987755982989), (functions.Atan(0.5), 0.4636476090008061), diff --git a/trytond/trytond/tests/test_tryton.py b/trytond/trytond/tests/test_tryton.py index 50bf906473..72182ae03e 100644 --- a/trytond/trytond/tests/test_tryton.py +++ b/trytond/trytond/tests/test_tryton.py @@ -169,7 +169,8 @@ def _sqlite_copy(file_, restore=False): try: database.create(connection, DB_NAME) finally: - database.put_connection(connection, True) + database.put_connection(connection) + database.close() with Transaction().start(DB_NAME, 0) as transaction: conn1 = transaction.connection @@ -1246,7 +1247,8 @@ def create_db(name=DB_NAME, lang='en'): try: database.create(connection, name) finally: - database.put_connection(connection, True) + database.put_connection(connection) + database.close() database = backend.Database(name) connection = database.get_connection() diff --git a/trytond/trytond/tools/misc.py b/trytond/trytond/tools/misc.py index c555bb79e7..b9bb13c2b3 100644 --- a/trytond/trytond/tools/misc.py +++ b/trytond/trytond/tools/misc.py @@ -17,7 +17,7 @@ from collections.abc import Iterable, Sized from functools import cache, wraps from itertools import chain, islice, tee, zip_longest -from sql import As, Literal, Select +from sql import As, Cast, Literal, Select from sql.conditionals import Case from sql.operators import Or @@ -302,9 +302,11 @@ def sortable_values(func): def sql_pairing(x, y): """Return SQL expression to pair x and y Pairing function from http://szudzik.com/ElegantPairing.pdf""" - return Case( - (x < y, (y * y) + x), - else_=(x * x) + x + y) + x = Cast(x, 'BIGINT') + y = Cast(y, 'BIGINT') + return Cast(Case( + (x < y, (y * y) + x), + else_=(x * x) + x + y), 'BIGINT') def pair(x, y): diff --git a/trytond/trytond/transaction.py b/trytond/trytond/transaction.py index fb539d565e..ae4f3bb340 100644 --- a/trytond/trytond/transaction.py +++ b/trytond/trytond/transaction.py @@ -124,7 +124,6 @@ class Transaction(object): instance.database = None instance.readonly = False instance.connection = None - instance.close = None instance.user = None instance.context = None instance.create_records = None @@ -173,7 +172,7 @@ class Transaction(object): return cache def start(self, database_name, user, readonly=False, context=None, - close=False, autocommit=False, timeout=None, **extras): + autocommit=False, timeout=None, **extras): ''' Start transaction ''' @@ -181,7 +180,6 @@ class Transaction(object): from trytond import backend assert self.user is None assert self.database is None - assert self.close is None assert self.context is None # Compute started_at before connect to ensure # it is strictly before all transactions started after @@ -195,7 +193,6 @@ class Transaction(object): self.user = user self.database = database self.readonly = readonly - self.close = close self.context = ImmutableDict(context or {}) self.create_records = defaultdict(list) self.delete_records = defaultdict(set) @@ -257,13 +254,11 @@ class Transaction(object): self.rollback() finally: if self.connection: - self.database.put_connection( - self.connection, self.close) + self.database.put_connection(self.connection) finally: self.database = None self.readonly = False self.connection = None - self.close = None self.user = None self.context = None self.create_records = None @@ -329,7 +324,7 @@ class Transaction(object): def new_transaction(self, autocommit=False, readonly=False, **extras): transaction = Transaction(new=True) return transaction.start(self.database.name, self.user, - context=self.context, close=self.close, readonly=readonly, + context=self.context, readonly=readonly, autocommit=autocommit, **extras) def _store_log_records(self):