gpt4 book ai didi

python - 在系统中找不到外部 ID - Odoo v9 社区

转载 作者:太空宇宙 更新时间:2023-11-04 02:55:25 25 4
gpt4 key购买 nike

这是一个非常奇怪的行为,它正在工作,现在我正要将我的模块安装到另一个数据库上,突然出现关于外部 ID 的错误。

这是我在模型中的代码:

def _static_location(self):
return self.env.ref('fleet_stock.location_stock')

然后我从字段中调用这个函数:

x_location_dest_id = fields.Many2one('stock.location', string=u'Ubicacion Destino de Productos', required=True,
readonly=False, default=_static_location,
help="Location where the system will look for components.")

location_stock 属性位于数据文件夹的 xml 文件中,声明如下:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="location_stock" model="stock.location">
<field name="name">ReparacionUnidades</field>
<field name="location_id" ref="stock.stock_location_locations_virtual"/>
<field name="usage">production</field>
<field name="company_id"></field>
</record>
</data>
</openerp>

__openerp__.py 文件上:

 "data": [
'data/location_data.xml',
'data/fleet_stock_data.xml',
'views/fleet_vehicle_log_services.xml',
],

当我尝试安装它时,会抛出这个:

Traceback (most recent call last):
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 648, in _handle_exception
return super(JsonRequest, self)._handle_exception(exception)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 685, in dispatch
result = self._call_function(**self.params)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 321, in _call_function
return checked_call(self.db, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/service/model.py", line 118, in wrapper
return f(dbname, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 314, in checked_call
result = self.endpoint(*a, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 964, in __call__
return self.method(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/http.py", line 514, in response_wrap
response = f(*args, **kw)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/web/controllers/main.py", line 892, in call_button
action = self._call_kw(model, method, args, {})
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/web/controllers/main.py", line 880, in _call_kw
return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/module/module.py", line 459, in button_immediate_install
return self._button_immediate_function(cr, uid, ids, self.button_install, context=context)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/module/module.py", line 534, in _button_immediate_function
registry = openerp.modules.registry.RegistryManager.new(cr.dbname, update_module=True)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/registry.py", line 386, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/loading.py", line 338, in load_modules
loaded_modules, update_module)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/loading.py", line 237, 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/odoov9/odoo-9.0c-20161106/openerp/modules/loading.py", line 137, in load_module_graph
init_module_models(cr, package.name, models)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/modules/module.py", line 300, in init_module_models
result = obj._auto_init(cr, {'module': module_name})
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/models.py", line 2643, in _auto_init
self._set_default_value_on_column(cr, k, context=context)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/models.py", line 2399, in _set_default_value_on_column
default = default(self, cr, SUPERUSER_ID, context)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 354, in old_api
result = method(recs, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/fields.py", line 82, in <lambda>
return api.model(lambda model: field.convert_to_write(value(model)))
File "/home/kristian/odoov9/danisan/fleet_stock/models/fleet_vehicle_services.py", line 122, in _static_location
return self.env.ref('fleet_stock.location_stock')
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 792, in ref
return self['ir.model.data'].xmlid_to_object(xml_id, raise_if_not_found=raise_if_not_found)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 248, in wrapper
return new_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 490, in new_api
result = method(self._model, cr, uid, *args, **old_kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/ir/ir_model.py", line 1019, in xmlid_to_object
t = self.xmlid_to_res_model_res_id(cr, uid, xmlid, raise_if_not_found)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/ir/ir_model.py", line 1005, in xmlid_to_res_model_res_id
return self.xmlid_lookup(cr, uid, xmlid)[1:3]
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "<string>", line 2, in xmlid_lookup
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/tools/cache.py", line 85, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0c-20161106/openerp/addons/base/ir/ir_model.py", line 995, in xmlid_lookup
raise ValueError('External ID not found in the system: %s' % (xmlid))
ValueError: External ID not found in the system: fleet_stock.location_stock

但这完全荒谬,这是有效的,它是我的模块,该模块称为 fleet_stock,它是什么?

__openerp__.py文件中data列的顺序吗?

有什么想法吗?

最佳答案

可能位置不是从您的 xml 文件创建的。

您可以尝试以下方法:

从您的 xml 文件中删除 noupdate="1" 属性并重新启动 Odoo 服务器并升级您的自定义模块。

然后转到“位置”菜单并检查是否创建了 ReparacionUnidades。如果它创建了,那么我们可以在 xml 文件中放回 noupdate="1" 属性。

现在,检查您的 x_location_dest_id 值。它应该会给你想要的输出。

关于python - 在系统中找不到外部 ID - Odoo v9 社区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42545268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com