Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Timesheet Activities Invalid XML for View Architecture!'

By
oussama Lachiheb
on 6/2/13, 12:30 PM 1,614 views

Hi , I'm working on openErp 7.0 ,on the module Timesheet i want to add 2 attributes to the tree view (start_at and end_at) but when updating the module i have the following error message : * Invalid XML for View Architecture!'* would some one tell me what i should correct in the following xml and python code : My XML hr_timesheet_view.xml

<record id="hr_timesheet_line_tree" model="ir.ui.view">
        <field name="name">hr.analytic.timesheet.tree</field>
        <field name="model">hr.analytic.timesheet</field>
        <field name="arch" type="xml">
            <tree editable="top" string="Timesheet Activities" version="7.0">                  
                <field name="date" on_change="on_change_date(date)"/>
                <field name="user_id" on_change="on_change_user_id(user_id)" required="1" options='{"no_open": True}'/>
                <field name="name"/>
                <field domain="[('type','=','normal'),('use_timesheets','=',1)]" name="account_id" context="{'default_use_timesheets': 1, 'default_type': 'contract'}"/>                                        
                <field name="unit_amount" string="Duration" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" sum="Total time" widget="float_time"/>                    
                <field name="start_at"/>
                <field name="end_at"/>
                <field name="product_uom_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" invisible="1"/>
                <field name="journal_id" invisible="1"/>                    
                <field name="amount" sum="Total cost" invisible="1"/>
                <field name="general_account_id" invisible="1"/>
                <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" required="1" domain="[('type','=','service')]" invisible="1"/>
            </tree>
        </field>
    </record>

my python code :

class hr_analytic_timesheet(osv.osv):
_name = "hr.analytic.timesheet"
_table = 'hr_analytic_timesheet'
_description = "Timesheet Line"
_inherits = {'account.analytic.line': 'line_id'}
_order = "id desc"
_columns = {
    'line_id': fields.many2one('account.analytic.line', 'Analytic Line', ondelete='cascade', required=True),
    'partner_id': fields.related('account_id', 'partner_id', type='many2one', string='Partner', relation='res.partner', store=True),                
    'start_at':fields.text('from'),
    'end_at':fields.text('to'),

}

With regards

3

Borni DHIFI

--Borni DHIFI--
5102
| 6 8 9
Tunis, Tunisia
--Borni DHIFI--

Techno Functional Consultant Odoo(OpenERP) 

http://www.linkedin.com/in/borni

Skype : dhifi.borni

Borni DHIFI
On 6/2/13, 6:29 PM

Hi,

should not modify the original code openerp , if you want add fields must create a

new module :

your_file.py

from osv import osv, fields
class hr_analytic_timesheet(osv.osv):
    _inherit = "hr.analytic.timesheet"
    _columns = {
               'start_at':fields.char('from'),
               'end_at':fields.char('to'),
                }          
hr_analytic_timesheet()

your_file.xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="ir.ui.view" id="hr_timesheet_inherit">
            <field name="name">hr_timesheet_inherit_tree</field>
            <field name="model">hr.analytic.timesheet</field>
            <field name="type">form</field>
            <field name="inherit_id" ref="hr_timesheet.hr_timesheet_line_tree" />
            <field name="arch" type="xml">
                <xpath expr="//field[@name='unit_amount']" position="after">
                    <field name="start_at" />
                    <field name="end_at" />
                </xpath>

            </field>
        </record>
    </data>
</openerp>

Another thing to do when modifying code, is to restart the openERP server, than reload the module (Settings -> installed modules -> search for module and click on it -> Click button Upgrade)

patrick
on 6/2/13, 6:45 PM

Thank's a lot , it works now :)

oussama Lachiheb
on 6/2/13, 7:37 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

0 follower(s)

Stats

Asked: 6/2/13, 12:30 PM
Seen: 1614 times
Last updated: 3/16/15, 8:10 AM