Search code examples
pythonodootypeerror

TypeError: Model 'SaleOrder' inherits from non-existing model


class Sale.Order is defined differently in many models I'm definitely uncertain about where the actual error is. My code for Sale.Order is



class SaleOrder(models.Model):
    _name = "sale.order"
    _inherit = ['sale.order', 'utm.mixin']

    tag_ids = fields.Many2many('crm.lead.tag', 'sale_order_tag_rel', 'order_id', 'tag_id', string='Tags')
    opportunity_id = fields.Many2one('crm.lead', string='Opportunity', domain="[('type', '=', 'opportunity')]")

If anyone of you have any clue kindly help me.


Solution

  • Once the module is installed, if you add the module itself to the dependencies in the manifest, the error goes away but that's not really a fix and you will most likely get a recursion error later.

    For now try, adding the following dependency: 'depends' : ['sale'], in your manifest.py. Because you are trying to inherit the 'sale' module from addons (sale.order is found in this module). Basically this module is not installed. So you are trying to inherit from a non-existing model until you install said module. You use depends on all modules that you are using in other models (inherit model/views). In that case, you will no longer get any errors like this. Good luck!