summaryrefslogtreecommitdiff
path: root/addons/microsoft_account/models/res_users.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
committerstephanchrst <stephanchrst@gmail.com>2022-05-10 21:51:50 +0700
commit3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch)
treea44932296ef4a9b71d5f010906253d8c53727726 /addons/microsoft_account/models/res_users.py
parent0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff)
initial commit 2
Diffstat (limited to 'addons/microsoft_account/models/res_users.py')
-rw-r--r--addons/microsoft_account/models/res_users.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/addons/microsoft_account/models/res_users.py b/addons/microsoft_account/models/res_users.py
new file mode 100644
index 00000000..d6587ffe
--- /dev/null
+++ b/addons/microsoft_account/models/res_users.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+
+from datetime import timedelta
+
+
+from odoo import api, fields, models, _
+
+
+class User(models.Model):
+ _inherit = 'res.users'
+
+ microsoft_calendar_rtoken = fields.Char('Microsoft Refresh Token', copy=False, groups="base.group_system")
+ microsoft_calendar_token = fields.Char('Microsoft User token', copy=False, groups="base.group_system")
+ microsoft_calendar_token_validity = fields.Datetime('Microsoft Token Validity', copy=False)
+
+ def _set_microsoft_auth_tokens(self, access_token, refresh_token, ttl):
+ self.write({
+ 'microsoft_calendar_rtoken': refresh_token,
+ 'microsoft_calendar_token': access_token,
+ 'microsoft_calendar_token_validity': fields.Datetime.now() + timedelta(seconds=ttl) if ttl else False,
+ })