Multiple views in menuitem odoo - odoo-9

I try to create a menuitem + action + tree base + form with inherit
I do not want to replace the view that is used in the rest of oudoo
But not working
Odoo 9
thx for help D:
My xml file with records
<menuitem id="menu_picking_listing" name="Picking List" parent="purchase.menu_procurement_management" sequence="20" action="action_picking_listing"/>
<record model="ir.actions.act_window" id="action_picking_listing">
<field name="name">JobApplication Application</field>
<field name="type">ir.actions.act_window</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 Job.</p>
</field>
<field name="res_model">stock.picking</field>
</record>
<record model="ir.actions.act_window.view" id="action_picking_listing_tree">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="stock.vpicktree"/>
<field name="act_window_id" ref="action_picking_listing"/>
</record>
<record model="ir.actions.act_window.view" id="action_picking_listing_form">
<field name="sequence" eval="2"/>
<!--<field name="model">stock.picking</field>-->
<field name="view_mode">form</field>
<field name="view_id" ref="stock.view_picking_form"/>
<field name="act_window_id" ref="action_picking_listing"/>
<field name="arch" type="xml">
<notebook position="after">
<page string="Landed Costs">
<field name="landed_costs" colspan="4" nolabel="1" />
</page>
</notebook>
</field>
</record>

Solution:
XML View
-->
<!-- Definimos un menuitem donde el action es el id del dispatcher de action -->
<menuitem id="menu_picking_listing" name="Picking List" parent="purchase.menu_procurement_management" sequence="20" action="action_picking_listing"/>
<!-- Este es el dispatcher de acciones -->
<record model="ir.actions.act_window" id="action_picking_listing">
<field name="name">Picking List</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">stock.picking</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Definimos la vista tree y con el view_id le decimos cual es -->
<record id="accion_vista_arbol_default" model="ir.actions.act_window.view">
<field eval="15" name="sequence"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="stock.vpicktree"/>
<field name="act_window_id" ref="action_picking_listing"/>
</record>
<!-- Definimos la vista form y con el view_id le decimos cual es -->
<record id="accion_vista_formulario_conlanded" model="ir.actions.act_window.view">
<field eval="15" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="stock_landed_costs_fields.sale_picking_listing_form"/>
<field name="act_window_id" ref="action_picking_listing"/>
</record>
<!-- Definimos la vista nueva independiente de todo con un name nuevo y con mode primary le decimos que sea a parte, no heredado -->
<record model="ir.ui.view" id="sale_picking_listing_form">
<field name="name">stock.picking.form.inherit</field>
<field name="model">stock.picking</field>
<field name="mode">primary</field> <!-- Con esto digo que NO es herencia, que es una vista a parte -->
<field name="inherit_id" ref="stock.view_picking_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page string="Landed Costs">
<field name="landed_costs" colspan="4" nolabel="1" />
</page>
</notebook>
</field>
</record>
</data>

Related

AssertionError: Element odoo has extra content: record, line 4

I'm trying to add multi field to timesheet module to work as a tasks manage app i did inheritance to account.analytic.line the problem is in the view i got that error "AssertionError: Element odoo has extra content: record, line 4"
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="todo_timesheet_line_tree" model="ir.ui.view">
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree"/>
<field name="model">account.analytic.line</field>
<field name="arch" type="xml"/>
<field name="task_id" position="after">
<field name="priority"/>
</field>
<field name="company_id" groups="base.group_multi_company" position="before">
<field name="gov_department"/>
<field name="priority"/>
<field name="date_deadline"/>
</field>
</record>
</odoo>
from odoo import models, fields, api
class TodoTask(models.Model):
_inherit = 'account.analytic.line'
startdate=fields.Date('start Date', required=True, index=True, default=fields.Date.context_today)
date_deadline=fields.Date('Deadline', required=True, index=True, default=fields.Date.context_today)
priority = fields.Selection(selection=[('1', 'فوري'), ('2','هام جدا' ),('3','اقل اهمية')])
is_done = fields.Boolean ('Done?')
gov_department = fields.Many2one('govauthority','الجهة الحكومية')
class govauthority(models.Model):
govname = fields.Char('GOV_Department', size=25, required=True)
The error is in this line
<field name="arch" type="xml" />
You closed the tag while you really should not. Within this tag the actual XML body should be.
<record id="todo_timesheet_line_tree" model="ir.ui.view">
<field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
<field name="model">account.analytic.line</field>
<field name="arch" type="xml">
<field name="task_id" position="after">
<field name="priority" />
</field>
<field name="company_id" groups="base.group_multi_company" position="before">
<field name="gov_department" />
<field name="priority" />
<field name="date_deadline" />
</field>
</field>
</record>

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>

