Skip to Content
Menu
This question has been flagged
1933 Views

I had inherited my model from multiple. I had a field

sub_heads = fields.Many2one('accounting_heads.sub_heads',domain = "[('heads', '=', heads)]", string= 'Sub Heads')

which have Many2one relation with accounting_heads.sub_heads model But it is showing value of accounting_heads.accounting_heads model field heads. here are my classes

from odoo import models, fields, api

class accounting_heads(models.Model):
    _name = 'accounting_heads.accounting_heads'
    _rec_name = 'heads'

    heads = fields.Char()

class sub_heads(models.Model):
    _name = 'accounting_heads.sub_heads'
    _inherit = 'accounting_heads.accounting_heads'


    heads = fields.Many2one('accounting_heads.accounting_heads', string= 'Heads')
    sub_heads= fields.Char(string ='Sub Heads')

class elementary_heads(models.Model):
    _name = 'accounting_heads.elementary_head'

    _inherits = {'accounting_heads.accounting_heads': 'heads',
     'accounting_heads.sub_heads' : 'sub_heads',
     }


    heads = fields.Many2one('accounting_heads.accounting_heads', string='Heads')
    sub_heads = fields.Many2one('accounting_heads.sub_heads',domain = "[('heads', '=', heads)]", string= 'Sub Heads')
    elementary_heads = fields.Char(string = 'Elementary Head')

Here is my view

 <record model="ir.ui.view" id="accounting_heads.elementary_form">
      <field name="name">Form</field>
      <field name="model">accounting_heads.elementary_head</field>
      <field name="arch" type="xml">
        <form >
          <field name="heads" string="Head"/>
          <field name="sub_heads" string="Sub Head"/>
          <field name="elementary_heads" string="Elememtary Head"/>

        </form>
      </field>
    </record>
Avatar
Discard

HI Hassan,

In this class sub_heads you dont need to inherit the accounting_heads.accounting_heads class. Just remove that inheirt and check onces.

Related Posts Replies Views Activity
1
Apr 24
334
0
Nov 23
754
1
Sep 23
1026
2
Aug 22
6354
8
Jun 20
19650