2
votes

I'm having a problem with the create button appearing in tree view. Neither does the next or previous buttons appear in the form view. However, the data is being retrieved from the database.

Tree form with missing buttons

The module I'm trying to make is an extended module of the human resource module, like the included HR attendance module. The extended module doesn't inherit anything and security hasn't been added yet. Only a menu item is added to the main module.

A module I previously created by inheriting the main HR module created the buttons as expected.

Expected outcome(different module)

training.py:

from openerp import fields, models, api

class ew_training(models.Model):
  _name           = 'hr.training'

  var             = fields.Char(      string='variable')

training_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
  <data>
    <!-- Main Submenu -->
    <menuitem id="menu_training_tree" action="action_view_training"
                  parent="hr.menu_hr_main" sequence="6"/>

    <record id="action_view_training" model="ir.actions.act_window">
      <field name="name">Training</field>
      <field name="res_model">hr.training</field>
      <field name="view_type">tree</field>
      <field name="view_mode">tree,form</field>
    </record>

    <record id="view_training_tree" model="ir.ui.view">
      <field name="name">hr.training.tree</field>
      <field name="model">hr.training</field>
      <field name="arch" type="xml">
        <tree>
          <field name="var"/>
        </tree>
      </field>
    </record>

    <record id="view_training_form" model="ir.ui.view">
      ...
    </record>      
  </data>
</openerp>

Please try avoid using the old API

2

2 Answers

1
votes

EDIT

This should be work if you are trying to call differents views in differents actions.

The problem is not the button create, the problem is that you are not calling the tree view on your action action_view_training, try adding this line after view_mode:

<field name="view_id" ref="view_training_tree"/>

EDIT

To solve your case you only need to change in the view_type, you should use form:

<record id="action_view_training" model="ir.actions.act_window">
  <field name="name">Training</field>
  <field name="res_model">hr.training</field>
  <field name="view_type">form</field>
  <field name="view_mode">tree,form</field>
</record>

It should be work perfectly!!! I hope this could be helpful for you.

0
votes

Just for Information.

in action view_type tree can be used when you want to create hierarchical view, It will not give you ability to create or update record. view of company structure in Odoo is the example of view type tree.

and view_type to form in action will allow you to create normal tree, form view with ability to Create, Update, Duplicate, Delete.

Hope this helps.