File: ir_model_fields.py

package info (click to toggle)
oca-core 11.0.20180730-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 509,684 kB
  • sloc: xml: 258,806; python: 164,081; sql: 217; sh: 92; makefile: 16
file content (29 lines) | stat: -rw-r--r-- 857 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details

from odoo import models


# This is a nasty hack, targeted for V11 only
class IrModelFields(models.Model):
    _inherit = 'ir.model.fields'

    def unlink(self):
        # Prevent the deletion of some `shared` fields... -_-
        social = (
            'social_facebook',
            'social_github',
            'social_googleplus',
            'social_linkedin',
            'social_twitter',
            'social_youtube',
        )

        self = self.filtered(
            lambda rec: not (
                (rec.model == 'res.company' and rec.name in social)
                or (rec.model == 'res.config.settings'
                    and rec.name == 'auth_signup_uninvited')
            )
        )
        return super(IrModelFields, self).unlink()