List view remains blank even after creating a record in odoo

467 views Asked by At

I have been working with odoo for quite sometimes and I have never experienced this issue before, The tree view of a model is not displaying records even after they have been created.

This is my model:


class PayrollStructureByJob(models.Model):
    _name = 'payroll.job'
    _inherit = 'mail.thread'
    _description = 'Salary Structure By job Position'
    _rec_name = 'job_id'

    job_id = fields.Many2one('hr.job', string='Job Position')
    salary_id = fields.Many2one('hr.payroll.structure',
                                string='Salary Structure')
    wage = fields.Float()
    notes = fields.Text()
    active = fields.Boolean()
    

This is my record rule I added to the security file, I created for the model:

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_payroll_job,payroll_job,model_payroll_job,hr.group_hr_manager,1,1,1,1
access_payroll_job_base,payroll_job_base,model_payroll_job,base.group_user,1,0,0,0

This is my tree view and my form view:

<record id="view_payroll_job_list" model="ir.ui.view">
      <field name="name">view.payroll.job.list</field>
      <field name="model">payroll.job</field>
       <field eval="8" name="priority"/>
      <field name="arch" type="xml">
        <tree>
          <field name="id"/>
          <field name="job_id"/>
          <field name="salary_id"/>
          <field name="wage"/>
          <field name="active"/>
        </tree>
      </field>
    </record>


    <record id="view_payroll_job_form" model="ir.ui.view">
        <field name="name">view.payroll.job.form</field>
        <field name="model">payroll.job</field>
        <field name="arch" type="xml">
           
            <form>
              <sheet>
                <group>
                <field name="id"/>
                  <field name="job_id"/>
                  <field name="salary_id"/>
                  <field name="wage"/>
                  <field name="notes"/>
                  <field name="active"/>
                </group>
              </sheet>
              <div class="oe_chatter">
                <field name="message_follower_ids" widget="mail_followers"/>
                    
                <field name="message_ids" widget="mail_thread"/>
            </div>
            </form>
        </field>
    </record>

I am confused as too what could be wrong, I may not have caught something but I can't seem to figure out what.

1

There are 1 answers

1
Kenly On BEST ANSWER

If an object has a field named active, odoo will filter out all inactive records unless they were explicitly asked for (setting active_test to True in the context).

You defined the active field with a default value set to False, Odoo will add the ('active', '=', 1) triplet to the search domain which will filter out all records with active set to False. If you keep the default value for active field, the created records will not be visible in the tree view.

You can find many examples in Odoo defining the active field like following:

active = fields.Boolean(default=True, help="Set active to false to hide the Account Tag without removing it.")