字段'字段'不存在 - Odoo v10社区

时间:2017-02-28 19:04:05

标签: python openerp odoo-10

我有这堂课:

from odoo import fields, models, api

class ResCompany(models.Model):
_inherit = 'res.company'

jour_id = fields.Many2one('account.journal', string='Journal', required=False,
    help="Default journal for damaged invoices")
acc_id = fields.Many2one('account.account', string='Account', required=False,
    help="Default account used for invoices and lines from damaged invoices")
printer_fiscal = fields.Boolean(string='Manages fiscal printer',
    help='Indicates that the company can operate a fiscal printer')

@api.model
def create(self, cr, uid, vals, context=None):
    """ To create a new record,
    adds a Boolean field to true
    indicates that the partner is a company
    """
    if context is None:
        context = {}
    context.update({'create_company': True})
    return super(ResCompany, self).create(cr, uid, vals, context=context)

@api.multi
def write(self, cr, uid, ids, values, context=None):
    """ To write a new record,
    adds a Boolean field to true
    indicates that the partner is a company
    """
    context = dict(context or {})
    context.update({'create_company': True})
    return super(ResCompany, self).write(cr, uid, ids, values,
                                         context=context)

这就是它的观点:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
  <data>
    <record id="view_account_config_settings2" model="ir.ui.view">
        <field name="name">account settings2</field>
        <field name="model">account.config.settings</field>
        <field name="arch" type="xml">
            <form string="Configure Accounting" class="oe_form_configuration">
                 <separator string="Invoice Damaged" groups="account.group_account_user"/>
                    <group name="fr1_grp" string="Damaged Invoices Info">
                        <field name="jour_id"/>
                        <newline/>
                        <field name="acc_id" domain="[('type','in',('other','receivable','payable'))]"/>
                    </group>
                    <group name="fr2_grp" string="Does This Company Use Fiscal Printer?">
                        <field name="printer_fiscal"/>
                    </group>
            </form>
        </field>
    </record>
  </data>
</odoo>

它在视图验证时抛出了这个错误:

2017-02-28 18:48:17,540 6919 ERROR gilda_1 werkzeug: Error on request:
Traceback (most recent call last):
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/server.py", line 246, in app
return self.app(e, s)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 1306, in __call__
return self.dispatch(environ, start_response)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/http.py", line 1454, in dispatch
odoo.registry(db).check_signaling()
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/__init__.py", line 55, in registry
return modules.registry.Registry(database_name)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/modules/registry.py", line 55, in __new__
return cls.new(db_name)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/modules/registry.py", line 78, in new
odoo.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/modules/loading.py", line 333, in load_modules
force, status, report, loaded_modules, update_module)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/modules/loading.py", line 235, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/home/kristian/.virtualenvs/odoov10/lib/python2.7/site-packages/odoo-10.0rc1c_20161005-py2.7.egg/odoo/modules/loading.py", line 177, in load_module_graph
env['ir.ui.view']._validate_module_views(module_name)
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/base/ir/ir_ui_view.py", line 1171, in _validate_module_views
self.raise_view_error("Can't validate view: %s" % e.message, vid)
File "/home/kristian/odoov10/odoo-10.0rc1c-20161005/odoo/addons/base/ir/ir_ui_view.py", line 445, in raise_view_error
raise ValueError(message)
ValueError: Can't validate view: El campo `acc_id` no existe

Error de contexto:
Vista `account settings2`
[view_id: 895, xml_id:    l10n_ve_fiscal_requirements.view_account_config_settings2, model:  account.config.settings, parent_id: n/a]

它表示无法验证视图,因为字段acc_id不存在。

但它就在那里,即使在Odoo v10社区必须使用string标志。

有人能指出我这里可能出现的问题吗?

1 个答案:

答案 0 :(得分:2)

字段import numpy as np import matplotlib as plt x = np.array([45, 68, 41, 87, 61, 44, 67, 30, 54, 8, 39, 60, 37, 50, 19, 86, 42, 29, 32, 61, 25, 77, 62, 98, 47, 36, 15, 40, 9, 25, 34, 50, 61, 75, 51, 96, 20, 13, 18, 35, 43, 88, 25, 95, 68, 81, 29, 41, 45, 87,45, 68, 41, 87, 61, 44, 67, 30, 54, 8, 39, 60, 37, 50, 19, 86, 42, 29, 32, 61, 25, 77, 62, 98, 47, 36, 15, 40, 9, 25, 34, 50, 61, 75, 51, 96, 20, 13, 18, 35, 43, 88, 25, 95, 68, 81, 29, 41, 45, 87]) len_x = len(x) mean = np.mean(x) xup = np.zeros(shape=(1,120)) for i in range(len_x) : xup[i] = (x[i] - mean) ** 2 xup_sum = np.sum(xup) var = xup_sum / len_x std_dev = var ** 0.5 z = np.zeros(shape = (1,120)) for i in range(len_x) : z[i] = (x[i] - mean)/std_dev print("Mean :", mean) print("Standard_dev :",std_dev) print("Variance : ",var) 位于acc_id模型上,您正在创建的视图具有

res.company

您可以在<field name="model">account.config.settings</field>模型上创建该字段,也可以更改视图的模型