Adding a Button in Tree View Odoo 8 - odoo-8

I've Created a Wizard in Tree View Mode and Just Want to add some button with it, is there a way to this in odoo 8?
Thanks

Yes, you can add button in the tree view like you are adding in the form view.
<tree string="My Tree">
<button name="%{action_wiz_open}d" string="Scrap Products" type="action" icon="terp-gtk-jump-to-ltr" help="calls window action" />
<button name="call_function" string="Process" type="object" help="calls python function" />
</tree>
Hope this helps!

To add a button in tree view try below code:
<tree>
<button name="your_action" icon="rupee-symbol"
String="Payment" type="action"
attrs="{'invisible':[('status','!=','Confirmed')]}" />
</tree>
Hope it will help you..

Create a folder wizard
which will have
__init__.py
file_name.py
file_name_view.xml
In Python file_name.py
def fields_view_get(self, cr, uid, view_id=None, view_type='form',
context=None, toolbar=False, submenu=False):
if context is None:
context={}
res = super(class_name_wizard, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
return res
Add your function next to it
In file_name_view.xml
<record model="ir.ui.view" id="new_id">
<field name="name">New Wizard</field>
<field name="model">my.wizard</field>
<field name="arch" type="xml">
<form string="New Form">
<header>
<button name="do_generate" string="My Function" type="object"/>
or
<button string="Cancel" class ="oe_link" special="cancel"/>
</header>
</form>
</field>
</record>
<record id="action_my_function_wizard" model="ir.actions.act_window">
<field name="name">My Function</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">my.wizard</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
<act_window name="My Function"
res_model="my.wizard"
src_model="product.master"
view_mode="form"
target="new"
multi="True"
key2="client_action_multi"
id="action_view_my_new_id"/>
Note:In src_model write the table name of the tree view
Hope this will help you

Related

odoo wizard cant inherit the model

I created a model like this
class FoundCheque(models.TransientModel):
_name = "found.cheque"
date_Found = fields.Date(string='Found Date', default=fields.Date.context_today, required=True, translate=True)
and its view
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<data>
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
</data>
</odoo>
but when I try to update the module after restarting the service
it just says:
Field `date_found` does not exist
Error context:
View `found.cheque.wizard`
[view_id: 4100, xml_id: n/a, model: found.cheque, parent_id: n/a]
None" while parsing /opt/odoo/odoo11-custom-addons/cheque_management/views/found_cheque.xml:4, near
<record model="ir.ui.view" id="wizard_found_cheque">
<field name="name">found.cheque.wizard</field>
<field name="model">found.cheque</field>
<field name="arch" type="xml">
<form string="found Cheque">
<group>
<field name="date_found" style="width:40%%"/>
</group>
<footer>
<button name="found_cheque" string="Post" type="object" class="oe_highlight" confirm="آیا مطمئن هستید؟"/>
or <button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
and just to add I restarted the service several times
more information will be added on request
Your field name in python file is date_Found and date_found in xml. Both are different. so change field name in xml file
the defined field in model was "date_Found" and the defined field in wizard was "date_found"
F

Make a delete button invisible using attrs. I am using Odoo 10

I need to make a delete button invisible using attrs.
my code here.
in this code i want to put invisible delete button.
<record id="calender_event_form_id1" model="ir.ui.view">
<field name="name">calender_event</field>
<field name="model">calendar.event</field>
<field name="inherit_id" ref="calendar.view_calendar_event_form_popup"/>
<field name="arch" type="xml" delete="false">
<xpath expr="//field[#name='partner_ids']" position="after">
<field name="c_is_meeting_done" string="Is Meeting Done?" readonly="1"/>
<field name="description"/>
</xpath>
<xpath expr="//field[#name='alarm_ids']" position="after">
<div name="buttons">
<button name="%(ouc_meeting_wizard_action)d" string="Close Meeting" attrs="{'invisible':[('c_is_meeting_done', '=', True)]}" type="action" class="oe_highlight" />
</div>
</xpath>
</field>
</record>
You can give "delete=1" to your particular view from xml. Like this:
<form string="Custom" delete="1"/>

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>

Odoo - search_default does not work?

I created button in partner form to show another models relation with it. It is same button like Opportunities, Meetings, Sales button at partners form showing all its Opportunities, Meetings, Sales etc.
Code looks like this:
Model:
from openerp import models, fields
from openerp import api
class res_partner(models.Model):
_inherit = 'res.partner'
service_ids = fields.One2many('calendar.service', 'partner_id', 'Calendar Services')
service_count = fields.Integer('Services', compute='_count_services')
#api.one
#api.depends('service_ids')
def _count_services(self):
self.service_count = len(self.service_ids)
Action:
<record id="action_calendar_service" model="ir.actions.act_window">
<field name="name">Services</field>
<field name="res_model">calendar.service</field>
<field name="view_mode">tree,calendar,form</field>
<field name="view_id" ref="view_calendar_service_tree"/>
<field name="search_view_id" ref="view_calendar_service_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create new service.
</p>
</field>
</record>
View:
<record id="view_partners_form_service1" model="ir.ui.view">
<field name="name">view.res.partner.form.crm.inherited1</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="crm.view_partners_form_crm1"/>
<field eval="18" name="priority"/>
<field name="arch" type="xml">
<button name="schedule_meeting" position="after">
<button
class="oe_inline oe_stat_button"
attrs="{'invisible': [('customer', '=', False)]}"
name="%(calendar_service.action_calendar_service)d"
icon="fa-star"
type="action"
context="{'search_default_partner_id': active_id}">
<field name="service_count" string="Services" widget="statinfo"/>
</button>
</button>
</field>
</record>
Everything works with that button except for one thing. It does not filter result with partner_id (the one that button was pressed) and it opens all 'calendar.service' records. But it should show only the ones from that specific partner. Does context="{'search_default_partner_id': active_id}"> need something more? What am I missing here?
Finally found what was missing. I needed to add this line:
<field name="partner_id" filter_domain="[('partner_id','child_of',self)]"/>
In my model search view. Without that it does not use search_default filter.

Resources