1

我正在用 Python 做一些功课。我需要为 OpenErp 6.1 创建一个新模块,当我尝试安装升级时,我会在弹出窗口中看到下一条消息:

OpenERP 警告
ValidateError
验证字段拱时发生错误:视图架构的 XML 无效!

我附上了我开发的代码。
谁能帮帮我。


__init__.py

import library

__openerp__.py

{
    'name' : "Library",
    'version' : "1.0",
    'depends' : [
        "base"
    ],
    'author' : "JuanRa",
    'category': 'Tools',
    'description': u"""  
Library - Cine, Música y Libros Este módulo se va a encargar de gestionar cine, música y libros. Además se puede marcar como leídas y configurar varias opciones.
    """,
    'website': '',
    'data': [    
        'library_view.xml',    
    ],
    'installable': True,   
}

库.py

import pdb 
import sys 
import time
import logging

from datetime import date, datetime, timedelta 
from openerp.osv import osv, fields 
from openerp.tools.translate import 


sys.setdefaultencoding('iso-8859-1')

class library(osv.Model):
    _name = 'library'
    _description = u'library class'

    def _get_global_score(self, cr, uid, ids, field_name, field_value, context = None):
        res = {}
        pdb.set_trace()
        for id in ids:
            res[id] = 0.0

        return res

    _columns = {
        'name': fields.char(_(u'Nombre del Libro'), size = 128, required = True),
        'year': fields.integer(_(u'Año de inicio')),
        'no_more_seassons': fields.boolean(_(u'No hay mas temporadas')),
        'is_serie': fields.boolean(_(u'¿Es serie?')),
        'global_score': fields.function(_get_global_score, type='float', digits=(12,2), string=_(u'Total puntuación')),
        'full_view': fields.boolean(_(u'Visualizado por completo')),
        #'line_ids': fields.one2many('library.lines', 'library_id', string=_(u'Líbros/Capítulos')),
    }

    _default = {
        'year': lambda self, cr, uid, ids: datetime.now().year,
    }

    def mark_as_seen(self, cr, uid, ids, context = None):
        osv.logging.log(100, "[JuanRa] mark_as_seen:library:library (%s)" % (uid))

        #Modelos
        mlibrary = self.pool.get('library')

        #Ejecucion
        mlibrary.write(cr, uid, ids, {'full_view': True}, context)

library_view.xml

<openerp>
    <data>

        <record id='view_library_form' model='ir.ui.view'>
            <field name='name'>view.library.form</field>
            <field name='model'>library</field>
            <field name='arch' type='xml'>
                <form string='Library' version='7.0'>
                    <sheet>
                        <group col='4'>
                            <group>
                                <field name='name' />
                                <field name='year' />
                                <field name='global_score' />
                            </group>
                            <group>
                                <field name='is_serie' />
                                <field name='no_more_seasons' attrs="{'invisible':[('is_seire','=',False)]}" />
                                <field name='full_view' />
                            </group>
                        </group>
                    </sheet>
                </form>
            </field>
        </record>

        <record id='view_library_tree' model='ir.ui.view'>
            <field name='name'>view.library.tree</field>
            <field name="model">library</field>
            <field name="arch" type='xml'>
                <tree string='Library' version='7.0' colors='green:full_view==True'>
                    <field name='name' />
                    <field name='year' />
                    <field name='global_score' />
                    <field name='full_view' />
                </tree>
            </field>                                            
        </record>

        <record id='view_library_search' model='ir.ui.view'>
            <field name="name">view.library.search</field>
            <field name="model">library</field>
            <field name="arch" type='xml'>
                <search string='Busqueda library' version='7.0'>
                    <field name='name' />
                    <field name='year' />

                    <filter string='Vistas' name='seen' domain="[('full_view', '=', True)]"/>
                    <filter string='No Vistas' name='unseen' domain="[('full_view', '=', False)]"/>
                    <filter string='No Vistas o que sean del 2014' name='unseen_year' domain="['|',('full_view', '=', False),('year','=','2014')]"/>

                    <group expand='1' string="Group by">
                        <filter name='group_by_year' string='Año' context="{('group_by':'year')}" />                    
                    </group>
                </search>
            </field>                                            
        </record>

        <record id='action_library_series_libros' model='ir.actions.act_window'>
            <field name="name">Series y Libros</field>
            <field name="res_model">library</field>
            <field name="view_mode">tree, form</field>
            <field name="view_type">form</field>
            <field name="search_view_id" ref="view_library_search"/>                                
        </record>

        <menuitem name="Library" id="menu_library_main" sequence="25" />
            <menuitem name="Library" id="menu_library_sub" sequence="1" parent="menu_library_main"/>
                <menuitem id="menu_library_series_libros" sequence="1" 
                          parent="menu_library_sub" action="action_library_series_libros" />

        <!-- Ejemplo de accion de servidor -->                
        <record id='action_server_mark_as_seen' model='ir.actions.server'>
            <field name="name">Marcar como vistas</field>
            <field name="condition">True</field>
            <field name="type">ir.actions.server</field>
            <field name="model_id" ref="model_library" />
            <field name="state">code</field>    
            <field name="code">self.mark_as_seen(cr, uid, context.get('active_ids', []), context=context)</field>
        </record>

        <!-- Ejemplo de llamada accion de servidor -->                
        <record id='ir.values' model='action_library_mark_as_seen'>
            <field name="name">Marcar como vistas</field>
            <field name="action_id" ref='action_server_mark_as_seen' />
            <field name="value" eval="'ir.actions.server,' + str(ref('action_server_mark_as_seen'))" />
            <field name="key">action</field>
            <field name="model_id" ref="model_library" />
            <field name="model">library</field>  
            <field name="key2">client_action_multi</field>                              
        </record>

    </data>
</openerp>
4

1 回答 1

0

<sheet> and </sheet> 从表单视图中删除。

于 2018-04-10T05:10:32.663 回答