diff --git a/modules/account_fr_chorus/CHANGELOG b/modules/account_fr_chorus/CHANGELOG index 998e003f34..bfa7cfb0e8 100644 --- a/modules/account_fr_chorus/CHANGELOG +++ b/modules/account_fr_chorus/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/account_fr_chorus/account.py b/modules/account_fr_chorus/account.py index b8db96489c..8e86b3b4a8 100644 --- a/modules/account_fr_chorus/account.py +++ b/modules/account_fr_chorus/account.py @@ -19,7 +19,7 @@ from trytond.pool import Pool, PoolMeta from trytond.pyson import Bool, Eval, If from trytond.transaction import Transaction -from .exceptions import InvoiceChorusValidationError +from .exceptions import ChorusCredentialWarning, InvoiceChorusValidationError OAUTH_TOKEN_URL = { 'service-qualif': 'https://sandbox-oauth.piste.gouv.fr/api/oauth/token', @@ -163,6 +163,28 @@ class CredentialChorus(ModelSQL, CompanyValueMixin): resp.raise_for_status() return resp.json() + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for records, values in zip(actions, actions): + for record in records: + for field in [ + 'chorus_piste_client_id', 'chorus_piste_client_secret', + 'chorus_login', 'chorus_password', 'chorus_service']: + if (field in values + and getattr(record, field) + and getattr(record, field) != values[field]): + warning_name = Warning.format( + 'chorus_credential', [record]) + if Warning.check(warning_name): + raise ChorusCredentialWarning( + warning_name, + gettext('account_fr_chorus' + '.msg_chorus_credential_modified')) + return super().write(*args) + class Invoice(metaclass=PoolMeta): __name__ = 'account.invoice' diff --git a/modules/account_fr_chorus/exceptions.py b/modules/account_fr_chorus/exceptions.py index 6e5031f7b6..c06cd15afb 100644 --- a/modules/account_fr_chorus/exceptions.py +++ b/modules/account_fr_chorus/exceptions.py @@ -1,8 +1,13 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +from trytond.exceptions import UserWarning from trytond.model.exceptions import ValidationError class InvoiceChorusValidationError(ValidationError): pass + + +class ChorusCredentialWarning(UserWarning): + pass diff --git a/modules/account_fr_chorus/message.xml b/modules/account_fr_chorus/message.xml index 5e704f43d2..4bf1f519f1 100644 --- a/modules/account_fr_chorus/message.xml +++ b/modules/account_fr_chorus/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify Chorus credentials? + You can create only one Chorus invoice per invoice. diff --git a/modules/account_payment_braintree/CHANGELOG b/modules/account_payment_braintree/CHANGELOG index a7cd1f6e00..de0e1db524 100644 --- a/modules/account_payment_braintree/CHANGELOG +++ b/modules/account_payment_braintree/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/account_payment_braintree/account.py b/modules/account_payment_braintree/account.py index d05373784c..01f2b5263a 100644 --- a/modules/account_payment_braintree/account.py +++ b/modules/account_payment_braintree/account.py @@ -35,6 +35,7 @@ from trytond.wizard import ( Button, StateAction, StateTransition, StateView, Wizard) from .common import BraintreeCustomerMethodMixin +from .exceptions import BraintreeAccountWarning logger = logging.getLogger(__name__) @@ -902,6 +903,22 @@ class PaymentBraintreeAccount(ModelSQL, ModelView): payment.braintree_update(transaction) return bool(payments) + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for accounts, values in zip(actions, actions): + if ({'environment', 'merchant_id', 'public_key', 'private_key'} + & values.keys()): + warning_name = Warning.format('braintree_key', accounts) + if Warning.check(warning_name): + raise BraintreeAccountWarning( + warning_name, + gettext('account_payment_braintree' + '.msg_braintree_key_modified')) + return super().write(*args) + class PaymentBraintreeCustomer( CheckoutMixin, DeactivableMixin, ModelSQL, ModelView): diff --git a/modules/account_payment_braintree/exceptions.py b/modules/account_payment_braintree/exceptions.py new file mode 100644 index 0000000000..de33e6f94c --- /dev/null +++ b/modules/account_payment_braintree/exceptions.py @@ -0,0 +1,8 @@ +# This file is part of Tryton. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. + +from trytond.exceptions import UserWarning + + +class BraintreeAccountWarning(UserWarning): + pass diff --git a/modules/account_payment_braintree/message.xml b/modules/account_payment_braintree/message.xml index 7768844bdd..e1bad42c55 100644 --- a/modules/account_payment_braintree/message.xml +++ b/modules/account_payment_braintree/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify the keys of the Braintree account? + To process payment "%(payment)s" you must set a Braintree nonce or customer. diff --git a/modules/account_payment_stripe/CHANGELOG b/modules/account_payment_stripe/CHANGELOG index 41c3bff01e..ad4600d84e 100644 --- a/modules/account_payment_stripe/CHANGELOG +++ b/modules/account_payment_stripe/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/account_payment_stripe/exceptions.py b/modules/account_payment_stripe/exceptions.py new file mode 100644 index 0000000000..a048c6d9b4 --- /dev/null +++ b/modules/account_payment_stripe/exceptions.py @@ -0,0 +1,8 @@ +# This file is part of Tryton. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. + +from trytond.exceptions import UserWarning + + +class StripeAccountWarning(UserWarning): + pass diff --git a/modules/account_payment_stripe/message.xml b/modules/account_payment_stripe/message.xml index 18cb20e3d8..5d0583cbda 100644 --- a/modules/account_payment_stripe/message.xml +++ b/modules/account_payment_stripe/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify the keys of the Stripe account? + To process payment "%(payment)s" you must set a Stripe token or customer. diff --git a/modules/account_payment_stripe/payment.py b/modules/account_payment_stripe/payment.py index 0c936fc997..d39fe8d1f3 100644 --- a/modules/account_payment_stripe/payment.py +++ b/modules/account_payment_stripe/payment.py @@ -35,6 +35,7 @@ from trytond.wizard import ( Button, StateAction, StateTransition, StateView, Wizard) from .common import StripeCustomerMethodMixin +from .exceptions import StripeAccountWarning logger = logging.getLogger(__name__) stripe.max_network_retries = config.getint( @@ -1314,6 +1315,21 @@ class Account(ModelSQL, ModelView): account.webhook_identifier = uuid.uuid4().hex cls.save(accounts) + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for accounts, values in zip(actions, actions): + if {'secret_key', 'publishable_key'} & values.keys(): + warning_name = Warning.format('stripe_key', accounts) + if Warning.check(warning_name): + raise StripeAccountWarning( + warning_name, + gettext('account_payment_stripe' + '.msg_stripe_key_modified')) + return super().write(*args) + class Customer(CheckoutMixin, DeactivableMixin, ModelSQL, ModelView): "Stripe Customer" diff --git a/modules/currency_rs/CHANGELOG b/modules/currency_rs/CHANGELOG index e50a9807d2..b7278dc495 100644 --- a/modules/currency_rs/CHANGELOG +++ b/modules/currency_rs/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/currency_rs/currency.py b/modules/currency_rs/currency.py index f53bf3208e..3e874b63b4 100644 --- a/modules/currency_rs/currency.py +++ b/modules/currency_rs/currency.py @@ -8,11 +8,14 @@ from zeep.exceptions import Error from trytond.cache import Cache from trytond.config import config +from trytond.i18n import gettext from trytond.model import fields from trytond.modules.currency.currency import CronFetchError -from trytond.pool import PoolMeta +from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval, If +from .exceptions import RSCredentialWarning + URL = ( 'https://webservices.nbs.rs/CommunicationOfficeService1_0/' 'ExchangeRateXmlService.asmx?WSDL') @@ -95,3 +98,18 @@ class Cron(metaclass=PoolMeta): Decimal(r.Unit.text) / Decimal(r.MiddleRate.text)) for r in data.iterchildren() if r.Date == date.strftime('%d.%m.%Y')} + + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for crons, values in zip(actions, actions): + if ({'rs_username', 'rs_password', 'rs_license_id'} + & values.keys()): + warning_name = Warning.format('rs_credential', crons) + if Warning.check(warning_name): + raise RSCredentialWarning( + warning_name, + gettext('currency_rs.msg_rs_credential_modified')) + return super().write(*args) diff --git a/modules/currency_rs/exceptions.py b/modules/currency_rs/exceptions.py new file mode 100644 index 0000000000..5e278ec2fe --- /dev/null +++ b/modules/currency_rs/exceptions.py @@ -0,0 +1,8 @@ +# This file is part of Tryton. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. + +from trytond.exceptions import UserWarning + + +class RSCredentialWarning(UserWarning): + pass diff --git a/modules/currency_rs/message.xml b/modules/currency_rs/message.xml new file mode 100644 index 0000000000..c4fa56172f --- /dev/null +++ b/modules/currency_rs/message.xml @@ -0,0 +1,10 @@ + + + + + + Are you sure you want to modify Serbian National Bank credentials? + + + diff --git a/modules/document_incoming_ocr_typless/CHANGELOG b/modules/document_incoming_ocr_typless/CHANGELOG index a9b0756a09..4f47f21df3 100644 --- a/modules/document_incoming_ocr_typless/CHANGELOG +++ b/modules/document_incoming_ocr_typless/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/document_incoming_ocr_typless/document.py b/modules/document_incoming_ocr_typless/document.py index 2b9c8bde67..adf6e1f853 100644 --- a/modules/document_incoming_ocr_typless/document.py +++ b/modules/document_incoming_ocr_typless/document.py @@ -9,10 +9,10 @@ import requests from trytond.i18n import gettext from trytond.model import fields -from trytond.pool import PoolMeta +from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval -from .exceptions import TyplessError +from .exceptions import TyplessCredentialWarning, TyplessError MIME_TYPES = { 'application/pdf', @@ -320,3 +320,18 @@ class IncomingOCRService(metaclass=PoolMeta): return '' elif name == 'vat_rate_net': return str(line.base) + + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for services, values in zip(actions, actions): + if 'typless_api_key' in values.keys(): + warning_name = Warning.format('typless_credential', services) + if Warning.check(warning_name): + raise TyplessCredentialWarning( + warning_name, + gettext('document_incoming_ocr_typless' + '.msg_typless_credential_modified')) + return super().write(*args) diff --git a/modules/document_incoming_ocr_typless/exceptions.py b/modules/document_incoming_ocr_typless/exceptions.py index 0d77cf5ec7..8f7d0cc41f 100644 --- a/modules/document_incoming_ocr_typless/exceptions.py +++ b/modules/document_incoming_ocr_typless/exceptions.py @@ -1,8 +1,12 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserError +from trytond.exceptions import UserError, UserWarning class TyplessError(UserError): pass + + +class TyplessCredentialWarning(UserWarning): + pass diff --git a/modules/document_incoming_ocr_typless/message.xml b/modules/document_incoming_ocr_typless/message.xml index 9d7b4c264e..2c2aafa453 100644 --- a/modules/document_incoming_ocr_typless/message.xml +++ b/modules/document_incoming_ocr_typless/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify Typless credentials? + Typless webservice call failed with the following error message: %(message)s diff --git a/modules/stock_package_shipping_dpd/CHANGELOG b/modules/stock_package_shipping_dpd/CHANGELOG index 3850a8881f..49aec21076 100644 --- a/modules/stock_package_shipping_dpd/CHANGELOG +++ b/modules/stock_package_shipping_dpd/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/stock_package_shipping_dpd/carrier.py b/modules/stock_package_shipping_dpd/carrier.py index a1025d5711..941cc4422f 100644 --- a/modules/stock_package_shipping_dpd/carrier.py +++ b/modules/stock_package_shipping_dpd/carrier.py @@ -8,11 +8,11 @@ from zeep.exceptions import Fault from trytond.i18n import gettext from trytond.model import ( MatchMixin, ModelSQL, ModelView, fields, sequence_ordered) -from trytond.pool import PoolMeta +from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval from .configuration import LOGIN_SERVICE, get_client -from .exceptions import DPDError +from .exceptions import DPDCredentialWarning, DPDError class CredentialDPD(sequence_ordered(), ModelSQL, ModelView, MatchMixin): @@ -52,6 +52,21 @@ class CredentialDPD(sequence_ordered(), ModelSQL, ModelView, MatchMixin): self.depot = result.depot self.save() + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for credentials, values in zip(actions, actions): + if {'user_id', 'password', 'server'} & values.keys(): + warning_name = Warning.format('dpd_credential', credentials) + if Warning.check(warning_name): + raise DPDCredentialWarning( + warning_name, + gettext('stock_package_shipping_dpd' + '.msg_dpd_credential_modified')) + return super().write(*args) + class Carrier(metaclass=PoolMeta): __name__ = 'carrier' diff --git a/modules/stock_package_shipping_dpd/exceptions.py b/modules/stock_package_shipping_dpd/exceptions.py index d3cb0d2c64..d8d1b03b91 100644 --- a/modules/stock_package_shipping_dpd/exceptions.py +++ b/modules/stock_package_shipping_dpd/exceptions.py @@ -1,8 +1,12 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserError +from trytond.exceptions import UserError, UserWarning class DPDError(UserError): pass + + +class DPDCredentialWarning(UserWarning): + pass diff --git a/modules/stock_package_shipping_dpd/message.xml b/modules/stock_package_shipping_dpd/message.xml index 94ec63fc0e..1106af8ec7 100644 --- a/modules/stock_package_shipping_dpd/message.xml +++ b/modules/stock_package_shipping_dpd/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify DPD credentials? + DPD webservice call failed with the following error message: %(message)s diff --git a/modules/stock_package_shipping_mygls/CHANGELOG b/modules/stock_package_shipping_mygls/CHANGELOG index 9c6bb179ea..4d37f85eca 100644 --- a/modules/stock_package_shipping_mygls/CHANGELOG +++ b/modules/stock_package_shipping_mygls/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/stock_package_shipping_mygls/carrier.py b/modules/stock_package_shipping_mygls/carrier.py index 3b0d680cfe..5474031fef 100644 --- a/modules/stock_package_shipping_mygls/carrier.py +++ b/modules/stock_package_shipping_mygls/carrier.py @@ -1,10 +1,13 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. +from trytond.i18n import gettext from trytond.model import ( MatchMixin, ModelSQL, ModelView, fields, sequence_ordered) -from trytond.pool import PoolMeta +from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval, If +from .exceptions import MyGLSCredentialWarning + class CredentialMyGLS(sequence_ordered(), ModelSQL, ModelView, MatchMixin): "MyGLS Credential" @@ -31,6 +34,22 @@ class CredentialMyGLS(sequence_ordered(), ModelSQL, ModelView, MatchMixin): def default_server(cls): return 'testing' + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for credentials, values in zip(actions, actions): + if ({'server', 'username', 'password', 'client_number'} + & values.keys()): + warning_name = Warning.format('mygls_credential', credentials) + if Warning.check(warning_name): + raise MyGLSCredentialWarning( + warning_name, + gettext('stock_package_shipping_mygls' + '.msg_mygls_credential_modified')) + return super().write(*args) + class Carrier(metaclass=PoolMeta): __name__ = 'carrier' diff --git a/modules/stock_package_shipping_mygls/exceptions.py b/modules/stock_package_shipping_mygls/exceptions.py index 5da7ef4d7a..d0c7f59c76 100644 --- a/modules/stock_package_shipping_mygls/exceptions.py +++ b/modules/stock_package_shipping_mygls/exceptions.py @@ -1,7 +1,11 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserError +from trytond.exceptions import UserError, UserWarning class MyGLSError(UserError): pass + + +class MyGLSCredentialWarning(UserWarning): + pass diff --git a/modules/stock_package_shipping_mygls/message.xml b/modules/stock_package_shipping_mygls/message.xml index 3e3fb4f76d..52e8f4ed2e 100644 --- a/modules/stock_package_shipping_mygls/message.xml +++ b/modules/stock_package_shipping_mygls/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify MyGLS credentials? + To validate shipment "%(shipment)s" you must set an address on warehouse "%(warehouse)s". diff --git a/modules/stock_package_shipping_sendcloud/CHANGELOG b/modules/stock_package_shipping_sendcloud/CHANGELOG index 9c6bb179ea..4d37f85eca 100644 --- a/modules/stock_package_shipping_sendcloud/CHANGELOG +++ b/modules/stock_package_shipping_sendcloud/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/stock_package_shipping_sendcloud/carrier.py b/modules/stock_package_shipping_sendcloud/carrier.py index e66feadbc8..70db3a1bf9 100644 --- a/modules/stock_package_shipping_sendcloud/carrier.py +++ b/modules/stock_package_shipping_sendcloud/carrier.py @@ -10,11 +10,11 @@ from trytond.config import config from trytond.i18n import gettext from trytond.model import ( MatchMixin, ModelSQL, ModelView, fields, sequence_ordered) -from trytond.pool import PoolMeta +from trytond.pool import Pool, PoolMeta from trytond.protocols.wrappers import HTTPStatus from trytond.pyson import Eval -from .exceptions import SendcloudError +from .exceptions import SendcloudCredentialWarning, SendcloudError SENDCLOUD_API_URL = 'https://panel.sendcloud.sc/api/v2/' TIMEOUT = config.getfloat( @@ -171,6 +171,22 @@ class CredentialSendcloud(sequence_ordered(), ModelSQL, ModelView, MatchMixin): response.raise_for_status() return response.content + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for credentials, values in zip(actions, actions): + if {'public_key', 'secret_key'} & values.keys(): + warning_name = Warning.format( + 'sendcloud_credential', credentials) + if Warning.check(warning_name): + raise SendcloudCredentialWarning( + warning_name, + gettext('stock_package_shipping_sendcloud' + '.msg_sendcloud_credential_modified')) + return super().write(*args) + class SendcloudAddress(sequence_ordered(), ModelSQL, ModelView, MatchMixin): "Sendcloud Address" diff --git a/modules/stock_package_shipping_sendcloud/exceptions.py b/modules/stock_package_shipping_sendcloud/exceptions.py index 718b43637b..49279772c3 100644 --- a/modules/stock_package_shipping_sendcloud/exceptions.py +++ b/modules/stock_package_shipping_sendcloud/exceptions.py @@ -1,8 +1,12 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserError +from trytond.exceptions import UserError, UserWarning class SendcloudError(UserError): pass + + +class SendcloudCredentialWarning(UserWarning): + pass diff --git a/modules/stock_package_shipping_sendcloud/message.xml b/modules/stock_package_shipping_sendcloud/message.xml index 763793b4cf..1f560729cb 100644 --- a/modules/stock_package_shipping_sendcloud/message.xml +++ b/modules/stock_package_shipping_sendcloud/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify Sendcloud credentials? + Sendcloud webservice call failed with the following error message: %(message)s diff --git a/modules/stock_package_shipping_ups/CHANGELOG b/modules/stock_package_shipping_ups/CHANGELOG index c90ba7ef32..28dba106aa 100644 --- a/modules/stock_package_shipping_ups/CHANGELOG +++ b/modules/stock_package_shipping_ups/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/stock_package_shipping_ups/carrier.py b/modules/stock_package_shipping_ups/carrier.py index 0d13c91d56..8da74c52ac 100644 --- a/modules/stock_package_shipping_ups/carrier.py +++ b/modules/stock_package_shipping_ups/carrier.py @@ -4,11 +4,14 @@ from oauthlib.oauth2 import BackendApplicationClient from requests_oauthlib import OAuth2Session +from trytond.i18n import gettext from trytond.model import ( MatchMixin, ModelSQL, ModelView, fields, sequence_ordered) -from trytond.pool import PoolMeta +from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval +from .exceptions import UPSCredentialWarning + class CredentialUPS(sequence_ordered(), ModelSQL, ModelView, MatchMixin): 'UPS Credential' @@ -61,6 +64,22 @@ class CredentialUPS(sequence_ordered(), ModelSQL, ModelView, MatchMixin): else: return 'https://wwwcie.ups.com/api/shipments/v1/ship' + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for credentials, values in zip(actions, actions): + if ({'client_id', 'client_secret', 'account_number'} + & values.keys()): + warning_name = Warning.format('dpd_credential', credentials) + if Warning.check(warning_name): + raise UPSCredentialWarning( + warning_name, + gettext('stock_package_shipping_ups' + '.msg_ups_credential_modified')) + return super().write(*args) + class Carrier(metaclass=PoolMeta): __name__ = 'carrier' diff --git a/modules/stock_package_shipping_ups/exceptions.py b/modules/stock_package_shipping_ups/exceptions.py index 5ef681f84d..620a4bc5ce 100644 --- a/modules/stock_package_shipping_ups/exceptions.py +++ b/modules/stock_package_shipping_ups/exceptions.py @@ -1,8 +1,12 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserError +from trytond.exceptions import UserError, UserWarning class UPSError(UserError): pass + + +class UPSCredentialWarning(UserWarning): + pass diff --git a/modules/stock_package_shipping_ups/message.xml b/modules/stock_package_shipping_ups/message.xml index 2bb8d0487c..10c844a4ca 100644 --- a/modules/stock_package_shipping_ups/message.xml +++ b/modules/stock_package_shipping_ups/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify UPS credentials? + UPS webservice call failed with the following error message: %(message)s diff --git a/modules/web_shop_shopify/CHANGELOG b/modules/web_shop_shopify/CHANGELOG index fa45c409d6..183c227c4d 100644 --- a/modules/web_shop_shopify/CHANGELOG +++ b/modules/web_shop_shopify/CHANGELOG @@ -1,3 +1,4 @@ +* Warn when changing credential Version 7.2.0 - 2024-04-29 -------------------------- diff --git a/modules/web_shop_shopify/exceptions.py b/modules/web_shop_shopify/exceptions.py index 6f073fdb84..1223225180 100644 --- a/modules/web_shop_shopify/exceptions.py +++ b/modules/web_shop_shopify/exceptions.py @@ -1,7 +1,11 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from trytond.exceptions import UserError +from trytond.exceptions import UserError, UserWarning class ShopifyError(UserError): pass + + +class ShopifyCredentialWarning(UserWarning): + pass diff --git a/modules/web_shop_shopify/message.xml b/modules/web_shop_shopify/message.xml index 80e03fb836..400ba36c1d 100644 --- a/modules/web_shop_shopify/message.xml +++ b/modules/web_shop_shopify/message.xml @@ -3,6 +3,9 @@ this repository contains the full copyright notices and license terms. --> + + Are you sure you want to modify Shopify credentials? + Shopify Identifier diff --git a/modules/web_shop_shopify/web.py b/modules/web_shop_shopify/web.py index 5551066273..be83be7638 100644 --- a/modules/web_shop_shopify/web.py +++ b/modules/web_shop_shopify/web.py @@ -20,7 +20,7 @@ from trytond.transaction import Transaction from trytond.url import http_host from .common import IdentifierMixin, IdentifiersMixin -from .exceptions import ShopifyError +from .exceptions import ShopifyCredentialWarning, ShopifyError EDIT_ORDER_DELAY = dt.timedelta(days=60 + 1) @@ -580,6 +580,23 @@ class Shop(metaclass=PoolMeta): Amendment._clear_sale(to_update.keys()) Sale.__queue__.process(to_update.keys()) + @classmethod + def write(cls, *args): + pool = Pool() + Warning = pool.get('res.user.warning') + actions = iter(args) + for shops, values in zip(actions, actions): + if ({'shopify_url', 'shopify_password', + 'shopify_webhook_shared_secret'} + & values.keys()): + warning_name = Warning.format('shopify_credential', shops) + if Warning.check(warning_name): + raise ShopifyCredentialWarning( + warning_name, + gettext('web_shop_shopify' + '.msg_shopidy_credential_modified')) + return super().write(*args) + class ShopShopifyIdentifier(IdentifierMixin, ModelSQL, ModelView): "Shopify Identifier"