Skip to Content
Menu
This question has been flagged
1 Reply
2024 Views

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})
Avatar
Discard
Best Answer

Here seems it's not due on dependency. Which error you are facing?

Here simple you can check if 'sale.order' in self.env instead of search in 'ir.module.module'. Inside if condition simple define object of sale order.  self.env['sale.order'].search([*******])

Avatar
Discard