I'm new to Odoo and I'm looking for a way to add/edit columns in the overview of customer invoices.
Does anyone know which files to edit? Or how this "overview screen" is called so I can look it up better?
Link to screenshot of overview screen: http://oi58.tinypic.com/2prtyk0.jpg
Thanks in advance!
The VIEW of this "TREE" is defined in
addons/account/views/account_invoice_view.xml
Which has the code like this:
<record id="invoice_tree" model="ir.ui.view">
<field name="name">account.invoice.tree</field>
<field name="model">account.invoice</field>
<field name="arch" type="xml">
<tree decoration-info="state == 'draft'" decoration-muted="state == 'cancel'" string="Invoice">
<field name="partner_id" groups="base.group_user" string="Customer"/>
<field name="date_invoice"/>
<field name="number"/>
<field name="commercial_partner_id" invisible="1"/>
<field name="reference" invisible="1"/>
<field name="name" invisible="1"/>
<field name="journal_id" invisible="1"/>
<field name="company_id" groups="base.group_multi_company" options="{'no_create': True}"/>
<field name="user_id"/>
<field name="date_due"/>
<field name="origin"/>
<field name="amount_total_signed" sum="Total Amount"/>
<field name="residual_signed" sum="Residual Amount"/>
<field name="currency_id" invisible="1"/>
<field name="company_currency_id" invisible="1"/>
<field name="state"/>
<field name="type" invisible="context.get('type',True)"/>
</tree>
</field>
</record>
I recommend you use developer mode to know the name of the view what you want change/edit/inherit/..etc,
Go to Administrator => About Odoo => Activate Developer Mode then return to the view and you will see near to the name of the current view a Drop-down list with name Debug View#xx click there and choice Edit TreeView/FormView/...etc after that you are going to see the definition of the current view, in this way you will know what view you need to inherit/edit/..etc
I hope this will help you!
Related
I want to hide field from tree view depends on the condition. I tried some techniques, but didn't work for me. Currently I can hide just value not all column. I want to hide whole column.
This is my tree view. And this code just hide the value not column.
<record id="view_tai_approval_tree" model="ir.ui.view">
<field name="name">tai.approval.tree</field>
<field name="model">tai.approval</field>
<field name="arch" type="xml">
<tree create="false">
<field name="tai_reference"/>
<field name="tai_project_name"/>
<field name="responsible_name"/>
<field name="tai_purchase_date"/>
<field name="tai_supplier_name"/>
<field name="state" class="bg-danger" attrs="{'invisible': [('state', '!=', 'unapproved')]}"/>
<field name="state" class="bg-success" attrs="{'invisible': [('state', '!=', 'approved')]}"/>
<field name="state" class="bg-warning" attrs="{'invisible': [('state', '!=', 'pending')]}"/>
</tree>
</field>
</record>
Actually, as you can see in the code, I just want to change the colors depends on the states. So is there any simple solution for this?
Odoo allows you to change the behavior of the text based on the attributes of the corresponding record.
This documentation is for tree views, but what they describe also works for fields.
<record id="view_tai_approval_tree" model="ir.ui.view">
<field name="name">tai.approval.tree</field>
<field name="model">tai.approval</field>
<field name="arch" type="xml">
<tree create="false">
<field name="tai_reference"/>
<field name="tai_project_name"/>
<field name="responsible_name"/>
<field name="tai_purchase_date"/>
<field name="tai_supplier_name"/>
<field name="state"
decoration-danger=="state != 'unapproved'"
decoration-success="state != approved'"
decoration-warning="state != 'pending'"/>
</tree>
</field>
</record>
I want to make the create button only show for certain group. Here is my xml code
<record model="ir.ui.view" id="sales_forecast_view_tree">
<field name="name">sales.forecast.tree</field>
<field name="model">sales.forecast</field>
<field name="priority" eval="16"/>
<field name="groups_id" eval="[(4,ref('ts_addons_tbk.group_tbk_exim'))]"/>
<field name="arch" type="xml">
<tree string="Sales Forecast" version="7.0" >
<field name="name" />
</tree>
</field>
</record>
What shoukd I do?
In order di hide create button, it more easy to set the group in setting menu > Database Structure > Models
So no need to edit the script
I am very new in odoo and i really need your help.
I've extended res.partner :
class extendedPartner(models.Model):
_name = 'extended.partner'
_inherit = 'res.partner'
auto = fields.One2Many('partner.car', 'auto_name', 'Car', required=False)
class partnerCar(models.Model):
_name = 'partner.car'
auto_model = fields.Char('Model auto', size=20, required=True)
release = fields.Integer('Year of release', required=True)
auto_name = fields.Many2One('extended.partner', 'Car Name', required=True)
But I don't know how to write xml so that I could see all partner's cars and information about them
<record model="ir.ui.view" id="view_partner_form">
<field name="name">res.partner.form.inherit</field>
<field name="model">extended.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Cars">
<!-- what should I write here? -->
</page>
</notebook>
</field>
</record>
Could you please help me? Thank you in advance.
UPD:
Is it right solution?
<record model="ir.ui.view" id="view_partner_form">
<field name="name">res.partner.form.inherit</field>
<field name="model">extended.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<field name="auto">
<tree>
<field name="auto_name"/>
<field name="auto_model"/>
<field name="release"/>
</tree>
</field>
</field>
</record>
You are almost there, since you inherit from another view and you injecting your view into the view you inherit from, you need to give your new view a "hook" in the parent view which it can use to attach its contents. So you use an xpath expression, and then you insert your field.
When you insert a relational field you can create so called embedded views. Here you have defined a tree view for your field. That means whenever your field will be rendered as a tree that is the tree that will be used, in your case the form.
You could also create a <form> after <tree> to be shown when clicked.
<record model="ir.ui.view" id="view_partner_form">
<field name="name">res.partner.form.inherit</field>
<field name="model">extended.partner</field>
<field name="inherit_id" ref="base.view_partner_form"/>
<field name="arch" type="xml">
<xpath expr="insert_x_path_xpression here" position="after, before etc"
<field name="auto">
<tree>
<field name="auto_name"/>
<field name="auto_model"/>
<field name="release"/>
</tree>
</field>
</xpath>
</field>
</record>
In OpenERP version 6, in my custom module, I changed the Timesheet form view by inheriting as my custom view below:
<record id="oit_hr_timesheet_sheet_form" model="ir.ui.view">
<field name="name">oit.hr.timesheet.sheet.form</field>
<field name="model">hr_timesheet_sheet.sheet</field>
<field name="inherit_id" ref="hr_timesheet_sheet.hr_timesheet_sheet_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<data>
<button name="sign_in" position="replace"/>
<button name="sign_out" position="replace"/>
<field name="state_attendance" position="after">
<field name="day_attendance"/>
</field>
<field name="total_attendance_day" position="replace"/>
<field name="total_difference_day" position="replace"/>
<field name="total_timesheet_day" position="replace"/>
<field name="timesheet_ids" position="after">
<field name="day_difference"/>
<field name="day_timesheet"/>
</field>
<page string="By Day" position="replace" />
<notebook position="inside">
<page string="Time balance">
<group colspan="4" col="2" width="600">
<field name="time_account_balance"/>
<field name="working_hour"/>
<field name="attendance_hour"/>
<separator string="Timesheet numbers until the viewed working period." colspan="4" />
<field name="total_time_account_balance"/>
<field name="total_working_hour"/>
<field name="total_attendance_hour"/>
</group>
</page>
</notebook>
</data>
</field>
</record>
Then the Human Resources / Time Tracking / My Timesheet form totaly crash. But when I go to Administration / Customization / User Interface / Menu Items, and I choose "My Timesheet" menu item to fix its action from "ir.actions.server" to "ir.actions.act_window" and select object "hr_timesheet_sheet.sheet", then choose my view "oit.hr.timesheet.sheet.form" for object's form view, choose my view "oit.hr.timesheet.sheet.tree.simplified" for object's tree view.
Then I have "My Timesheet" form shown correctly.
Why is that? I think there is somethings in my view code not work with "My Timesheet" menu and "ir.actions.server" defined in file hr_timesheet_sheet/hr_timesheet_sheet_data.xml, Here I paste the openerp6 code in hr_timesheet_sheet_data.xml:
<record id="ir_actions_server_timsheet_sheet" model="ir.actions.server">
<field eval="5" name="sequence"/>
<field eval=""""code"""" name="state"/>
<field eval=""""ir.actions.server"""" name="type"/>
<field name="model_id" ref="model_hr_timesheet_current_open"/>
<field eval="[(6,0,[])]" name="child_ids"/>
<field eval=""""action = self.pool.get('hr.timesheet.current.open').open_timesheet(cr, uid, object.id, context)"""" name="code"/>
<field eval=""""True"""" name="condition"/>
<field eval=""""My Timesheet"""" name="name"/>
</record>
<record id="menu_act_hr_timesheet_sheet_form_my_current" model="ir.ui.menu">
<field name="name">My Timesheet</field>
<field eval="1" name="sequence"/>
<field name="parent_id" ref="hr_attendance.menu_hr_time_tracking"/>
<field name="icon">STOCK_JUSTIFY_FILL</field>
<field name="action" ref="ir_actions_server_timsheet_sheet"/>
</record>
Kindly please help me to have correct view code or a solution so that I will not need to change information for menu "My Timesheet" after I upgrade my custom module! thanks a lot!
I have a button as follows:
<button string="View Cancelled Applications" name="%(action_recruit_application)d" type="action" domain="[('state','=','cancel')]"/>
The action is as follows:
<record model="ir.actions.act_window" id="action_recruit_application">
<field name="name">Applications</field>
<field name="res_model">recruit.application</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_recruit_application_search"/>
</record>
Finally the search view is as follows:
<record model="ir.ui.view" id="view_recruit_application_search">
<field name="name">recruit.application.search</field>
<field name="model">recruit.application</field>
<field name="arch" type="xml">
<search string="Applications">
<field name="application_id"/>
<field name="name"/>
<field name="application_date"/>
<field name="state"/>
</search>
</field>
</record>
I can't seem to pass the 'state' = 'cancel' to the search view.
Could anyone please help me out?
Thanks in advance.
Try by adding context in the button.For example
<button string="View Cancelled Applications" name="%(action_recruit_application)d" type="action" domain="[('state','=','cancel')]" context="{'search_default_state':'cancel'}"/>