Clicking on odoo menu show `Document empty` error - view

I am getting the following error on odoo 15.0 when clicking on menu Time Off/Approvals/Time Off
This menu is linked to the action
open_view_holiday_status
from odoo module's hr_holidays which in turn is linked to the view tree
view_holiday_status_normal_tree
I have extended that view the following way in a module named hr_holidays_base:
<record id="holiday_status_base_tree" model="ir.ui.view">
<field name="name">hr.holidays.status.tree</field>
<field name="model">hr.leave.type</field>
<field name="inherit_id" ref="hr_holidays.view_holiday_status_normal_tree" />
<field name="priority" eval="1" />
<field name="arch" type="xml">
<field name='display_name' position="after">
<field
name="max_leaves"
invisible="not context.get('active_id',False)"
/>
<field
name="leaves_taken"
invisible="not context.get('active_id',False)"
/>
<field
name="remaining_leaves"
invisible=" not context.get('active_id',False)"
/>
</field>
</field>
</record>
Note: i have a second view tree extending from it too:
<record id="secondary_holiday_status_base_tree" model="ir.ui.view">
<field name="name">secondary.hr.holidays.status.tree</field>
<field name="model">hr.leave.type</field>
<field name="inherit_id" ref="hr_holidays_base.holiday_status_base_tree" />
<field name="mode">primary</field>
<field name="priority" eval="15" />
<field name="arch" type="xml">
<field name="company_id" position="attributes">
<attribute name="invisible">1</attribute>
</field>
</field>
</record>
Now getting the error:
Error:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/odoo/http.py", line 643, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/usr/local/lib/python3.10/dist-packages/odoo/http.py", line 301, in _handle_exception
raise exception.with_traceback(None) from new_cause
File "<string>", line 1
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
What could go wrong? any hint maybe?
I have tried following the execution of every step by step. I have searched these defined views from the UI and they work well individually. The only issue is when trying on that menu and this is where it shows the error

Related

Create a new tree view in Odoo13