I am getting AssertionError: Element openerp has extra content: data, line 2

I am trying to install a module, then I am getting below error.
AssertionError: Element openerp has extra content: data, line 2
What type of mistake I did for getting this error.
In which file I have to search for error rectify. I am using odoo9.
Files:
This is my xmlfile.xml
<data>
<record model="ir.ui.view" id="10">
<field name="name">model.name</field>
<field name="model">smp.model2</field>
<field name="arch" type="xml">
<form>
<sheet>
<group colspan="4">
<group colspan="2" cal="2">
<field name="name"/>
<field name="active"/>
</group>
<group colspan="2" cal="2">
<field name="age"/>
<field name="sal"/>
</group>
<group colspan="2" cal="2">
<field name="adharid"/>
<field name="cell"/>
</group>
<notebook colspan="4">
<page string="extrainfo"><field name="extrainfo"/></page>
<page string="temporaryaddress"><field name="temporaryaddress"/></page>
<page string="perminantaddress"><field name="perminantaddress"/></page>
</notebook>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="20">
<field name="name">model.name</field>
<field name="model">smp.model2</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="active"/>
<field name="age"/>
<field name="sal"/>
<field name="adharid"/>
<field name="cell"/>
<field name="extrainfo"/>
<field name="temporaryaddress"/>
<field name="perminantaddress"/>
</tree>
</field>
</record>
<record model ="ir.actions.act_window" id="action_smp_model2">
<field name="name">sampmodel</field>
<field name="res_model">smp.model2</field>
<field name="view_type">form</field>
<field name="viwe_mode">tree,form</field>
</record>
<menuitem id="smp_main_menu1" name="smp model2"/>
<menuitem id="subsmp_main_menu1" name="Sub sample model"
parent="smp_main_menu1"/>
<menuitem id="actsmp_main_menu" name="action smp model"
parent="subsmp_main_menu1" action="action_smp_model2"/>
</data>
</openerp>
This is my data.xml file
<data>
<record id='1' name="smp.model2">
<filed name="name">name1</filed>
<filed name="age">23</filed>
<filed name="cell">123456434</filed>
</record>
<record id='2' name="smp.model2">
<filed name="name">name1</filed>
<filed name="age">23</filed>
<filed name="cell">123456434</filed>
</record>
<record id='3' name="smp.model2">
<filed name="name">name1</filed>
<filed name="age">23</filed>
<filed name="cell">123456434</filed>
</record>
</data>
</openerp>
This is python_file.py
from openerp import models,fields
class model2(models.Model):
_name="smp.model2"
name=fields.Char(string="model name", requred=True, help="name of the
model")
active=fields.Boolean(String="Active")
age=fields.Integer(string="person age",help="age of person")
sal=fields.Integer(string="sal")
adharid=fields.Integer(string="Adhar Id")
cell=fields.Integer(string="phone number",requred=True)
extrainfo=fields.Text(string="Extra information")
temporaryaddress=fields.Text(string="Temporary address")
perminantaddress=fields.Text(string="perminant address")
This is __openerp__.py file
{
'name':'module12',
'description':'module12',
'author':'naveen',
'version':'9.0',
'depends':['base'],
'data':['xmlfile.xml','data.xml']
}
you have errors in a xml, example:
requred=True is required=True
<filed is <field

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")

Resources