openErp 6.1 AttributeError:' NoneType'对象没有属性' _columns'在自定义模块安装

时间:2017-04-09 11:52:51

标签: python openerp-6

我试图解决openERP 6.1中自定义模块的安装问题。

我收到此错误:

class BarChartViewController: UIViewController, ChartViewDelegate {

    @IBOutlet weak var barChartView: BarChartView!

    let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        barChartView.delegate = self
        barChartView.xAxis.valueFormatter = self

        let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 16.0, 4.0, 18.0, 2.0, 4.0, 5.0, 4.0]
        setChart(values: unitsSold)
    }

    func setChart(values: [Double]) {
        barChartView.noDataText = "You need to provide data for the chart."

        let chartData = BarChartDataSet()
        for (i, val) in values.enumerated(){
            _ = chartData.addEntry(BarChartDataEntry(x: Double(i), y: val))
        }
        barChartView.data = BarChartData(dataSet: chartData)
    }
}

extension BarChartViewController: IAxisValueFormatter{
    func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        return months[ Int(value) % months.count]
    }
}

我认为我的模型定义存在问题,但我无法找到问题所在。

这是型号代码:

    Server Traceback (most recent call last):
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\openerp\addons\web\common\http.py", line 593, in send
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\netsvc.py", line 360, in dispatch_rpc
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\service\web_services.py", line 586, in dispatch
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\osv\osv.py", line 186, in execute_kw
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\osv\osv.py", line 129, in wrapper
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\osv\osv.py", line 195, in execute
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\osv\osv.py", line 183, in execute_cr
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\openerp\addons\base\module\wizard\base_module_upgrade.py", line 101, in upgrade_module
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\pooler.py", line 39, in restart_pool
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\modules\registry.py", line 202, in new
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\modules\loading.py", line 338, in load_modules
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\modules\loading.py", line 253, in load_marked_modules
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\modules\loading.py", line 192, in load_module_graph
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\modules\loading.py", line 90, in <lambda>
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\modules\loading.py", line 138, in _load_data
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\tools\convert.py", line 998, in convert_xml_import
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\tools\convert.py", line 890, in parse
  File "C:\Archivos de programa\OpenERP 6.1-20140210-004940\Server\server\.\openerp\tools\convert.py", line 818, in _tag_record AttributeError: 'NoneType' object has no attribute '_columns'

这是观点:

 from osv import osv, fields 
from tools.translate import _

from datetime import date

import time


class adventure_sports_sport_type(osv.osv):
    _name = 'adventure_sports.sport_type'
    _columns = {
        'name': fields.char('name', size=64, required=True, translate=True, help='The name of the sport'),
        'level': fields.selection([('aHigh', 'High'), ('aMedium', 'Medium'), ('cLow', 'Low')], 'level',
                                  required=True),
        'activities': fields.one2many('adventure_sports.activity', 'sport_type_id', 'Activities')
    }
    _defaults = {
        'level': lambda *a: 'medium',
    }
    _order = 'name, level'
adventure_sports_sport_type()


class adventure_sports_activity(osv.osv):
    _name = 'adventure_sports.activity'
    _columns = {
        'name': fields.char('Activity name', size=64, required=True, translate=True, help='The name of the activity'),
        'sport_type_id': fields.many2one('adventure_sports.sport_type', 'Sport type', ondelete='cascade',
                                         help='sport_type_id'),
        'current': fields.boolean('Current'),
        'is_available_monday': fields.boolean('Monday'),
        'is_available_tuesday': fields.boolean('Tuesday'),
        'is_available_wednesday': fields.boolean('Wednesday'),
        'is_available_thursday': fields.boolean('Thursday'),
        'is_available_friday': fields.boolean('Friday'),
        'is_available_saturday': fields.boolean('Saturday'),
        'is_available_sunday': fields.boolean('Sunday'),
        'start_time': fields.float('Start time'),
        'end_time': fields.float('End time'),
        'images': fields.one2many('adventure_sports.image', 'activity_id', 'Images'),
    }
    _defaults = {
        'is_active': True,
    }
adventure_sports_activity()


