Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
345 Vizualizări

Dear All,


One of our customer requesting for encrypting Email IDs, Phone Numeber, Mobile Number for security purposes.

Does Odoo support encrypting personal information such as Email ID, Phone Number , Mobile Number etc.,?

If not so, Is there any readymade solution available to acheive this?


Thanks,

Odoo@Tenthplanet


Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

Try the following code,


from odoo import models, fields, api

from cryptography.fernet import Fernet

import base64


KEY = b'your_32_byte_key_here=='  # You must securely store this key

cipher = Fernet(KEY)


class ResPartner(models.Model):

    _inherit = 'res.partner'


    _encrypted_email = fields.Char(string="Encrypted Email", readonly=True)


    @api.depends('_encrypted_email')

    def _compute_email(self):

        for rec in self:

            try:

                rec.email = cipher.decrypt(rec._encrypted_email.encode()).decode()

            except:

                rec.email = ''


    email = fields.Char(compute="_compute_email", inverse="_inverse_email", store=True)


    def _inverse_email(self):

        for rec in self:

            if rec.email:

                rec._encrypted_email = cipher.encrypt(rec.email.encode()).decode()


Hope it helps


Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
apr. 25
610
0
ian. 25
984
0
ian. 25
1088
1
iul. 25
632
1
mai 25
1140