Hi,
Our goal is to resolve if Sale module is installed and then parser customer name for MRP orders, but if Sale module is not installed we just want to display empty customer name. When updating module Odoo checks modules dependencies and we can't access to self.env['sale_order'] this is because it's not in dependencies.
Here is example
@api.depends('origin')
def compute_sale_order_name(self):
for production in self:
name = False
if self.env['ir.module.module'].search([('name', '=', 'sale'), ('state', '=', 'installed')]):
origin = production.origin
if origin:
sale_order = self.env['sale.order'].search([('name', '=', origin)])
if sale_order:
name = sale_order.name
production.write({'sale_order_name': name})