Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mail_environment and microsoft_outlook incompatibility. #162

Closed
florian-dacosta opened this issue Jul 27, 2023 · 1 comment
Closed

mail_environment and microsoft_outlook incompatibility. #162

florian-dacosta opened this issue Jul 27, 2023 · 1 comment
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@florian-dacosta
Copy link

I only have tested with version 16 but it probably impacts all versions.

If both mail_environment and microsoft_outlook are installed, it is impossible to create an outgoing mail server with smtp_authentication = 'outlook', unless you manage the environment dependent fields in your Odoo config files. (So it does not work with default value or data_encryption_server_environment module)

During the creation, you will have a failure due to this constraints : https://github.com/OCA/OCB/blob/16.0/addons/microsoft_outlook/models/ir_mail_server.py#L46
The reason is, Odoo will check these constraint before the default environement value is set.
Constraints are checked there https://github.com/OCA/OCB/blob/16.0/odoo/models.py#L4206 while the not stored fields with inverse method (which is the case of the environment dependent fields) are managed later on in the create method.
During the constraint check, the value will always be False (unless defined in config file)

So, the source of the problem is the fact that server_environment some stored fields to not stored /computed fields.
Actually, I think I already met issues with server_environment because of this, I think required field are not anymore, fields no more searchable, stuff like that.

Anyway, I have no perfect solution about this issue. For now, I intent to fix it for microsoft_outlook with the following :

class IrMailServer(models.Model):
    _inherit = "ir.mail_server"

    @api.model_create_multi
    def create(self, vals_list):
        res = super(IrMailServer, self.with_context(delay_field_validation=True)).create(vals_list)
        res.with_context(delay_field_validation=False)._validate_fields(name for vals in vals_list for name in vals)
        return res

    def _validate_fields(self, field_names, excluded_names=()):
        if self.env.context.get("delay_field_validation"):
            return
        return super()._validate_fields(field_names, excluded_names=excluded_names)

It seems good enough to me and not too dangerous because specific to the constraints of ir.mail_server

I wonder if anyone would have a better idea and/or if it was good enough to go to mail_environment_office365 module.

I guess the problem from this issue is the same as spotted here : #119 (comment)
Even though I did not experience this one.

Any feedback is appreciated @JordiBForgeFlow @simahawk @lmignon @StefanRijnhart

Copy link

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Jan 28, 2024
@github-actions github-actions bot closed this as completed Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

1 participant