how to change default delete icon of odoo 11 - odoo-11

I have given editable bottom so i am getting default delete icon of odoo11. But i want to change it only to my module. How to change the delete icon to my own module ?
<field name="name"> Attachments</field>
<field name="model">attachments</field>
<field name="arch" type="xml">
<form string="Attachments">
<field name="line_ids" >
<tree string="Attachments" editable="bottom">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
</field>
Thanks in Advance !

just add delete="false" in tree view
<field name="name">Attachments</field>
<field name="model">attachments</field>
<field name="arch" type="xml">
<form string="Attachments">
<field name="line_ids" >
<tree string="Attachments" editable="bottom" delete="false">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>
</field>

You can add delete="false" in tree tag
ex.
<tree string="Attachments" editable="bottom" delete="false">
<field name="description" />
<field name="file_name" invisible="1" />
<field name="upload_file" filename="file_name" />
<button name ="download" icon ="gtk-go-down" type="object" />
</tree>

Related

Tree view in odoo 11

I want to show the fields that i mentioned in the tree string when there are no records in my tree view instead of showing "Click to add a new Sample record."
<record model="ir.ui.view" id="sample_tree_view">
<field name="name">Sample</field>
<field name="model">sample.test</field>
<field name="arch" type="xml"
<tree string="Sample" default_order="name">
<field name="code" />
<field name="name" />
<field name="status" />
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="action_sample">
<field name="name">Sample</field>
<field name="res_model">sample.test</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click here to create a new sample Record.
</p>
</field>
</record>
Thanks in advance ..!
Please remove help from your defined action & check.

Odoo 9 add column to grid view

I'm create simple module with 4 fields (name,date,user,description).Below is my .xml file.
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_my_report_form" model="ir.ui.view">
<field name="name">penalty.form</field>
<field name="model">my.report</field>
<field eval="2" name="priority"/>
<field name="arch" type="xml">
<form string="Project">
<sheet string="My report">
<group>
<div class="oe_title">
<h1 class="o_row">
<field name="name" placeholder="Name..." />
</h1>
</div>
</group>
<group>
<field name="user" placeholder="User..."/>
</group>
<group>
<field name="date" placeholder="Date..."/>
</group>
<notebook>
<page name="description_page" string="Description">
<field name="description"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_my_report_form">
<field name="name">Add new</field>
<field name="res_model">my.report</field>
</record>
<menuitem name="MY report" id="menu_penalty" action="action_my_izvjestaj_form" sequence="1"/>
</data>
</openerp>
When open from menu in grid view visble is only name.
https://postimg.org/image/ccms5aww3/
How add date and user fields?
You need to declare Tree view for that model.
<!-- Tree Views BEGIN-->
<record model="ir.ui.view" id="view_my_report_tree">
<field name="name">penalty.tree</field>
<field name="model">my.form</field>
<field name="arch" type="xml">
<tree string="Project">
<field name="name"/>
<field name="user"/>
<field name="date"/>
</tree>
</field>
</record>

How add new field on tree view (inherit on inherited)

I'm trying to replace a field in a tree view. Help me please.
This is script on base odoo enteprice
<record model="ir.ui.view" id="view_task_form2_inherited">
<field name="name">project.task.form.inherited</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2" />
<field name="arch" type="xml">
<field name="project_id" position="attributes">
<attribute name="on_change">onchange_project(project_id)</attribute>
</field>
<field name="tag_ids" position="after">
<field name="analytic_account_id" invisible="1"/>
<field name="progress" widget="progressbar"
groups="project.group_time_work_estimation_tasks"/>
</field>
<xpath expr="//notebook/page[#name='description_page']" position="after">
<page string="Timesheets" groups="project.group_tasks_work_on_tasks,project.group_time_work_estimation_tasks">
<field name="timesheet_ids" groups="project.group_tasks_work_on_tasks" context="{'default_account_id' : analytic_account_id, 'default_is_timesheet' : 1}">
<tree editable="top" string="Timesheet Activities">
<field name="date"/>
<field name="user_id" required="1"/>
<field name="name"/>
<field name="account_id"/>
<field name="unit_amount" string="Duration" sum="Total time" widget="float_time"/>
<field name="is_timesheet" invisible="1"/>
</tree>
</field>
<group>
<group class="oe_subtotal_footer oe_right" name="project_hours" groups="project.group_time_work_estimation_tasks">
<field name="effective_hours" widget="float_time" groups="project.group_time_work_estimation_tasks"/>
<field name="remaining_hours" widget="float_time" class="oe_subtotal_footer_separator" groups="project.group_time_work_estimation_tasks"/>
</group>
</group>
</page>
</xpath>
</field>
</record>
This is my custom script on _view.xml:
<record id="project_task_view_form" model="ir.ui.view">
<field name="name">project.task.view.form</field>
<field name="model">project.task</field>
<field name="inherit_id" ref="project.view_task_form2"/>
<field name="arch" type="xml">
<xpath expr="/notebook/page[#name='description_page']" position="replace">
<page string="Timesheets" groups="project.group_tasks_work_on_tasks,project.group_time_work_estimation_tasks">
<field name="timesheet_ids" groups="project.group_tasks_work_on_tasks" context="{'default_account_id' : analytic_account_id, 'default_is_timesheet' : 1}">
<tree editable="top" string="Timesheet Activities">
<field name="date"/>
<field name="user_id" required="1"/>
<field name="name"/>
<field name="unit_amount" string="Duration" sum="Total time" widget="float_time"/>
<field name="is_timesheet" invisible="1"/>
<field name="invoiceable_analytic_line"/>
</tree>
</field>
</page>
</xpath>
</field>
</record>
I want add new field "invoiceable_analytic_line" inside "timesheet_ids", but it doesn't work.
anybody help me?
Thanks.
View
The procedure is correct but just that there is an error with the expr attribute inside xpath.
Instead:
<xpath expr="/notebook/page[#name='description_page']" position="replace">,you have to write:
<xpath expr="//sheet/notebook/page[1]" position="replace"> when on odoo 10<xpath expr="/sheet/notebook/page[#string='Description']" position="replace">Because description_page doesn't existSo copy whole <page string="Description">..</page> tag from /project/project_view.xml and paste it inside your xpath tag by modify the string. After that insert your field where you want
Model
class Add_in_timesheet(models.Model)
_inherit = 'project.task
invoiceable_analytic_line = fields.Char(string=u"Invoiceable")

