2

I want to create child item line from the parent model form page but Add Data Line button not showing. I have given all permission to the base user for both model like create,update, and delete still create button not showing.

Reference image: look no Add Data Line button or delete icon showing to the line items enter image description here

ir.model.access.csv file

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_test_data_data,test_data.data,model_test_data_data,base.group_user,1,1,1,1
access_test_data_source,test_data.source,model_test_data_source,base.group_user,1,1,1,1

model file code


class TestData(models.Model):
    _name = 'test_data.data'
    _description = 'Test Data Table'

    name = fields.Char(string='Name', required=True)
    source_properties_definition = fields.PropertiesDefinition(
        'Source Properties'
    )
    # relation to data source
    source_ids = fields.One2many(
        comodel_name='test_data.source', inverse_name='data_id',
        string='Source', readonly=True,
    )

class DataSource(models.Model):
    _name = 'test_data.source'
    _description = 'Data Source Table'

    name = fields.Char(string='Name', required=True)
    latitude = fields.Char(string='Latitude')
    longitude = fields.Char(string='Longitude')
    # relation to test_data
    data_id = fields.Many2one(
        comodel_name='test_data.data', string='Data',
        required=True, ondelete='cascade', index=True,
    )
    # dynamic field
    properties = fields.Properties(
        string='Properties',
        copy=True,
        definition='data_id.source_properties_definition'
    )

The form view source code

<!-- Form View -->
        <record model="ir.ui.view" id="test_data.form_view">
            <field name="name">Test Data Form</field>
            <field name="model">test_data.data</field>
            <field name="arch" type="xml">
                <form>
                    <sheet>
                        <div class="oe_title">
                            <span class="o_form_label">Data Name</span>
                            <h1 class="mt0">
                                <field name="name"/>
                            </h1>
                        </div>
                        <notebook>
                            <page name="data_source_list_page" string="Data Lines">
                                <field name="source_ids" string="">
                                    <tree create="1" edit="1" delete="1">
                                        <control>
                                            <create name="add_data_line" string="Add Data Line" edit="top"/>
                                        </control>
                                        <field name="name"/>
                                        <field name="latitude"/>
                                        <field name="longitude"/>
                                    </tree>
                                    <form>
                                        <group>
                                            <group>
                                                <field name="name"/>
                                                <field name="latitude"/>
                                            </group>
                                            <group>
                                                <field name="longitude"/>
                                                <field name="properties" attrs="{'invisible': [('id', '!=', False)]}"/>
                                            </group>
                                        </group>
                                    </form>
                                </field>
                            </page>
                        </notebook>
                    </sheet>
                </form>
            </field>
        </record>
Riajul Kashem
  • 89
  • 3
  • 13

1 Answers1

2

Everything was fine still not showing Add Data Line button because the source_ids field was readonly=True That's why not working.

source_ids = fields.One2many(
        comodel_name='qm_data.source', inverse_name='data_id',
        string='Source', readonly=True,
    )

after removed readonly attribute

source_ids = fields.One2many(
        comodel_name='qm_data.source', inverse_name='data_id',
        string='Source',
    )
Riajul Kashem
  • 89
  • 3
  • 13