I having some problem in Odoo
<record id="lunch_order_view_form" model="ir.ui.view">
<field name="name">lunch.order.form</field>
<field name="model">lunch.order</field>
<field name="arch" type="xml">
<form string='Orders Form' class="o_lunch">
<header>
<button name="%(action_lunch_order_line_lucky)d" type="action" string="Feeling Lucky" class="oe_highlight"/>
<!-- HERE THAT I WANT TO ADD -->
And then I use
<record id="lunch_order_view_form" model="ir.ui.view">
<xpath expr="/lunch/views/lunch_views/field[#name='arch']" position="after">
<button name="%(action_lunch_order_line_favorite)d" type="action" string="Favorite Menu" />
hello
</xpath>
</record>
but it now works how to define it?
If header is already define in your parent form view , you can inherit it as below:
<record id="lunch_order_view_form_inherit" model="ir.ui.view">
<field name="name">lunch.order.form.inherit</field>
<field name="model">lunch.order</field>
<field name="inherit_id" ref="parent_form_module_name.lunch_order_view_form"/>
<field name="arch" type="xml">
<xpath expr="//header" position="inside">
<button name="%(action_lunch_order_line_favorite)d" type="action" string="Favorite Menu" />
</xpath>
</field>
</record>
You can replace parent_form_module_name with actual module name where you have define parent form.
Related
Currently, I just see the Schedule working hours and timezone with developer mode.
So, how to make the Schedule visible without developer mode?
You need to inherit form view and replace group section. It will be easy.
Something like:
<record id="view_employee_form" model="ir.ui.view">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//notebook/page/div/div/group[4]" position="replace">
<group string="Schedule">
<field name="resource_calendar_id" required="1"/>
<field name="tz"/>
</group>
</xpath>
</field>
</record>
The origin form view you're inheriting resp. extending is in short:
<notebook>
<page name="public" string="Work Information">
<div id="o_work_employee_container"> <!-- These two div are used to position org_chart -->
<div id="o_work_employee_main">
<!-- ... -->
<group string="Schedule" groups="base.group_no_one">
<field name="resource_calendar_id" required="1"/>
<field name="tz"/>
</group>
</div>
</div>
</page>
<!-- ... --->
</notebook>
You could as one option just remove the groups attribute, which is in combination with the group base.group_no_one used for showing things in debug mode only:
<record id="view_employee_form" model="ir.ui.view">
<field name="name">hr.employee.form</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<xpath expr="//field[#name='tz']/.." position="attributes">
<attribute name="groups" />
</xpath>
</field>
</record>
I have tried so many ways to display "Offer Letter" button only when a customer is saved. But it seems i am not getting the condition right here:
<xpath expr="//form/*" position="before">
<header>
<button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight"
attrs="{'invisible':[('what condition?')]}"/>
</header>
</xpath>
Below is my code snippet:
The Model:
class res_partner(models.Model):
_inherit = 'res.partner'
baf = fields.Boolean("Application Form", help="Specify customer who bought application form")
#api.multi
def offer_letter_method(self):
return self.env['report'].get_action(self, 'sales_custom.offer_letter_view')
The View:
<record model="ir.ui.view" id="customer_custom_form_view">
<field name="name">customer.custom</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//form/*" position="before">
<header>
<button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight"
attrs="{'invisible':[('what condition?')]}"/>
</header>
</xpath>
<xpath expr="//field[#name='name']" position="after">
<field name="baf"/>
<label for="baf"/>
</xpath>
</field>
</record>
Kindly assist.
You should try as following :
<record model="ir.ui.view" id="customer_custom_form_view">
<field name="name">customer.custom</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="//form/*" position="before">
<header>
<button name="offer_letter" string="Offer Letter" type="object" class="oe_highlight"
attrs="{'invisible':[('id','=',False)]}"/>
<field name="id" invisible="1"/>
</header>
</xpath>
<xpath expr="//field[#name='name']" position="after">
<field name="baf"/>
<label for="baf"/>
</xpath>
</field>
</record>
I am trying to invisible the button but its not working, Why its like this?
<button name="%(sale_confirm_details)d" states="draft" type="action" attrs="{'invisible':[('order_confirm','=',True)]}" />
try something like the following
<record model="ir.ui.view" id="form_view_id_inherit">
<field name="name">model.name.form</field>
<field name="model">model.model</field>
<field name="inherit_id" ref="module_name.form_view_id"/>
<field name="arch" type="xml">
<data>
<xpath expr="//button[#name='sale_confirm_details']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</data>
</field>
</record>
I had successfully inherited the CRM module into my custom module.I'm able to view the Form view but i need to show Tree view first.When i click Lead button in the main menu i'm able to show the form view (like in img1), but i need to show the tree view(like in img 2)
img 1
img 2
lead_view.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_lead_tree" model="ir.ui.view">
<field name="name">bala.lead</field>
<field name="model">bala.lead</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="contact_name"/>
<field name="lead_source"/>
<field name="lead_status"/>
</tree>
</field>
</record>
<!-- ========================This is Form layout===============================-->
<record id="crm_case_form_view_leads_extended" model="ir.ui.view">
<field name="name">CRM - Leads Form</field>
<field name="model">bala.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads" />
<field name="arch" type="xml">
<field name="email_from" postion="replace"/>
<field name="contact_name" position="replace"/>
<label for="contact_name" position="replace">
<br/>
</label>
<xpath expr="//label[#for='street']" position="before">
<field name="contact_name"/>
</xpath>
<xpath expr="//label[#for='section_id']" position="before">
<field name="lead_source"/>
<field name="lead_status"/>
</xpath>
<field name="function" position="replace"/>
<field name="partner_name" position="replace"/>
<field name="priority" position="replace"/>
<field name="categ_ids" position="replace"/>
<field name="partner_id" position="replace"/>
</field>
</record>
<!-- ===========================Action layout=========================== -->
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Leads</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_lead_tree"/>
</record>
<!-- ===========================Menu Settings=========================== -->
<menuitem name ="Lead" id = "menu_lis_lab" />
<menuitem name="Leads" id="sub_lead" parent="menu_lis_lab" />
<menuitem name="Create Lead" id="create_lead" parent="sub_lead" action="new_lead"/>
</data>
</openerp>
then on click of any lead i'm getting img 3 (invalid view)and on click on Create button img 4 is being displyed , but i need to get img1
img 3
img 4
Add tree view to your xml file, and you can add more fields in this according to requirement,
<record id="view_lead_tree" model="ir.ui.view">
<field name="name">bala.lead</field>
<field name="model">bala.lead</field>
<field name="arch" type="xml">
<tree string="Leads">
<field name="contact_name"/>
<field name="lead_source"/>
<field name="lead_status"/>
</tree>
</field>
</record>
update your act_window
<record id="new_lead" model="ir.actions.act_window">
<field name="name">Lead</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">bala.lead</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_lead_tree"/>
</record>
Hope this will help you.
How can I inherited a view to add a field into the "Sessions" tab ?
e.g :
<record model="ir.ui.view" id="partner_sessions_form_view">
<field name="name">partner.sessions.name</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<xpath expr="/form/notebook/page[#string='Notes']" position="after">
<page string="Sessions">
<field name="session_ids" nolabel="1" colspan="4"/>
</page>
</xpath>
</field>
</record>
This adds a page, but how would I add a field in the page Sessions ?
If you want to add a field to page 'Sessions' that you have created above, then you should provide
<record model="ir.ui.view" id="partner_sessions_form_view_again_inherited">
<field name="name">partner.sessions.name.inherited</field>
<field name="model">res.partner</field>
<field name="type">form</field>
<field name="inherit_id" ref="partner_sessions_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[#name='session_ids']" position="before">
<field name="new_field1" nolabel="1" colspan="4"/>
</xpath>
</field>
</record>
if you want to add add a field to the session_ids tree or form view, then
<xpath expr="//field[#name='session_ids']/tree/field[#name='already_existing_field']" position="after">
<field name="new_field1" />
</xpath>
You need to find that field in side you page Session
like this (but that page has to be their in view):
<xpath expr="//page[#string='Sessions']/field[#name='some_field'] position="after">
<field name="session_ids" nolabel="1" colspan="4"/>
</xpath>
Thanks
This is covered pretty well in the documentation. The simplest case is to just add your new field after an existing one. In this example, you're placing the relation_ids field after the lang field.
<record model="ir.ui.view" id="view_partner_form4">
<field name="name">res.partner.form.inherit4</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="lang" position="after">
<field name="relation_ids"/>
</field>
</field>
</record>
If that field appears in more than one place, you'll have to use an XPath element. For example, if the lang field appears in a subview's tree view and its form view.