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

ValidateError while creating new view

By
biligsaikhan
on 10/22/14, 11:08 PM 873 views

I keep getting this error while trying to parse xml with new views. 

ParseError: "ValidateError Field(s) `arch` failed against a constraint: Invalid view definition

my code for xml

<?xml version="1.0" encoding="utf-8"?>
<openerp>    
<data>


<!--Daily Transaction List View  -->
    <record id="daily_transaction_tree_view" model="ir.ui.view">
     <field name="name">daily.transaction.tree</field>
     <field name="model">daily.transaction</field>
    <field name="arch" type="xml">            
 <!-- this will be our title of list/tree view   -->            
    <tree string="Daily Transaction">                
 <!-- these will automatically map table headers for our list view, so we’ll select out column names of our model here  -->          
    <field name="name"/>               
    <field name="date"/>               
    <field name="type"/>                 
    <field name="amount"/>                   
    </tree>             
    </field>
    </record>     

<!--Daily Transaction Form View-->    
    <record id="daily_transaction_form_view" model="ir.ui.view">
     <field name="name">daily.transaction.form</field>
     <field name="model">daily.transaction</field>     
    <field name="arch" type="xml">            
<!-- this will be our title of list/tree view -->            
    <form string="Daily Transaction" version="8.0">                
    <group>                    
    <field name="name"/>                    
    <field name="date"/>                    
    <field name="type"/>
    <field name="amount"/>                     
    <field name="note"/>                                   
    </group>             
    </form>        
    </field>    
    </record>

    <record id="action_daily_transaction" model="ir.actions.act_window">        
    <field name="name">Daily Transaction</field>        <!-- name of action -->
    <field name="res_model">daily.transaction</field>        <!-- this action will be mapped to model specified -->
    <field name="view_type">form</field>        
    <field name="view_mode">tree, form</field>        <!-- these are type of view our module will show for our daily transaction mode  -->
    <field name="search_view_id"  eval="False"/>        <!-- here we specify id of our search view -->
    <field name="context">{}</field>        
    <field name="help">Create new daily transaction.</field>    <!-- help text for our model -->
    </record> 
    
    <!-- Main Menu Related Info -->
    <menuitem name="Daily Transaction" id="base.daily_transaction_root" sequence="60"/>

    <!-- Sub Menu Related Info -->
    <menuitem id="menu_daily_transaction_root" name="Daily Transaction"
    parent="base.daily_transaction_root" sequence="1"/>
    
    <!-- Action Menu Related Info -->
    <menuitem action="action_daily_transaction" id="menu_action_daily_transaction"
    parent="menu_daily_transaction_root" sequence="20"/>
    
    </data>
    </openerp>

my code for py

from openerp.osv import fields, osv

class daily_transaction(osv.osv):
    _name = 'daily.transaction'
    _description = 'Daily Transaction'
    
    
    _columns = {

        'name':  fields.char('Name', size=128, required=True),
        'subject': fields.char('Subject', size=128, required=True),
        'date': fields.date('Date', required=True),
        'note': fields.text('Notes'),
        'amount': fields.float('Amount', required=True),
        'type': fields.selection([
            ('transport', 'Transport'),
            ('household', 'Household'),
            ('personal', 'Personal'),
            ], required=True),
            
    }

0

Ben Bernard

--Ben Bernard--
1083
| 4 3 6
Jakarta, Indonesia
--Ben Bernard--
Ben Bernard
On 10/23/14, 12:04 AM

I think you should explicitly define "name" field in daily_transaction model.

And, the "subject" field should be defined in the view because it's required.

0

Med Said BARA

--Med Said BARA--
2664
| 5 5 7
Algeria
--Med Said BARA--
Med Said BARA
On 10/23/14, 7:00 AM

Try to post the error message from your .log file

Between time try to Copy/Paste the following parsed code:

 

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <!--Daily Transaction List View  -->
        <record id="daily_transaction_tree_view" model="ir.ui.view">
            <field name="name">daily.transaction.tree</field>
            <field name="model">daily.transaction</field>
            <field name="arch" type="xml">
                <!-- this will be our title of list/tree view   -->
                <tree string="Daily Transaction">
                    <!-- these will automatically map table headers for our list view, so we’ll select out column names of our model here  -->
                    <field name="name"/>
                    <field name="date"/>
                    <field name="type"/>
                    <field name="amount"/>
                </tree>
            </field>
        </record>
        <!--Daily Transaction Form View-->
        <record id="daily_transaction_form_view" model="ir.ui.view">
            <field name="name">daily.transaction.form</field>
            <field name="model">daily.transaction</field>
            <field name="arch" type="xml">
                <!-- this will be our title of list/tree view -->
                <form string="Daily Transaction" version="8.0">
                    <group>
                        <field name="name"/>
                        <field name="date"/>
                        <field name="type"/>
                        <field name="amount"/>
                        <field name="note"/>
                    </group>
                </form>
            </field>
        </record>
        <record id="action_daily_transaction" model="ir.actions.act_window">
            <field name="name">Daily Transaction</field>
            <!-- name of action -->
            <field name="res_model">daily.transaction</field>
            <!-- this action will be mapped to model specified -->
            <field name="view_type">form</field>
            <field name="view_mode">tree, form</field>
            <!-- these are type of view our module will show for our daily transaction mode  -->
            <field name="search_view_id"  eval="False"/>
            <!-- here we specify id of our search view -->
            <field name="context">{}</field>
            <field name="help">Create new daily transaction.</field>
            <!-- help text for our model -->
        </record>
        <!-- Main Menu Related Info -->
        <menuitem name="Daily Transaction" id="base.daily_transaction_root" sequence="60"/>
        <!-- Sub Menu Related Info -->
        <menuitem id="menu_daily_transaction_root" name="Daily Transaction"
        parent="base.daily_transaction_root" sequence="1"/>
        <!-- Action Menu Related Info -->
        <menuitem action="action_daily_transaction" id="menu_action_daily_transaction"
        parent="menu_daily_transaction_root" sequence="20"/>
    </data>
</openerp>

 

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

2 follower(s)

Stats

Asked: 10/22/14, 11:08 PM
Seen: 873 times
Last updated: 3/16/15, 8:10 AM