summaryrefslogtreecommitdiff
path: root/ob_chatter_position/models/res_users.py
blob: fab83a7309280fa94fb1491435920a1ad9e0800c (plain)
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
# -*- coding: utf-8 -*-
from odoo import fields, models


class ResUsers(models.Model):
    _inherit = "res.users"

    chatter_position = fields.Selection(
        [("normal", "Normal"), ("sided", "Sided")],
        default="sided",
    )

    #  Override so that the user can change the chatter_position field

    def __init__(self, pool, cr):
        """ Override of init to allow user to set its chatter position. """
        init_res = super(ResUsers, self).__init__(pool, cr)

        # duplicate list to avoid modifying the original reference
        type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
        type(self).SELF_WRITEABLE_FIELDS.extend(['chatter_position'])

        type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
        type(self).SELF_READABLE_FIELDS.extend(['chatter_position'])
        return init_res