summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/account_tax_python/__init__.py13
-rw-r--r--addons/account_tax_python/__manifest__.py1
-rw-r--r--addons/account_tax_python/models/account_tax.py8
-rw-r--r--addons/base_automation/models/ir_actions.py4
-rw-r--r--addons/base_sparse_field/models/models.py4
-rw-r--r--addons/calendar_sms/models/calendar.py4
-rw-r--r--addons/crm/wizard/crm_lead_to_opportunity_mass.py4
-rw-r--r--addons/delivery/models/delivery_grid.py6
-rw-r--r--addons/event_sms/models/event_mail.py8
-rw-r--r--addons/hr/models/mail_alias.py4
-rw-r--r--addons/im_livechat_mail_bot/models/res_users.py7
-rw-r--r--addons/l10n_be_invoice_bba/models/account_journal.py4
-rw-r--r--addons/l10n_ch/models/account_journal.py4
-rw-r--r--addons/l10n_no/models/account_journal.py4
-rw-r--r--addons/mail/models/ir_action_act_window.py4
-rw-r--r--addons/mail/models/ir_actions.py2
-rw-r--r--addons/mass_mailing_sms/models/mailing_mailing.py4
-rw-r--r--addons/mass_mailing_sms/models/mailing_trace.py4
-rw-r--r--addons/mrp/models/stock_picking.py4
-rw-r--r--addons/mrp/models/stock_rule.py4
-rw-r--r--addons/mrp_landed_costs/models/stock_landed_cost.py4
-rw-r--r--addons/mrp_subcontracting/models/mrp_bom.py4
-rw-r--r--addons/payment_adyen/models/payment.py4
-rw-r--r--addons/payment_alipay/models/payment.py4
-rw-r--r--addons/payment_authorize/models/payment.py4
-rw-r--r--addons/payment_buckaroo/models/payment.py4
-rw-r--r--addons/payment_ingenico/models/payment.py4
-rw-r--r--addons/payment_paypal/models/payment.py4
-rw-r--r--addons/payment_payulatam/models/payment.py4
-rw-r--r--addons/payment_payumoney/models/payment.py4
-rw-r--r--addons/payment_sips/models/payment.py4
-rw-r--r--addons/payment_stripe/models/payment.py4
-rw-r--r--addons/payment_test/models/payment_acquirer.py4
-rw-r--r--addons/payment_transfer/models/payment.py4
-rw-r--r--addons/point_of_sale/models/barcode_rule.py18
-rw-r--r--addons/pos_mercury/models/pos_mercury.py2
-rw-r--r--addons/purchase_stock/models/stock_rule.py4
-rw-r--r--addons/sale_coupon_delivery/__init__.py9
-rw-r--r--addons/sale_timesheet/__init__.py12
-rw-r--r--addons/sale_timesheet/__manifest__.py1
-rw-r--r--addons/sale_timesheet/models/product.py2
-rw-r--r--addons/sms/models/ir_actions.py2
-rw-r--r--addons/sms/models/mail_message.py4
-rw-r--r--addons/sms/models/mail_notification.py4
-rw-r--r--addons/snailmail/models/mail_message.py4
-rw-r--r--addons/stock/__init__.py9
-rw-r--r--addons/stock/__manifest__.py1
-rw-r--r--addons/stock/models/barcode.py15
-rw-r--r--addons/stock/models/product.py4
-rw-r--r--addons/survey/models/challenge.py4
-rw-r--r--addons/web/models/models.py4
-rw-r--r--addons/website_forum/models/gamification.py4
-rw-r--r--addons/website_sale_slides/models/slide_channel.py4
-rw-r--r--addons/website_slides/models/gamification_challenge.py4
-rw-r--r--addons/website_slides_survey/models/slide_slide.py4
55 files changed, 160 insertions, 108 deletions
diff --git a/addons/account_tax_python/__init__.py b/addons/account_tax_python/__init__.py
index 3b46f4dba2b..dc5e6b693d1 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 cb0dde674a5..e27facde6aa 100644
--- a/addons/account_tax_python/__manifest__.py
+++ b/addons/account_tax_python/__manifest__.py
@@ -17,5 +17,4 @@ A tax defined as python code consists of two snippets of python code which are e
'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 dbd143a58b5..435be47fa9c 100644
--- a/addons/account_tax_python/models/account_tax.py
+++ b/addons/account_tax_python/models/account_tax.py
@@ -8,7 +8,9 @@ from odoo.tools.safe_eval import safe_eval
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 @@ class AccountTaxPython(models.Model):
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 67e75872873..0cf9263c637 100644
--- a/addons/base_automation/models/ir_actions.py
+++ b/addons/base_automation/models/ir_actions.py
@@ -7,4 +7,6 @@ from odoo import fields, models
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 cc886e808d8..6947a2d1202 100644
--- a/addons/base_sparse_field/models/models.py
+++ b/addons/base_sparse_field/models/models.py
@@ -7,7 +7,9 @@ from odoo.exceptions import UserError
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 1bfccfe7521..815a93c86d0 100644
--- a/addons/calendar_sms/models/calendar.py
+++ b/addons/calendar_sms/models/calendar.py
@@ -31,7 +31,9 @@ class CalendarEvent(models.Model):
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 f33abf83ea9..2433c9e474e 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 @@ class Lead2OpportunityMassConvert(models.TransientModel):
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 bbfc0560a9c..5cef40ac210 100644
--- a/addons/delivery/models/delivery_grid.py
+++ b/addons/delivery/models/delivery_grid.py
@@ -38,7 +38,11 @@ class PriceRule(models.Model):
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 14d43ec1373..53562875f10 100644
--- a/addons/event_sms/models/event_mail.py
+++ b/addons/event_sms/models/event_mail.py
@@ -7,7 +7,9 @@ from odoo import api, fields, models
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 @@ class EventTypeMail(models.Model):
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 6a363221943..3d652142f68 100644
--- a/addons/hr/models/mail_alias.py
+++ b/addons/hr/models/mail_alias.py
@@ -7,7 +7,9 @@ from odoo import fields, models, tools, _
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 ceea8848a58..2803dddd98e 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 @@ from odoo import models, fields
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 e8cc09daf44..9ec4f408cbd 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 @@ from odoo import fields, models
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 9076a9f128d..f1bbb1bf5bb 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 b030052781d..fd75a635dd9 100644
--- a/addons/l10n_no/models/account_journal.py
+++ b/addons/l10n_no/models/account_journal.py
@@ -7,4 +7,6 @@ from odoo import fields, models
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 f08c404bf13..b95068cce4a 100644
--- a/addons/mail/models/ir_action_act_window.py
+++ b/addons/mail/models/ir_action_act_window.py
@@ -5,4 +5,6 @@ from odoo import fields, models
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 a9ad3c6cd2d..5c27db9a08a 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 4024b957b13..b33456aa266 100644
--- a/addons/mass_mailing_sms/models/mailing_mailing.py
+++ b/addons/mass_mailing_sms/models/mailing_mailing.py
@@ -21,7 +21,9 @@ class Mailing(models.Model):
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 f9d22f823e4..386ffb9bf4a 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 b3d2c1f671b..62f1d5f877d 100644
--- a/addons/mrp/models/stock_picking.py
+++ b/addons/mrp/models/stock_picking.py
@@ -7,7 +7,9 @@ from odoo import fields, models
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 c08e2ab2015..132711287f0 100644
--- a/addons/mrp/models/stock_rule.py
+++ b/addons/mrp/models/stock_rule.py
@@ -11,7 +11,9 @@ from odoo.addons.stock.models.stock_rule import ProcurementException
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 3e193e39c3c..5d991f8c788 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 @@ from odoo import fields, models, api
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 e8ada6e16f5..00576ff5272 100644
--- a/addons/mrp_subcontracting/models/mrp_bom.py
+++ b/addons/mrp_subcontracting/models/mrp_bom.py
@@ -7,7 +7,9 @@ from odoo.osv.expression import AND
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 b1dce04c050..7a5388fab89 100644
--- a/addons/payment_adyen/models/payment.py
+++ b/addons/payment_adyen/models/payment.py
@@ -47,7 +47,9 @@ CURRENCY_CODE_MAPS = {
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 e615fe9e36d..4be338cf397 100644
--- a/addons/payment_alipay/models/payment.py
+++ b/addons/payment_alipay/models/payment.py
@@ -17,7 +17,9 @@ _logger = logging.getLogger(__name__)
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 d6e08fda0e5..3c89c36b5da 100644
--- a/addons/payment_authorize/models/payment.py
+++ b/addons/payment_authorize/models/payment.py
@@ -19,7 +19,9 @@ _logger = logging.getLogger(__name__)
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 67ceb82a451..8689cf5f2ba 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 2e719ce033c..6076088aec1 100644
--- a/addons/payment_ingenico/models/payment.py
+++ b/addons/payment_ingenico/models/payment.py
@@ -25,7 +25,9 @@ _logger = logging.getLogger(__name__)
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 f3b99925c85..d947c3a8c92 100644
--- a/addons/payment_paypal/models/payment.py
+++ b/addons/payment_paypal/models/payment.py
@@ -19,7 +19,9 @@ _logger = logging.getLogger(__name__)
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 db063f2ce5d..958a977ee1b 100644
--- a/addons/payment_payulatam/models/payment.py
+++ b/addons/payment_payulatam/models/payment.py
@@ -18,7 +18,9 @@ _logger = logging.getLogger(__name__)
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 5fafad61657..39bbc23dbd2 100644
--- a/addons/payment_payumoney/models/payment.py
+++ b/addons/payment_payumoney/models/payment.py
@@ -17,7 +17,9 @@ _logger = logging.getLogger(__name__)
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 fafea220e75..ff651a78362 100644
--- a/addons/payment_sips/models/payment.py
+++ b/addons/payment_sips/models/payment.py
@@ -43,7 +43,9 @@ CURRENCY_CODES = {
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 54441a1a475..81b553587dd 100644
--- a/addons/payment_stripe/models/payment.py
+++ b/addons/payment_stripe/models/payment.py
@@ -24,7 +24,9 @@ INT_CURRENCIES = [
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 7d816f4f555..c569c7a1f07 100644
--- a/addons/payment_test/models/payment_acquirer.py
+++ b/addons/payment_test/models/payment_acquirer.py
@@ -10,7 +10,9 @@ from odoo import api, exceptions, fields, models, _
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 4f51f2cf117..b748fa50349 100644
--- a/addons/payment_transfer/models/payment.py
+++ b/addons/payment_transfer/models/payment.py
@@ -13,7 +13,9 @@ _logger = logging.getLogger(__name__)
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 5e505983006..e9b67a51582 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 cfac776876c..a95dba493d6 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 a102726dece..2fbabfe79ca 100644
--- a/addons/purchase_stock/models/stock_rule.py
+++ b/addons/purchase_stock/models/stock_rule.py
@@ -13,7 +13,9 @@ from odoo.addons.stock.models.stock_rule import ProcurementException
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 03e0428dae5..be9f4fab00a 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 154c2b71150..7d7e07d0b8c 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 63c503ec8c7..55ca50305e5 100644
--- a/addons/sale_timesheet/__manifest__.py
+++ b/addons/sale_timesheet/__manifest__.py
@@ -37,5 +37,4 @@ have real delivered quantities in sales orders.
'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 d1a4d83d307..3ae044c7c91 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 85869761e57..e5421d4546c 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 10e9ffab73b..dbc0a78cd75 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 c45981ea0b0..3e00399fcc3 100644
--- a/addons/sms/models/mail_notification.py
+++ b/addons/sms/models/mail_notification.py
@@ -7,7 +7,9 @@ from odoo.tools.translate import _
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 38364f75590..94284fd99a7 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 9d7a09cb88c..f912d4ed8fa 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 5513c5e7911..9b17dd03f51 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 61b8a31dbc0..e81afcfe607 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 79173dbe6b2..4158b86d84a 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 b4cd4626b91..23b54c16ce7 100644
--- a/addons/survey/models/challenge.py
+++ b/addons/survey/models/challenge.py
@@ -7,4 +7,6 @@ from odoo import models, fields
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 7f6e83554e3..bb9a865f161 100644
--- a/addons/web/models/models.py
+++ b/addons/web/models/models.py
@@ -14,7 +14,9 @@ from odoo.exceptions import UserError
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 902b5e0eab9..1f7d758ea3e 100644
--- a/addons/website_forum/models/gamification.py
+++ b/addons/website_forum/models/gamification.py
@@ -7,4 +7,6 @@ from odoo import models, fields
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 bb95e2e0ab5..ee288fb8b64 100644
--- a/addons/website_sale_slides/models/slide_channel.py
+++ b/addons/website_sale_slides/models/slide_channel.py
@@ -7,7 +7,9 @@ from odoo import api, fields, models
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 f1346f7ddab..7bb7f498ec4 100644
--- a/addons/website_slides/models/gamification_challenge.py
+++ b/addons/website_slides/models/gamification_challenge.py
@@ -7,4 +7,6 @@ from odoo import models, fields
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 26b79394c58..76e1453eb7a 100644
--- a/addons/website_slides_survey/models/slide_slide.py
+++ b/addons/website_slides_survey/models/slide_slide.py
@@ -38,7 +38,9 @@ class SlidePartnerRelation(models.Model):
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)