mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[12.0][ADD] base_default_lang_translate
This commit is contained in:
16
base_default_lang_translate/models/res_lang.py
Normal file
16
base_default_lang_translate/models/res_lang.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# Copyright 2021 Le Filament (https://le-filament.com)
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
|
||||
|
||||
from odoo import _, api, fields, models
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class ResLang(models.Model):
|
||||
_inherit = "res.lang"
|
||||
|
||||
is_default_lang = fields.Boolean("Default Language", default=False)
|
||||
|
||||
@api.constrains("is_default_lang")
|
||||
def _check_default(self):
|
||||
if self.search_count([("is_default_lang", "=", True)]) > 1:
|
||||
raise ValidationError(_("Another language is already set by default"))
|
||||
Reference in New Issue
Block a user