OCA/pylint-odoo

[IMP] detect when request is using in models

Closed this issue · 3 comments

Currently is possible to import request from odoo.http in models but the request is only available with information from Controllers (frontend) so, we can implement a way to identify when the request.env is used in models to notify the user.

I think it could be detected with the original pylint checks but using a dynamic way

I mean, you need to have configured the odoo package in the PYTHONPATH to be computed from pylint/astroid

The check related could be no-member

@fernandahf
Could you double-confirm if this check works as you expect here, please?

Even we could dev this static check in order to detect these kind of cases using self.env for controller classes

@sbidoul

I can not assign to @antonag32 to issues because "it is not a member of this organization"

What is the correct way to do it?

Workaround, for now, I just have added access temporally in

@moylop260

There are code lines that are doing the exactly I reported as improvement, so it's a valid case:

https://github.com/odoo/odoo/blob/c63493ab7b19a238304b2d7791c28bf1a52c0d2f/addons/website_sale/models/sale_order.py#L127

Closing this.