mirror of
https://github.com/bringout/oca-technical.git
synced 2026-04-18 15:52:03 +02:00
Initial commit: OCA Technical packages (595 packages)
This commit is contained in:
commit
2cc02aac6e
24950 changed files with 2318079 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
# © 2022 Florian Kantelberg - initOS GmbH
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from . import ir_http, res_users
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# © 2022 Florian Kantelberg - initOS GmbH
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import models
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class IrHttp(models.AbstractModel):
|
||||
_inherit = "ir.http"
|
||||
|
||||
@classmethod
|
||||
def _set_color_scheme(cls, response):
|
||||
scheme = request.httprequest.cookies.get("color_scheme")
|
||||
user = request.env.user
|
||||
user_scheme = "dark" if getattr(user, "dark_mode", None) else "light"
|
||||
device_dependent = getattr(user, "dark_mode_device_dependent", None)
|
||||
if (not device_dependent) and scheme != user_scheme:
|
||||
response.set_cookie("color_scheme", user_scheme)
|
||||
|
||||
@classmethod
|
||||
def _post_dispatch(cls, response):
|
||||
cls._set_color_scheme(response)
|
||||
return super()._post_dispatch(response)
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
# © 2022 Florian Kantelberg - initOS GmbH
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
dark_mode = fields.Boolean()
|
||||
dark_mode_device_dependent = fields.Boolean("Device Dependent Dark Mode")
|
||||
|
||||
@property
|
||||
def SELF_READABLE_FIELDS(self):
|
||||
return super().SELF_READABLE_FIELDS + [
|
||||
"dark_mode_device_dependent",
|
||||
"dark_mode",
|
||||
]
|
||||
|
||||
@property
|
||||
def SELF_WRITEABLE_FIELDS(self):
|
||||
return super().SELF_WRITEABLE_FIELDS + [
|
||||
"dark_mode_device_dependent",
|
||||
"dark_mode",
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue