diff --git a/golem_admin/__init__.py b/golem_admin/__init__.py index 9dd702d..feff6f0 100644 --- a/golem_admin/__init__.py +++ b/golem_admin/__init__.py @@ -14,3 +14,5 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +from . import models diff --git a/golem_admin/__manifest__.py b/golem_admin/__manifest__.py index a306c20..eded0a1 100644 --- a/golem_admin/__manifest__.py +++ b/golem_admin/__manifest__.py @@ -22,7 +22,7 @@ - New application on top menu ; - Management of users and groups, companies ; - Good default access / rights to do. ''', - 'version': '10.0.0.1.0', + 'version': '10.0.0.1.3', 'category': 'GOLEM', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_admin/models/__init__.py b/golem_admin/models/__init__.py new file mode 100644 index 0000000..8466807 --- /dev/null +++ b/golem_admin/models/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import res_partner diff --git a/golem_admin/models/res_partner.py b/golem_admin/models/res_partner.py new file mode 100644 index 0000000..21a2e63 --- /dev/null +++ b/golem_admin/models/res_partner.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" Partner adaptations """ + +from odoo import models, fields, api + + +class Partner(models.Model): + """ Partner adaptations """ + _inherit = 'res.partner' + + signup_token = fields.Char(groups="golem_base.group_golem_manager") + signup_type = fields.Char(groups="golem_base.group_golem_manager") + signup_expiration = fields.Datetime(groups="golem_base.group_golem_manager") + + @api.multi + def write(self, vals): + """ Overwrite native function to workaround admin only write on fields + signup*, as it's impossible to overwrite groups attribute """ + if (('signup_token' in vals or 'signup_type' in vals or + 'signup_expiration' in vals) + and self.env.user.has_group('golem_base.group_golem_manager')): + return super(Partner, self.sudo()).write(vals) + return super(Partner, self).write(vals)