This question has been flagged
3 Replies
4255 Views

Hi,

From the expense report form view, I can add a new expense line by clicking on "add a line". This open a search form, then I have to click on "Create"  to access to the creation form.

I want to skip the search view and show the create form when the modal open.

Is there a way to do this ?



EDIT:

I tried to add a control to the list with no success.


    <record id="view_hr_expense_sheet_form" model="ir.ui.view">
        <field name="model">hr.expense.sheet</field>
        <field name="inherit_id" ref="hr_expense.view_hr_expense_sheet_form" />
        <field name="arch" type="xml">
            <xpath expr="//field[@name='expense_line_ids']/tree" position="after">
                <control>
                    <create string="Add new line" />
                </control>
            </xpath>
        </field>
    </record>

According to the documentation this should shows a button and remove the "Add a line" link.

regards








Avatar
Discard
Author Best Answer

I solved my problem.

I replaced the widget "many2many" by "one2many", now when I click on "add a line" it's open the creation form.



Avatar
Discard
Best Answer

update view_mode  and view_id in record

<field name="view_mode">form</field>
<field
name="view_id" ref="sample_form_view"/>
Avatar
Discard
Author

Fasil,

Thank you for your answer.

I'm not sure how I can use those tags. I can't find the related action.

The view I'm talking about is "hr_expense.view_hr_expense_sheet_form".

...

<notebook>

<page name="expenses" string="Expense">

<field name="expense_line_ids" nolabel="1" widget="many2many"

domain="[('state', '=', 'draft'), ('employee_id', '=', employee_id), ('company_id', '=', company_id)]"

options="{'reload_on_button': True}"

context="{'form_view_ref' : 'hr_expense.hr_expense_view_form_without_header', 'default_company_id': company_id}">

<tree decoration-danger="is_refused">

<field name="date" />

<field name="name" />

<field name="state" invisible="1" />

<field name="analytic_account_id"

domain="['|', ('company_id', '=', parent.company_id), ('company_id', '=', False)]"

groups="analytic.group_analytic_accounting" />

<field name="analytic_tag_ids" widget="many2many_tags"

groups="analytic.group_analytic_tags" />

<field name="message_unread" invisible="1" />

<field name="attachment_number" string=" " />

<button name="action_get_attachment_view" string="View Attachments" type="object"

icon="fa-paperclip" />

<field name="tax_ids" widget="many2many_tags" groups="account.group_account_user"

context="{'default_company_id': company_id}" />

<field name="company_id" />

<field name="currency_id" invisible="1" />

<field name="total_amount" />

<field name="company_currency_id" invisible="1" />

<field name="total_amount_company" groups="base.group_multi_currency" />

<field name="is_refused" invisible="True" />

</tree>

</field>

...

The "Add a line" button in the tree view seems to be generated dynamically.

Regards