[MIG] base_force_record_noupdate: Migration to 17.0

pull/2950/head
Vincent Van Rossem 2024-05-24 10:56:21 +02:00
parent 251723a4d1
commit 16b011fcb2
3 changed files with 7 additions and 10 deletions

View File

@ -1,11 +1,8 @@
from . import models
def post_init_hook(cr, registry):
def post_init_hook(env):
"""Configure a list of models having ``force_noupdate`` set by default"""
from odoo import SUPERUSER_ID, api
env = api.Environment(cr, SUPERUSER_ID, {})
mods = env["ir.model"].sudo()
for model_name in [
"res.lang",

View File

@ -7,7 +7,7 @@
"author": "Camtocamp, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/server-tools",
"category": "Hidden",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"depends": ["base"],
"data": ["views/ir_model.xml"],

View File

@ -2,10 +2,10 @@
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
from odoo import api, fields, models
from odoo.tools.cache import ormcache
from odoo.tools import ormcache
class Model(models.Model):
class IrModel(models.Model):
_inherit = "ir.model"
force_noupdate = fields.Boolean("Force No-Update")
@ -13,20 +13,20 @@ class Model(models.Model):
@api.model_create_multi
def create(self, vals_list):
mods = super().create(vals_list)
type(self)._get_noupdate_model_ids.clear_cache(self.browse())
self.env.registry.clear_cache()
self._propagate_noupdate_to_model_data()
return mods
def write(self, vals):
res = super().write(vals)
if "force_noupdate" in vals:
type(self)._get_noupdate_model_ids.clear_cache(self.browse())
self.env.registry.clear_cache()
self._propagate_noupdate_to_model_data()
return res
def unlink(self):
res = super().unlink()
type(self)._get_noupdate_model_ids.clear_cache(self.browse())
self.env.registry.clear_cache()
return res
def _get_noupdate_models(self):