diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py index 3b46f4dba2bd0..dc5e6b693d19d 100644 --- a/addons/account_tax_python/__init__.py +++ b/addons/account_tax_python/__init__.py @@ -2,16 +2,3 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import models - -from odoo import api, SUPERUSER_ID - -import logging -_logger = logging.getLogger(__name__) - -def uninstall_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) - - code_taxes = env['account.tax'].search([('amount_type', '=', 'code')]) - code_taxes.write({'amount_type': 'percent', 'active': False}) - - _logger.warning("The following taxes have been archived following 'account_tax_python' module uninstallation: %s" % code_taxes.ids) diff --git a/addons/account_tax_python/__manifest__.py b/addons/account_tax_python/__manifest__.py index cb0dde674a565..e27facde6aa3e 100644 --- a/addons/account_tax_python/__manifest__.py +++ b/addons/account_tax_python/__manifest__.py @@ -17,5 +17,4 @@ 'data': [ 'views/account_tax_views.xml', ], - 'uninstall_hook': "uninstall_hook", } diff --git a/addons/account_tax_python/models/account_tax.py b/addons/account_tax_python/models/account_tax.py index dbd143a58b5a3..435be47fa9cc0 100644 --- a/addons/account_tax_python/models/account_tax.py +++ b/addons/account_tax_python/models/account_tax.py @@ -8,7 +8,9 @@ class AccountTaxPython(models.Model): _inherit = "account.tax" - amount_type = fields.Selection(selection_add=[('code', 'Python Code')]) + amount_type = fields.Selection(selection_add=[ + ('code', 'Python Code') + ], ondelete={'code': lambda recs: recs.write({'amount_type': 'percent', 'active': False})}) python_compute = fields.Text(string='Python Code', default="result = price_unit * 0.10", help="Compute the amount of the tax by setting the variable 'result'.\n\n" @@ -54,7 +56,9 @@ def compute_all(self, price_unit, currency=None, quantity=1.0, product=None, par class AccountTaxTemplatePython(models.Model): _inherit = 'account.tax.template' - amount_type = fields.Selection(selection_add=[('code', 'Python Code')]) + amount_type = fields.Selection(selection_add=[ + ('code', 'Python Code') + ], ondelete={'code': 'cascade'}) python_compute = fields.Text(string='Python Code', default="result = price_unit * 0.10", help="Compute the amount of the tax by setting the variable 'result'.\n\n" diff --git a/addons/base_automation/models/ir_actions.py b/addons/base_automation/models/ir_actions.py index 67e75872873ab..0cf9263c637c5 100644 --- a/addons/base_automation/models/ir_actions.py +++ b/addons/base_automation/models/ir_actions.py @@ -7,4 +7,6 @@ class ServerAction(models.Model): _inherit = "ir.actions.server" - usage = fields.Selection(selection_add=[('base_automation', 'Automated Action')]) + usage = fields.Selection(selection_add=[ + ('base_automation', 'Automated Action') + ], ondelete={'base_automation': 'cascade'}) diff --git a/addons/base_sparse_field/models/models.py b/addons/base_sparse_field/models/models.py index cc886e808d8db..6947a2d120208 100644 --- a/addons/base_sparse_field/models/models.py +++ b/addons/base_sparse_field/models/models.py @@ -7,7 +7,9 @@ class IrModelFields(models.Model): _inherit = 'ir.model.fields' - ttype = fields.Selection(selection_add=[('serialized', 'serialized')]) + ttype = fields.Selection(selection_add=[ + ('serialized', 'serialized'), + ], ondelete={'serialized': 'cascade'}) serialization_field_id = fields.Many2one('ir.model.fields', string='Serialization Field', ondelete='cascade', domain="[('ttype','=','serialized'), ('model_id', '=', model_id)]", help="If set, this field will be stored in the sparse structure of the " diff --git a/addons/calendar_sms/models/calendar.py b/addons/calendar_sms/models/calendar.py index 1bfccfe7521df..815a93c86d00a 100644 --- a/addons/calendar_sms/models/calendar.py +++ b/addons/calendar_sms/models/calendar.py @@ -31,7 +31,9 @@ def _do_sms_reminder(self): class CalendarAlarm(models.Model): _inherit = 'calendar.alarm' - alarm_type = fields.Selection(selection_add=[('sms', 'SMS Text Message')]) + alarm_type = fields.Selection(selection_add=[ + ('sms', 'SMS Text Message') + ], ondelete={'sms': 'set default'}) class AlarmManager(models.AbstractModel): diff --git a/addons/crm/wizard/crm_lead_to_opportunity_mass.py b/addons/crm/wizard/crm_lead_to_opportunity_mass.py index f33abf83ea9d3..2433c9e474eea 100644 --- a/addons/crm/wizard/crm_lead_to_opportunity_mass.py +++ b/addons/crm/wizard/crm_lead_to_opportunity_mass.py @@ -24,7 +24,9 @@ def default_get(self, fields): deduplicate = fields.Boolean('Apply deduplication', default=True, help='Merge with existing leads/opportunities of each partner') action = fields.Selection(selection_add=[ ('each_exist_or_create', 'Use existing partner or create'), - ], string='Related Customer') + ], string='Related Customer', ondelete={ + 'each_exist_or_create': lambda recs: recs.write({'action': 'exist'}), + }) force_assignment = fields.Boolean(default=False) @api.depends('duplicated_lead_ids') diff --git a/addons/delivery/models/delivery_grid.py b/addons/delivery/models/delivery_grid.py index bbfc0560a9cab..5cef40ac21024 100644 --- a/addons/delivery/models/delivery_grid.py +++ b/addons/delivery/models/delivery_grid.py @@ -38,7 +38,11 @@ def _compute_name(self): class ProviderGrid(models.Model): _inherit = 'delivery.carrier' - delivery_type = fields.Selection(selection_add=[('base_on_rule', 'Based on Rules')]) + delivery_type = fields.Selection(selection_add=[ + ('base_on_rule', 'Based on Rules'), + ], ondelete={'base_on_rule': lambda recs: recs.write({ + 'delivery_type': 'fixed', 'fixed_price': 0, + })}) price_rule_ids = fields.One2many('delivery.price.rule', 'carrier_id', 'Pricing Rules', copy=True) def base_on_rule_rate_shipment(self, order): diff --git a/addons/event_sms/models/event_mail.py b/addons/event_sms/models/event_mail.py index 14d43ec137372..53562875f1022 100644 --- a/addons/event_sms/models/event_mail.py +++ b/addons/event_sms/models/event_mail.py @@ -7,7 +7,9 @@ class EventTypeMail(models.Model): _inherit = 'event.type.mail' - notification_type = fields.Selection(selection_add=[('sms', 'SMS')]) + notification_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': 'set default'}) sms_template_id = fields.Many2one( 'sms.template', string='SMS Template', domain=[('model', '=', 'event.registration')], ondelete='restrict', @@ -21,7 +23,9 @@ def _get_event_mail_fields_whitelist(self): class EventMailScheduler(models.Model): _inherit = 'event.mail' - notification_type = fields.Selection(selection_add=[('sms', 'SMS')]) + notification_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': 'set default'}) sms_template_id = fields.Many2one( 'sms.template', string='SMS Template', domain=[('model', '=', 'event.registration')], ondelete='restrict', diff --git a/addons/hr/models/mail_alias.py b/addons/hr/models/mail_alias.py index 6a363221943b4..3d652142f687f 100644 --- a/addons/hr/models/mail_alias.py +++ b/addons/hr/models/mail_alias.py @@ -7,7 +7,9 @@ class Alias(models.Model): _inherit = 'mail.alias' - alias_contact = fields.Selection(selection_add=[('employees', 'Authenticated Employees')]) + alias_contact = fields.Selection(selection_add=[ + ('employees', 'Authenticated Employees'), + ], ondelete={'employees': 'cascade'}) def _get_alias_bounced_body_fallback(self, message_dict): if self.alias_contact == 'employees': diff --git a/addons/im_livechat_mail_bot/models/res_users.py b/addons/im_livechat_mail_bot/models/res_users.py index ceea8848a5848..2803dddd98e9c 100644 --- a/addons/im_livechat_mail_bot/models/res_users.py +++ b/addons/im_livechat_mail_bot/models/res_users.py @@ -6,7 +6,6 @@ class Users(models.Model): _inherit = 'res.users' - odoobot_state = fields.Selection( - selection_add=[ - ('onboarding_canned', 'Onboarding canned'), - ]) + odoobot_state = fields.Selection(selection_add=[ + ('onboarding_canned', 'Onboarding canned'), + ], ondelete={'onboarding_canned': 'set default'}) diff --git a/addons/l10n_be_invoice_bba/models/account_journal.py b/addons/l10n_be_invoice_bba/models/account_journal.py index e8cc09daf44a3..9ec4f408cbdbf 100644 --- a/addons/l10n_be_invoice_bba/models/account_journal.py +++ b/addons/l10n_be_invoice_bba/models/account_journal.py @@ -6,4 +6,6 @@ class AccountJournal(models.Model): _inherit = 'account.journal' - invoice_reference_model = fields.Selection(selection_add=[('be', 'Belgium')]) + invoice_reference_model = fields.Selection(selection_add=[ + ('be', 'Belgium') + ], ondelete={'be': lambda recs: recs.write({'invoice_reference_model': 'odoo'})}) diff --git a/addons/l10n_ch/models/account_journal.py b/addons/l10n_ch/models/account_journal.py index 9076a9f128d7b..f1bbb1bf5bba4 100644 --- a/addons/l10n_ch/models/account_journal.py +++ b/addons/l10n_ch/models/account_journal.py @@ -14,7 +14,9 @@ class AccountJournal(models.Model): # creation of bank journals by giving the account number, allow craetion of the l10n_ch_postal = fields.Char('Client Number', related='bank_account_id.l10n_ch_postal', readonly=False) - invoice_reference_model = fields.Selection(selection_add=[('ch', 'Switzerland')]) + invoice_reference_model = fields.Selection(selection_add=[ + ('ch', 'Switzerland') + ], ondelete={'ch': lambda recs: recs.write({'invoice_reference_model': 'odoo'})}) @api.model def create(self, vals): diff --git a/addons/l10n_no/models/account_journal.py b/addons/l10n_no/models/account_journal.py index b030052781d17..fd75a635dd9aa 100644 --- a/addons/l10n_no/models/account_journal.py +++ b/addons/l10n_no/models/account_journal.py @@ -7,4 +7,6 @@ class AccountJournal(models.Model): _inherit = 'account.journal' - invoice_reference_model = fields.Selection(selection_add=[('no', 'Norway')]) + invoice_reference_model = fields.Selection(selection_add=[ + ('no', 'Norway') + ], ondelete={'no': lambda recs: recs.write({'invoice_reference_model': 'odoo'})}) diff --git a/addons/mail/models/ir_action_act_window.py b/addons/mail/models/ir_action_act_window.py index f08c404bf13a1..b95068cce4a33 100644 --- a/addons/mail/models/ir_action_act_window.py +++ b/addons/mail/models/ir_action_act_window.py @@ -5,4 +5,6 @@ class ActWindowView(models.Model): _inherit = 'ir.actions.act_window.view' - view_mode = fields.Selection(selection_add=[('activity', 'Activity')]) + view_mode = fields.Selection(selection_add=[ + ('activity', 'Activity') + ], ondelete={'activity': 'cascade'}) diff --git a/addons/mail/models/ir_actions.py b/addons/mail/models/ir_actions.py index a9ad3c6cd2dd7..5c27db9a08a38 100644 --- a/addons/mail/models/ir_actions.py +++ b/addons/mail/models/ir_actions.py @@ -17,7 +17,7 @@ class ServerActions(models.Model): ('email', 'Send Email'), ('followers', 'Add Followers'), ('next_activity', 'Create Next Activity'), - ]) + ], ondelete={'email': 'cascade', 'followers': 'cascade', 'next_activity': 'cascade'}) # Followers partner_ids = fields.Many2many('res.partner', string='Add Followers') channel_ids = fields.Many2many('mail.channel', string='Add Channels') diff --git a/addons/mass_mailing_sms/models/mailing_mailing.py b/addons/mass_mailing_sms/models/mailing_mailing.py index 4024b957b1328..b33456aa26656 100644 --- a/addons/mass_mailing_sms/models/mailing_mailing.py +++ b/addons/mass_mailing_sms/models/mailing_mailing.py @@ -21,7 +21,9 @@ def default_get(self, fields): return res # mailing options - mailing_type = fields.Selection(selection_add=[('sms', 'SMS')]) + mailing_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': 'set default'}) # sms options body_plaintext = fields.Text('SMS Body', compute='_compute_body_plaintext', store=True, readonly=False) sms_template_id = fields.Many2one('sms.template', string='SMS Template', ondelete='set null') diff --git a/addons/mass_mailing_sms/models/mailing_trace.py b/addons/mass_mailing_sms/models/mailing_trace.py index f9d22f823e457..386ffb9bf4abe 100644 --- a/addons/mass_mailing_sms/models/mailing_trace.py +++ b/addons/mass_mailing_sms/models/mailing_trace.py @@ -14,7 +14,9 @@ class MailingTrace(models.Model): _inherit = 'mailing.trace' CODE_SIZE = 3 - trace_type = fields.Selection(selection_add=[('sms', 'SMS')]) + trace_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': 'set default'}) sms_sms_id = fields.Many2one('sms.sms', string='SMS', index=True, ondelete='set null') sms_sms_id_int = fields.Integer( string='SMS ID (tech)', diff --git a/addons/mrp/models/stock_picking.py b/addons/mrp/models/stock_picking.py index b3d2c1f671b1a..62f1d5f877d81 100644 --- a/addons/mrp/models/stock_picking.py +++ b/addons/mrp/models/stock_picking.py @@ -7,7 +7,9 @@ class StockPickingType(models.Model): _inherit = 'stock.picking.type' - code = fields.Selection(selection_add=[('mrp_operation', 'Manufacturing')]) + code = fields.Selection(selection_add=[ + ('mrp_operation', 'Manufacturing') + ], ondelete={'mrp_operation': 'cascade'}) count_mo_todo = fields.Integer(string="Number of Manufacturing Orders to Process", compute='_get_mo_count') count_mo_waiting = fields.Integer(string="Number of Manufacturing Orders Waiting", diff --git a/addons/mrp/models/stock_rule.py b/addons/mrp/models/stock_rule.py index c08e2ab2015db..132711287f099 100644 --- a/addons/mrp/models/stock_rule.py +++ b/addons/mrp/models/stock_rule.py @@ -11,7 +11,9 @@ class StockRule(models.Model): _inherit = 'stock.rule' - action = fields.Selection(selection_add=[('manufacture', 'Manufacture')]) + action = fields.Selection(selection_add=[ + ('manufacture', 'Manufacture') + ], ondelete={'manufacture': 'cascade'}) def _get_message_dict(self): message_dict = super(StockRule, self)._get_message_dict() diff --git a/addons/mrp_landed_costs/models/stock_landed_cost.py b/addons/mrp_landed_costs/models/stock_landed_cost.py index 3e193e39c3cf6..5d991f8c78825 100644 --- a/addons/mrp_landed_costs/models/stock_landed_cost.py +++ b/addons/mrp_landed_costs/models/stock_landed_cost.py @@ -7,7 +7,9 @@ class StockLandedCost(models.Model): _inherit = 'stock.landed.cost' - target_model = fields.Selection(selection_add=[('manufacturing', "Manufacturing Orders")]) + target_model = fields.Selection(selection_add=[ + ('manufacturing', "Manufacturing Orders") + ], ondelete={'manufacturing': 'set default'}) mrp_production_ids = fields.Many2many( 'mrp.production', string='Manufacturing order', copy=False, states={'done': [('readonly', True)]}, groups='mrp.group_mrp_user') diff --git a/addons/mrp_subcontracting/models/mrp_bom.py b/addons/mrp_subcontracting/models/mrp_bom.py index e8ada6e16f526..00576ff52723c 100644 --- a/addons/mrp_subcontracting/models/mrp_bom.py +++ b/addons/mrp_subcontracting/models/mrp_bom.py @@ -7,7 +7,9 @@ class MrpBom(models.Model): _inherit = 'mrp.bom' - type = fields.Selection(selection_add=[('subcontract', 'Subcontracting')]) + type = fields.Selection(selection_add=[ + ('subcontract', 'Subcontracting') + ], ondelete={'subcontract': lambda recs: recs.write({'type': 'normal', 'active': False})}) subcontractor_ids = fields.Many2many('res.partner', 'mrp_bom_subcontractor', string='Subcontractors', check_company=True) def _bom_subcontract_find(self, product_tmpl=None, product=None, picking_type=None, company_id=False, bom_type='subcontract', subcontractor=False): diff --git a/addons/payment_adyen/models/payment.py b/addons/payment_adyen/models/payment.py index b1dce04c050ac..7a5388fab8980 100644 --- a/addons/payment_adyen/models/payment.py +++ b/addons/payment_adyen/models/payment.py @@ -47,7 +47,9 @@ class AcquirerAdyen(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('adyen', 'Adyen')]) + provider = fields.Selection(selection_add=[ + ('adyen', 'Adyen') + ], ondelete={'adyen': 'set default'}) adyen_merchant_account = fields.Char('Merchant Account', required_if_provider='adyen', groups='base.group_user') adyen_skin_code = fields.Char('Skin Code', required_if_provider='adyen', groups='base.group_user') adyen_skin_hmac_key = fields.Char('Skin HMAC Key', required_if_provider='adyen', groups='base.group_user') diff --git a/addons/payment_alipay/models/payment.py b/addons/payment_alipay/models/payment.py index e615fe9e36d41..4be338cf39754 100644 --- a/addons/payment_alipay/models/payment.py +++ b/addons/payment_alipay/models/payment.py @@ -17,7 +17,9 @@ class PaymentAcquirer(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('alipay', 'Alipay')]) + provider = fields.Selection(selection_add=[ + ('alipay', 'Alipay') + ], ondelete={'alipay': 'set default'}) alipay_payment_method = fields.Selection([ ('express_checkout', 'Express Checkout (only for Chinese Merchant)'), ('standard_checkout', 'Cross-border'), diff --git a/addons/payment_authorize/models/payment.py b/addons/payment_authorize/models/payment.py index d6e08fda0e58e..3c89c36b5da22 100644 --- a/addons/payment_authorize/models/payment.py +++ b/addons/payment_authorize/models/payment.py @@ -19,7 +19,9 @@ class PaymentAcquirerAuthorize(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('authorize', 'Authorize.Net')]) + provider = fields.Selection(selection_add=[ + ('authorize', 'Authorize.Net') + ], ondelete={'authorize': 'set default'}) authorize_login = fields.Char(string='API Login Id', required_if_provider='authorize', groups='base.group_user') authorize_transaction_key = fields.Char(string='API Transaction Key', required_if_provider='authorize', groups='base.group_user') authorize_signature_key = fields.Char(string='API Signature Key', required_if_provider='authorize', groups='base.group_user') diff --git a/addons/payment_buckaroo/models/payment.py b/addons/payment_buckaroo/models/payment.py index 67ceb82a451a2..8689cf5f2ba5b 100644 --- a/addons/payment_buckaroo/models/payment.py +++ b/addons/payment_buckaroo/models/payment.py @@ -26,7 +26,9 @@ def normalize_keys_upper(data): class AcquirerBuckaroo(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('buckaroo', 'Buckaroo')]) + provider = fields.Selection(selection_add=[ + ('buckaroo', 'Buckaroo') + ], ondelete={'buckaroo': 'set default'}) brq_websitekey = fields.Char('WebsiteKey', required_if_provider='buckaroo', groups='base.group_user') brq_secretkey = fields.Char('SecretKey', required_if_provider='buckaroo', groups='base.group_user') diff --git a/addons/payment_ingenico/models/payment.py b/addons/payment_ingenico/models/payment.py index 2e719ce033c0c..6076088aec1ad 100644 --- a/addons/payment_ingenico/models/payment.py +++ b/addons/payment_ingenico/models/payment.py @@ -25,7 +25,9 @@ class PaymentAcquirerOgone(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('ogone', 'Ingenico')]) + provider = fields.Selection(selection_add=[ + ('ogone', 'Ingenico') + ], ondelete={'ogone': 'set default'}) ogone_pspid = fields.Char('PSPID', required_if_provider='ogone', groups='base.group_user') ogone_userid = fields.Char('API User ID', required_if_provider='ogone', groups='base.group_user') ogone_password = fields.Char('API User Password', required_if_provider='ogone', groups='base.group_user') diff --git a/addons/payment_paypal/models/payment.py b/addons/payment_paypal/models/payment.py index f3b99925c8517..d947c3a8c92a2 100644 --- a/addons/payment_paypal/models/payment.py +++ b/addons/payment_paypal/models/payment.py @@ -19,7 +19,9 @@ class AcquirerPaypal(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('paypal', 'Paypal')]) + provider = fields.Selection(selection_add=[ + ('paypal', 'Paypal') + ], ondelete={'paypal': 'set default'}) paypal_email_account = fields.Char('Email', required_if_provider='paypal', groups='base.group_user') paypal_seller_account = fields.Char( 'Merchant Account ID', groups='base.group_user', diff --git a/addons/payment_payulatam/models/payment.py b/addons/payment_payulatam/models/payment.py index db063f2ce5dd4..958a977ee1b30 100644 --- a/addons/payment_payulatam/models/payment.py +++ b/addons/payment_payulatam/models/payment.py @@ -18,7 +18,9 @@ class PaymentAcquirerPayulatam(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('payulatam', 'PayU Latam')]) + provider = fields.Selection(selection_add=[ + ('payulatam', 'PayU Latam') + ], ondelete={'payulatam': 'set default'}) payulatam_merchant_id = fields.Char(string="PayU Latam Merchant ID", required_if_provider='payulatam', groups='base.group_user') payulatam_account_id = fields.Char(string="PayU Latam Account ID", required_if_provider='payulatam', groups='base.group_user') payulatam_api_key = fields.Char(string="PayU Latam API Key", required_if_provider='payulatam', groups='base.group_user') diff --git a/addons/payment_payumoney/models/payment.py b/addons/payment_payumoney/models/payment.py index 5fafad61657ac..39bbc23dbd265 100644 --- a/addons/payment_payumoney/models/payment.py +++ b/addons/payment_payumoney/models/payment.py @@ -17,7 +17,9 @@ class PaymentAcquirerPayumoney(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('payumoney', 'PayUmoney')]) + provider = fields.Selection(selection_add=[ + ('payumoney', 'PayUmoney') + ], ondelete={'payumoney': 'set default'}) payumoney_merchant_key = fields.Char(string='Merchant Key', required_if_provider='payumoney', groups='base.group_user') payumoney_merchant_salt = fields.Char(string='Merchant Salt', required_if_provider='payumoney', groups='base.group_user') diff --git a/addons/payment_sips/models/payment.py b/addons/payment_sips/models/payment.py index fafea220e7553..ff651a78362f8 100644 --- a/addons/payment_sips/models/payment.py +++ b/addons/payment_sips/models/payment.py @@ -43,7 +43,9 @@ class AcquirerSips(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('sips', 'Sips')]) + provider = fields.Selection(selection_add=[ + ('sips', 'Sips') + ], ondelete={'sips': 'set default'}) sips_merchant_id = fields.Char('Merchant ID', help="Used for production only", required_if_provider='sips', groups='base.group_user') sips_secret = fields.Char('Secret Key', size=64, required_if_provider='sips', groups='base.group_user') sips_test_url = fields.Char("Test url", required_if_provider='sips', default='https://payment-webinit.simu.sips-atos.com/paymentInit') diff --git a/addons/payment_stripe/models/payment.py b/addons/payment_stripe/models/payment.py index 54441a1a47533..81b553587dd97 100644 --- a/addons/payment_stripe/models/payment.py +++ b/addons/payment_stripe/models/payment.py @@ -24,7 +24,9 @@ class PaymentAcquirerStripe(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('stripe', 'Stripe')]) + provider = fields.Selection(selection_add=[ + ('stripe', 'Stripe') + ], ondelete={'stripe': 'set default'}) stripe_secret_key = fields.Char(required_if_provider='stripe', groups='base.group_user') stripe_publishable_key = fields.Char(required_if_provider='stripe', groups='base.group_user') stripe_image_url = fields.Char( diff --git a/addons/payment_test/models/payment_acquirer.py b/addons/payment_test/models/payment_acquirer.py index 7d816f4f555cb..c569c7a1f072a 100644 --- a/addons/payment_test/models/payment_acquirer.py +++ b/addons/payment_test/models/payment_acquirer.py @@ -10,7 +10,9 @@ class PaymentAcquirerTest(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('test', 'Test')]) + provider = fields.Selection(selection_add=[ + ('test', 'Test') + ], ondelete={'test': 'set default'}) @api.model def create(self, values): diff --git a/addons/payment_transfer/models/payment.py b/addons/payment_transfer/models/payment.py index 4f51f2cf1173f..b748fa503494c 100644 --- a/addons/payment_transfer/models/payment.py +++ b/addons/payment_transfer/models/payment.py @@ -13,7 +13,9 @@ class TransferPaymentAcquirer(models.Model): _inherit = 'payment.acquirer' - provider = fields.Selection(selection_add=[('transfer', 'Manual Payment')], default='transfer') + provider = fields.Selection(selection_add=[ + ('transfer', 'Manual Payment') + ], default='transfer', ondelete={'transfer': 'set default'}) @api.model def _create_missing_journal_for_acquirers(self, company=None): diff --git a/addons/point_of_sale/models/barcode_rule.py b/addons/point_of_sale/models/barcode_rule.py index 5e50598300657..e9b67a515823e 100644 --- a/addons/point_of_sale/models/barcode_rule.py +++ b/addons/point_of_sale/models/barcode_rule.py @@ -9,9 +9,15 @@ class BarcodeRule(models.Model): _inherit = 'barcode.rule' type = fields.Selection(selection_add=[ - ('weight', 'Weighted Product'), - ('price', 'Priced Product'), - ('discount', 'Discounted Product'), - ('client', 'Client'), - ('cashier', 'Cashier') - ]) + ('weight', 'Weighted Product'), + ('price', 'Priced Product'), + ('discount', 'Discounted Product'), + ('client', 'Client'), + ('cashier', 'Cashier') + ], ondelete={ + 'weight': 'set default', + 'price': 'set default', + 'discount': 'set default', + 'client': 'set default', + 'cashier': 'set default', + }) diff --git a/addons/pos_mercury/models/pos_mercury.py b/addons/pos_mercury/models/pos_mercury.py index cfac776876ceb..a95dba493d6eb 100644 --- a/addons/pos_mercury/models/pos_mercury.py +++ b/addons/pos_mercury/models/pos_mercury.py @@ -14,7 +14,7 @@ class BarcodeRule(models.Model): type = fields.Selection(selection_add=[ ('credit', 'Credit Card') - ]) + ], ondelete={'credit': 'set default'}) class PosMercuryConfiguration(models.Model): diff --git a/addons/purchase_stock/models/stock_rule.py b/addons/purchase_stock/models/stock_rule.py index a102726dece12..2fbabfe79ca88 100644 --- a/addons/purchase_stock/models/stock_rule.py +++ b/addons/purchase_stock/models/stock_rule.py @@ -13,7 +13,9 @@ class StockRule(models.Model): _inherit = 'stock.rule' - action = fields.Selection(selection_add=[('buy', 'Buy')]) + action = fields.Selection(selection_add=[ + ('buy', 'Buy') + ], ondelete={'buy': 'cascade'}) def _get_message_dict(self): message_dict = super(StockRule, self)._get_message_dict() diff --git a/addons/sale_coupon_delivery/__init__.py b/addons/sale_coupon_delivery/__init__.py index 03e0428dae587..be9f4fab00ae2 100644 --- a/addons/sale_coupon_delivery/__init__.py +++ b/addons/sale_coupon_delivery/__init__.py @@ -1,12 +1,3 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -from odoo import api, SUPERUSER_ID - from . import models - - -def uninstall_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) - env['delivery.carrier'].search([ - ('delivery_type', '=', 'temando') - ]).write({'delivery_type': 'fixed', 'fixed_price': 0}) diff --git a/addons/sale_timesheet/__init__.py b/addons/sale_timesheet/__init__.py index 154c2b71150ab..7d7e07d0b8c53 100644 --- a/addons/sale_timesheet/__init__.py +++ b/addons/sale_timesheet/__init__.py @@ -1,18 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. - -from odoo import api, SUPERUSER_ID - from . import controllers from . import models from . import wizard from . import report - -def uninstall_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) - env['product.template'].search([ - ('service_type', '=', 'timesheet') - ]).write({'service_type': 'manual'}) - env['product.product'].search([ - ('service_type', '=', 'timesheet') - ]).write({'service_type': 'manual'}) diff --git a/addons/sale_timesheet/__manifest__.py b/addons/sale_timesheet/__manifest__.py index 63c503ec8c72d..55ca50305e5d4 100644 --- a/addons/sale_timesheet/__manifest__.py +++ b/addons/sale_timesheet/__manifest__.py @@ -37,5 +37,4 @@ 'data/sale_service_demo.xml', ], 'auto_install': True, - 'uninstall_hook': 'uninstall_hook', } diff --git a/addons/sale_timesheet/models/product.py b/addons/sale_timesheet/models/product.py index d1a4d83d307b8..3ae044c7c91bf 100644 --- a/addons/sale_timesheet/models/product.py +++ b/addons/sale_timesheet/models/product.py @@ -14,7 +14,7 @@ class ProductTemplate(models.Model): ], string="Service Invoicing Policy", compute='_compute_service_policy', inverse='_inverse_service_policy') service_type = fields.Selection(selection_add=[ ('timesheet', 'Timesheets on project (one fare per SO/Project)'), - ]) + ], ondelete={'timesheet': 'set default'}) # override domain project_id = fields.Many2one(domain="[('billable_type', '=', 'no'), ('allow_timesheets', 'in', [service_policy == 'delivered_timesheet' or '', True])]") project_template_id = fields.Many2one(domain="[('billable_type', '=', 'no'), ('allow_timesheets', 'in', [service_policy == 'delivered_timesheet' or '', True])]") diff --git a/addons/sms/models/ir_actions.py b/addons/sms/models/ir_actions.py index 85869761e5742..e5421d4546cf1 100644 --- a/addons/sms/models/ir_actions.py +++ b/addons/sms/models/ir_actions.py @@ -12,7 +12,7 @@ class ServerActions(models.Model): state = fields.Selection(selection_add=[ ('sms', 'Send SMS Text Message'), - ]) + ], ondelete={'sms': 'cascade'}) # SMS sms_template_id = fields.Many2one( 'sms.template', 'SMS Template', ondelete='set null', diff --git a/addons/sms/models/mail_message.py b/addons/sms/models/mail_message.py index 10e9ffab73ba8..dbc0a78cd7545 100644 --- a/addons/sms/models/mail_message.py +++ b/addons/sms/models/mail_message.py @@ -14,7 +14,9 @@ class MailMessage(models.Model): gateway. """ _inherit = 'mail.message' - message_type = fields.Selection(selection_add=[('sms', 'SMS')]) + message_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': lambda recs: recs.write({'message_type': 'email'})}) has_sms_error = fields.Boolean( 'Has SMS error', compute='_compute_has_sms_error', search='_search_has_sms_error', help='Has error') diff --git a/addons/sms/models/mail_notification.py b/addons/sms/models/mail_notification.py index c45981ea0b08f..3e00399fcc3dd 100644 --- a/addons/sms/models/mail_notification.py +++ b/addons/sms/models/mail_notification.py @@ -7,7 +7,9 @@ class Notification(models.Model): _inherit = 'mail.notification' - notification_type = fields.Selection(selection_add=[('sms', 'SMS')]) + notification_type = fields.Selection(selection_add=[ + ('sms', 'SMS') + ], ondelete={'sms': 'set default'}) sms_id = fields.Many2one('sms.sms', string='SMS', index=True, ondelete='set null') sms_number = fields.Char('SMS Number') failure_type = fields.Selection(selection_add=[ diff --git a/addons/snailmail/models/mail_message.py b/addons/snailmail/models/mail_message.py index 38364f75590ac..94284fd99a790 100644 --- a/addons/snailmail/models/mail_message.py +++ b/addons/snailmail/models/mail_message.py @@ -7,7 +7,9 @@ class Message(models.Model): snailmail_error = fields.Boolean("Snailmail message in error", compute="_compute_snailmail_error", search="_search_snailmail_error") snailmail_status = fields.Char("Snailmail Status", compute="_compute_snailmail_error") letter_ids = fields.One2many(comodel_name='snailmail.letter', inverse_name='message_id') - message_type = fields.Selection(selection_add=[('snailmail', 'Snailmail')]) + message_type = fields.Selection(selection_add=[ + ('snailmail', 'Snailmail') + ], ondelete={'snailmail': lambda recs: recs.write({'message_type': 'email'})}) def _get_message_format_fields(self): res = super(Message, self)._get_message_format_fields() diff --git a/addons/stock/__init__.py b/addons/stock/__init__.py index 9d7a09cb88c3f..f912d4ed8fa50 100644 --- a/addons/stock/__init__.py +++ b/addons/stock/__init__.py @@ -28,12 +28,3 @@ def _assign_default_mail_template_picking_id(cr, registry): company_ids_without_default_mail_template_id.write({ 'stock_mail_confirmation_template_id': default_mail_template_id.id, }) - - -def uninstall_hook(cr, registry): - env = api.Environment(cr, SUPERUSER_ID, {}) - default = env['product.template']._fields['type'].default(env['product.template']) - # stock introduces an option on the `type` Selection field of `product.template` - # if this module is uninstalled and any `product.template` record still points to this option - # the registry will find itself in an unstable state and will most likely crash (eventually) - cr.execute("UPDATE product_template SET type = %s WHERE type = %s", (default, 'product')) diff --git a/addons/stock/__manifest__.py b/addons/stock/__manifest__.py index 5513c5e791133..9b17dd03f5192 100644 --- a/addons/stock/__manifest__.py +++ b/addons/stock/__manifest__.py @@ -88,5 +88,4 @@ 'auto_install': False, 'pre_init_hook': 'pre_init_hook', 'post_init_hook': '_assign_default_mail_template_picking_id', - 'uninstall_hook': 'uninstall_hook', } diff --git a/addons/stock/models/barcode.py b/addons/stock/models/barcode.py index 61b8a31dbc08b..e81afcfe60799 100644 --- a/addons/stock/models/barcode.py +++ b/addons/stock/models/barcode.py @@ -8,8 +8,13 @@ class BarcodeRule(models.Model): _inherit = 'barcode.rule' type = fields.Selection(selection_add=[ - ('weight', 'Weighted Product'), - ('location', 'Location'), - ('lot', 'Lot'), - ('package', 'Package') - ]) + ('weight', 'Weighted Product'), + ('location', 'Location'), + ('lot', 'Lot'), + ('package', 'Package') + ], ondelete={ + 'weight': 'set default', + 'location': 'set default', + 'lot': 'set default', + 'package': 'set default', + }) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 79173dbe6b268..4158b86d84ad6 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -537,7 +537,9 @@ class ProductTemplate(models.Model): responsible_id = fields.Many2one( 'res.users', string='Responsible', default=lambda self: self.env.uid, company_dependent=True, check_company=True, help="This user will be responsible of the next activities related to logistic operations for this product.") - type = fields.Selection(selection_add=[('product', 'Storable Product')], tracking=True) + type = fields.Selection(selection_add=[ + ('product', 'Storable Product') + ], tracking=True, ondelete={'product': 'set default'}) property_stock_production = fields.Many2one( 'stock.location', "Production Location", company_dependent=True, check_company=True, domain="[('usage', '=', 'production'), '|', ('company_id', '=', False), ('company_id', '=', allowed_company_ids[0])]", diff --git a/addons/survey/models/challenge.py b/addons/survey/models/challenge.py index b4cd4626b911c..23b54c16ce700 100644 --- a/addons/survey/models/challenge.py +++ b/addons/survey/models/challenge.py @@ -7,4 +7,6 @@ class Challenge(models.Model): _inherit = 'gamification.challenge' - challenge_category = fields.Selection(selection_add=[('certification', 'Certifications')]) + challenge_category = fields.Selection(selection_add=[ + ('certification', 'Certifications') + ], ondelete={'certification': 'set default'}) diff --git a/addons/web/models/models.py b/addons/web/models/models.py index 7f6e83554e327..bb9a865f16179 100644 --- a/addons/web/models/models.py +++ b/addons/web/models/models.py @@ -14,7 +14,9 @@ class IrActionsActWindowView(models.Model): _inherit = 'ir.actions.act_window.view' - view_mode = fields.Selection(selection_add=[('qweb', 'QWeb')]) + view_mode = fields.Selection(selection_add=[ + ('qweb', 'QWeb') + ], ondelete={'qweb': 'cascade'}) class Base(models.AbstractModel): diff --git a/addons/website_forum/models/gamification.py b/addons/website_forum/models/gamification.py index 902b5e0eab9b1..1f7d758ea3eda 100644 --- a/addons/website_forum/models/gamification.py +++ b/addons/website_forum/models/gamification.py @@ -7,4 +7,6 @@ class Challenge(models.Model): _inherit = 'gamification.challenge' - challenge_category = fields.Selection(selection_add=[('forum', 'Website / Forum')]) + challenge_category = fields.Selection(selection_add=[ + ('forum', 'Website / Forum') + ], ondelete={'forum': 'set default'}) diff --git a/addons/website_sale_slides/models/slide_channel.py b/addons/website_sale_slides/models/slide_channel.py index bb95e2e0ab564..ee288fb8b64e3 100644 --- a/addons/website_sale_slides/models/slide_channel.py +++ b/addons/website_sale_slides/models/slide_channel.py @@ -7,7 +7,9 @@ class Channel(models.Model): _inherit = 'slide.channel' - enroll = fields.Selection(selection_add=[('payment', 'On payment')]) + enroll = fields.Selection(selection_add=[ + ('payment', 'On payment') + ], ondelete={'payment': lambda recs: recs.write({'enroll': 'invite'})}) product_id = fields.Many2one('product.product', 'Product', index=True) product_sale_revenues = fields.Monetary( string='Total revenues', compute='_compute_product_sale_revenues', diff --git a/addons/website_slides/models/gamification_challenge.py b/addons/website_slides/models/gamification_challenge.py index f1346f7ddabb5..7bb7f498ec433 100644 --- a/addons/website_slides/models/gamification_challenge.py +++ b/addons/website_slides/models/gamification_challenge.py @@ -7,4 +7,6 @@ class Challenge(models.Model): _inherit = 'gamification.challenge' - challenge_category = fields.Selection(selection_add=[('slides', 'Website / Slides')]) + challenge_category = fields.Selection(selection_add=[ + ('slides', 'Website / Slides') + ], ondelete={'slides': 'set default'}) diff --git a/addons/website_slides_survey/models/slide_slide.py b/addons/website_slides_survey/models/slide_slide.py index 26b79394c5850..76e1453eb7a80 100644 --- a/addons/website_slides_survey/models/slide_slide.py +++ b/addons/website_slides_survey/models/slide_slide.py @@ -38,7 +38,9 @@ def _write(self, vals): class Slide(models.Model): _inherit = 'slide.slide' - slide_type = fields.Selection(selection_add=[('certification', 'Certification')]) + slide_type = fields.Selection(selection_add=[ + ('certification', 'Certification') + ], ondelete={'certification': 'set default'}) survey_id = fields.Many2one('survey.survey', 'Certification') nbr_certification = fields.Integer("Number of Certifications", compute='_compute_slides_statistics', store=True)