Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
279 Zobrazení

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


Avatar
Zrušit
Nejlepší odpověď

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


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
dub 25
545
0
led 25
954
0
led 25
1051
1
čvc 25
524
1
kvě 25
1063