I´m trying to create a new tree view for the invoices in Odoo 13
my code looks like this:
<odoo>
<record model="ir.ui.view" id="new_invoice_tree">
<field name="name">New Tree</field>
<field name="model">account.move</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree>
<field name="custom_field_1"/>
<field name="custom_field_2"/>
</tree>
</field>
</record>
<record id="my_module.new_tree_action_window" model="ir.actions.act_window">
<field name="name">New tree</field>
<field name="res_model">account.move</field>
<field name="view_mode">tree</field>
<field name="view_id" ref="new_invoice_tree"/>
<field name="type">ir.actions.act_window</field>
<field name="domain">[('type','=','out_invoice')]</field>
</record>
<menuitem name="Libro de ventas"
id="my_module.new_tree_menu"
parent="my_parent_menu"
action="my_module.new_tree_action_window"
sequence="1"/>
</odoo>
But when I try to open the menu appears this error:
Rastreo de error:
Error: Unknown field state in domain
at Class.compute (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:322:55)
at evalModifier (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:1197:91)
at Class._evalModifiers (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:1200:44)
at Class._registerModifiers (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:1401:101)
at Class._renderBodyCell (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:2076:70)
at http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:2100:117
at Array.map (<anonymous>)
at Class._renderRow [as _super] (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:2100:80)
at Class._renderRow (http://192.168.1.7:8070/web/content/317-6c3bb5c/web.assets_backend.js:2010:69)
at Class._renderRow (http://192.168.1.7:8070/web/content/312-75a923f/web.assets_common.js:3863:371)
I´m not sure how my domain should look like, what´s what I´m doing wrong?
The way to avoid this kind of error is by adding the "state" field with the attribute invisible as True, like this:
<odoo>
<record model="ir.ui.view" id="new_invoice_tree">
<field name="name">New Tree</field>
<field name="model">account.move</field>
<field name="type">tree</field>
<field name="arch" type="xml">
<tree>
<field name="state" invisible="True"/>
<field name="custom_field_1"/>
<field name="custom_field_2"/>
</tree>
</field>
</record>
This error appears on databases that are working with the Enterprise version of Odoo.

Problem with adding a custom field to existing view

[![enter image description here][1]][1]I have a problem with adding a new field to the sale order view of odoo12. I have created a new module. I hope that you can help me.
Below the code of my view form
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml"></field>
<field name="payment_term_id" position="after">
<field name="additional_note"/>
</field>
</record>
</odoo>```
when i try to install the new module i have the following error:
File "src\lxml\etree.pyx", line 3557, in lxml.etree._Validator.assert_
AssertionError: Element odoo has extra content: record, line 3
[1]: https://i.stack.imgur.com/e1DOw.png
The problem is in the <field name="arch" type="xml"></field> line: the <field> tag is closed, and your additional_note field is declared outside of it.
Try this code instead:
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<!-- Leave the 'arch' field open -->
<field name="arch" type="xml">
<!-- Put your custom field and its position inside the 'arch' field.
Use 'xpath' tag to create a more precise positioning -->
<xpath expr="//group/group/field[#name='payment_term_id']" position="after">
<field name="additional_note"/>
</xpath>
<!-- Now, close the 'arch' field -->
</field>
</record>
</odoo>
The view is not correctly defined, you can refer to account_analytic_view.
The view definition should be (according to the provided link):
<odoo>
<record id="view_order_form_inherit" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<data>
<field name="payment_term_id" position="after">
<field name="additional_note"/>
</field>
</data>
</field>
</record>
</odoo>

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>

How to manage security of model, such as only sales manager should be able to create, delete, write and read those records in odoo 10

I am new in odoo and want know how to manage security in module,
O have created one model and now gives group that can only see my
record view, see below code that I have tried,
<record id="view_account_supplier_payment_tree" model="ir.ui.view">
<field name="name">account.supplier.payment.tree</field>
<field name="model">account.payment</field>
<field name="arch" type="xml">
<tree decoration-info="state=='draft'" decoration-muted="state=='reconciled'" edit="false">
<field name="payment_date"/>
<field name="name"/>
<field name="journal_id"/>
<field name="payment_method_id"/>
<field name="partner_id" string="Vendor"/>
<field name="amount" sum="Amount"/>
<field name="company_id" groups="base.group_multi_company"/>
<field name="state"/>
<field name="currency_id" invisible="1"/>
<field name="partner_type" invisible="1"/>
</tree>
</field>
</record>
Make an ir.model.access.csv file to manage security,
this file also mention in manifest file.

Odoo use both inherited Tree View and Parent Tree View

I created a special tree view for res.partner that help me modify records on the fly.
I put this view in a special Menu: test Configuration / Modification Rapide / Modification Contacts.
Everything is working fine expect that whenever there's a res.partner tree it's my tree view that is used.
Is there a way to use my custom tree view only from my Custom menu.
and every place else is the default tree view that is used ?
<record model="ir.ui.view" id="view_test_contact_tree">
<field name="name">res.partner.tree.inherit</field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<field name="email" position="replace" />
<field name="phone" position="replace" />
<xpath expr="//tree[#string='Contacts']" position="attributes">
<attribute name="editable">bottom</attribute>
</xpath>
<xpath expr="/tree/field[#name='display_name']" position="before">
<field name="isBuyer" string="A"/>
<field name="isSeller" string="V"/>
<field name="isSupplier" string="F"/>
<field name="isMiddle" string="I"/>
<field name="isBackOffice" string="B"/>
</xpath>
<xpath expr="/tree/field[#name='display_name']" position="after">
<field name="mobile"/>
<field name="phone"/>
<field name="email"/>
</xpath>
</field>
</record>
<record model="ir.actions.act_window" id="action_res_partner_rel10">
<field name="name">Menu</field>
<field name="res_model">res.partner</field>
<field name="view_mode">tree</field>
</record>
<menuitem name="test Configuration" id="test_config_id" sequence="450"/>
<menuitem name="Modification Rapide" id="modif_id" parent="test_contact.test_config_id" sequence="20" />
<menuitem name="Modification Contacts" id="sub_gestion_modif_id" parent="modif_id" sequence="11" action="action_res_partner_rel10"/>
As I understand you want to show your own created tree view in this menu.
So for this you have to pass your create tree view in ref of action to open your tree view
Like:
<record id="action_quotations" model="ir.actions.act_window">
<field name="name">Quotations</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_quotation_tree"/> <======= your tree view id
<field name="view_mode">tree,form,calendar,graph</field>
<field name="context">{'search_default_my_sale_orders_filter': 1}</field>
<field name="domain">[('state','in',('draft','sent','cancel'))]</field>
</record>
you have not have to inherit exits view and change in this, instead of create new tree view and pass in actions
Hope this help

Resources