[FIX] *: set ondelete policy of required Selection fields
With this commit, Selection fields with `required=True` which are extended via `selection_add` are given proper ondelete policies to ensure the cleanup of records containing these extended options during uninstall of the extending module. This commit also cleans up leftover uninstall hooks that were being used to handle the same set of problems prior to the ondelete mechanism being implemented for Selection fields. closes odoo/odoo#46325 Related: odoo/enterprise#9117 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
committed by
Raphael Collet
parent
f0481392c6
commit
1daf8eb127
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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 "
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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':
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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'})})
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'})})
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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)',
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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',
|
||||
})
|
||||
|
||||
@@ -14,7 +14,7 @@ class BarcodeRule(models.Model):
|
||||
|
||||
type = fields.Selection(selection_add=[
|
||||
('credit', 'Credit Card')
|
||||
])
|
||||
], ondelete={'credit': 'set default'})
|
||||
|
||||
|
||||
class PosMercuryConfiguration(models.Model):
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -37,5 +37,4 @@ have real delivered quantities in sales orders.
|
||||
'data/sale_service_demo.xml',
|
||||
],
|
||||
'auto_install': True,
|
||||
'uninstall_hook': 'uninstall_hook',
|
||||
}
|
||||
|
||||
@@ -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])]")
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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=[
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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'))
|
||||
|
||||
@@ -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',
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
})
|
||||
|
||||
@@ -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])]",
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'})
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user