Ir al contenido
Menú
Se marcó esta pregunta
2699 Vistas

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
Descartar

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.

Publicaciones relacionadas Respuestas Vistas Actividad
0
ene 25
1385
1
mar 25
652
0
nov 23
2407
1
sept 23
2641
2
ago 22
7766