How do I get an editable multilines layout in OpenERP?

I want to create Delivery orders based on a selection of order lines to invoices (as shown below) with the possibility to adjust quantity used in the delivery order.
Expected UI
Looking around, I found a UI similar to want I want in Delivery orders > More > Return Shipments (cf. _stock/wizard/stock_return_picking_view.xml_).
What I got
But I don't get the same result with my XML
view.xml
<record id="view_create_delivery_button" model="ir.ui.view">
<field name="name">Create Delivery</field>
<field name="model">sale.order.line</field>
<field name="arch" type="xml">
<form string="Create Delivery" version="7.0">
<label string="Select the quantities to create."/>
<group>
<field name="order_id"/>
<field name="name"/>
<field name="product_uom_qty"/>
<field name="state" invisible="1" />
</group>
<footer>
<button name="create_returns" string="Create delivery" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
Question
How do I get this editable multilines layout?
What you see in the Return Shipments wizard is a one2many field that related to stock.return.picking.line on it tree view with editable=top attribute.
I am assuming this is what you wanted:
<record id="view_create_delivery_button" model="ir.ui.view">
<field name="name">Create Delivery</field>
<field name="model">sale.order</field>
<field name="arch" type="xml">
<form string="Create Delivery" version="7.0">
<label string="Select the quantities to create."/>
<field name="order_line" >
<tree editable="top">
<field name="order_id"/>
<field name="name"/>
<field name="product_uom_qty"/>
<field name="state" invisible="1" />
</tree>
</field>
<footer>
<button name="create_returns" string="Create delivery" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
Note: This is just a sample of how to use the field many2one's tree view, you might need adjust to your on needs.

Odoo v9 edit record with view_type=tree

I have to show the records of a custom module in a tree view (not list)
<field name="view_type">tree</field>
Instead of
<field name="view_type">form</field>
However, I would also like to be able to go to the records' corresponding forms when I click on them. Based on what I read, it's not possible, at least not by default. Is there any workaround to 'fix' it?
Here is my code:
<!-- Estrutura de Redes -->
<record id="edit_estrutura" model="ir.ui.view">
<field name="name">gestao.rede.estrutura.form</field>
<field name="model">gestao.rede.estrutura</field>
<field name="arch" type="xml">
<form string="Estrutura da Rede">
<header>
<!--<button name="" string="Desabilitar" type="object" states="habilitado"/>-->
<!--<button name="" string="Habilitar" type="object" states="desabilitado"/>-->
</header>
<sheet string="Estrutura da Rede">
<div class="oe_nome">
<label for="razao_social" class="oe_edit_only" string="Nome"/>
<h1>
<field name="name" string="Nome:"/>
</h1>
<label string="Pasta Acima:"/>
<field name="parent_id" options="{'no_create': True}"/>
<label string="Variável:"/>
<field name="variavel"/>
<label string="Pastas Abaixo:" class="oe_read_only"/>
<field name="pastas_filho" options="{'no_create': True}" class="oe_read_only"/>
</div>
</sheet>
</form>
</field>
</record>
<record id="view_estrutura_tree" model="ir.ui.view">
<field name="name">gestao.rede.estrutura.tree</field>
<field name="model">gestao.rede.estrutura</field>
<field name="field_parent">pastas_filho</field>
<field name="arch" type="xml">
<tree string="Estrutura da Rede" delete="true" editable="bottom/top" toolbar="1">
<field name="name"/>
<field name="pastas_filho"/>
<field name="parent_id"/>
<field name="variavel"/>
</tree>
</field>
</record>
<record id="open_view_gestao_estrutura_all" model="ir.actions.act_window">
<field name="name">Estrutura da Rede</field>
<field name="res_model">gestao.rede.estrutura</field>
<field name="view_type">tree</field>
<field name="domain">[]</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_estrutura_tree"/>
</record>
<menuitem action="open_view_gestao_estrutura_all" id="menu_action_estrutura" parent="menu_gestao_redes" sequence="20"/>
Thanks!
Editable Tree View
by default, selecting a list view's row opens the corresponding form view. The editable attributes makes the list view itself editable in-place.
Valid values are top and bottom, making new records appear respectively at the top or bottom of the list.
The architecture for the inline form view is derived from the list view. Most attributes valid on a form view's fields and buttons are thus accepted by list views although they may not have any meaning if the list view is non-editable
Example:
<tree editable="bottom/top">
<field name="xyz"/>
</tree>
Try this
<tree editable="bottom">
Add your fields
</tree>

Resources