class adventure_sports_activity_image(osv.osv):
    _name = 'adventure_sports.activity_image'
    _columns = {
        'image': fields.binary('Image', filters='*.png,*.jpg,*.gif'),
        'description': fields.char('Description', size=500, required=True, translate=True),
        'activity_id': fields.many2one('adventure_sports.activity', 'Activity', readonly=True)
    }
adventure_sports_activity_image()

这是我的__openerp__.py文件:

    <?xml version="1.0"?>
<openerp>
<data>

    <record model="ir.ui.view" id="view_activities_catalog_tree">
        <field name="name">view.activities.catalog.tree</field>
        <field name="model">adventure_sports.activity</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="view.activities.catalog.tree" editable="bottom">
                <field name="name"/>
                <field name="level"/>
            </tree>
        </field>
    </record>

    <record model="ir.ui.view" id="view_activities_catalog_search">
        <field name="name">view.activities.catalog.search</field>
        <field name="model">adventure_sports.activity</field>
        <field name="type">search</field>
        <field name="arch" type="xml">
            <search string="Catalog Activities">
                <group col="6" colspan="4">
                    <filter string="MONDAY" icon="terp-go-today" domain="[('is_available_monday', '=', True)]"/>
                    <filter string="TUESDAY" icon="terp-go-today" domain="[('is_available_tuesday', '=', True)]"/>
                    <filter string="WEDNESDAY" icon="terp-go-today" domain="[('is_available_wednesday', '=', True)]"/>
                    <filter string="THURSDAY" icon="terp-go-today" domain="[('is_available_thursday', '=', True)]"/>
                    <filter string="FRIDAY" icon="terp-go-today" domain="[('is_available_friday', '=', True)]"/>
                    <filter string="SATURDAY" icon="terp-go-today" domain="[('is_available_saturday', '=', True)]"/>
                    <filter string="SUNDAY" icon="terp-go-today" domain="[('is_available_sunday', '=', True)]"/>
                    <field name="sport_type_id" widget="selection"/>
                    <field name="name"/>
                    <field name="current" widget="selection"/>
                </group>
                <field name="images" select="1"/>
            </search>
        </field>
    </record>

    <record model="ir.actions.act_windows" id="action_activities_catalog">
        <field name="name">action.activities.catalog</field>
        <field name="res_model">adventure_sports.activity</field>
        <field name="view_type">form</field>
        <field name="view_mode">search,tree</field>
    </record>


    <record model="ir.ui.view" id="view_sport_types_tree">
        <field name="name">sport.type.tree</field>
        <field name="model">adventure_sports.sport_type</field>
        <field name="type">tree</field>
        <field name="arch" type="xml">
            <tree string="adventure_sports.sport_type" editable="bottom">
                <field name="name"/>
                <field name="level"/>
            </tree>
        </field>
    </record>

    <record model="ir.actions.act_window" id="action_sport_types">
        <field name="name">Sport Types</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="res_model">adventure_sports.sport_type</field>
    </record>

    <menuitem
            id="adventure_sports_menu"
            name="Adventure Sports"
            web_icon="icons/adventure_sports.png"
            web_icon_hover="icons/adventure_sports_hover.png"
    />
    <menuitem
        id="configuration_menu"
        name="Configuration"
        parent="adventure_sports_menu"
    />
    <menuitem
        id="sport_types"
        name="Sport Types"
        action="action_sport_types"
        parent="configuration_menu"
    />
    <menuitem
        id="catalog_activities"
        name="Catalog Activities"
        action="action_activities_catalog"
        parent="configuration_menu"
    />
</data>
</openerp>

我已经检查了openerp.py文件中的模块依赖项,一切似乎都没问题。

拜托,有人可以帮助我吗?

非常感谢。

1 个答案:

答案 0 :(得分:0)

解决!这是xml中的拼写问题:

我改变了这个:

<record model="ir.actions.act_windows" id="action_activities_catalog">
        <field name="name">action.activities.catalog</field>
        <field name="res_model">adventure_sports.activity</field>
        <field name="view_type">form</field>
        <field name="view_mode">search,tree</field>
 </record>

为此:

<record model="ir.actions.act_window" id="action_activities_catalog">
        <field name="name">action.activities.catalog</field>
        <field name="res_model">adventure_sports.activity</field>
        <field name="view_type">form</field>
        <field name="view_mode">search,tree</field>
 </record>