Foregin密钥约束无法实现--Odoo v9社区

时间:2016-10-18 14:21:08

标签: python openerp

我在Odoo v9社区中将product.product中的相关字段添加到stock.picking模型中。

像这样:

class StockPicking(models.Model):
    _inherit = 'stock.picking'

    price_unity = fields.Float(string="Precio", store=True, readonly=True, related="product_id.price")

但似乎无法将这些字段联系起来,至少为了显示它们,那里存在一些不兼容性,

它引发了我的错误:

2016-10-18 14:14:34,202 24998 ERROR argentina openerp.modules.registry: Failed to load registry
Traceback (most recent call last):
File "/home/kristian/odoov9/odoo-9.0/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.0/openerp/modules/loading.py", line 334, in load_modules
force, status, report, loaded_modules, update_module)
File "/home/kristian/odoov9/odoo-9.0/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.0/openerp/modules/loading.py", line 137, in load_module_graph
init_module_models(cr, package.name, models)
File "/home/kristian/odoov9/odoo-9.0/openerp/modules/module.py", line 300, in init_module_models
result = obj._auto_init(cr, {'module': module_name})
File "/home/kristian/odoov9/odoo-9.0/openerp/api.py", line 250, in wrapper
return old_api(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0/openerp/models.py", line 2548, in _auto_init
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" TYPE %s' % (self._table, k, c[2]), log_exceptions=False)
File "/home/kristian/odoov9/odoo-9.0/openerp/sql_db.py", line 141, in wrapper
return f(self, *args, **kwargs)
File "/home/kristian/odoov9/odoo-9.0/openerp/sql_db.py", line 220, in execute
res = self._obj.execute(query, params)
ProgrammingError: foreign key constraint "stock_picking_price_unit_fkey" cannot be implemented
DETAIL:  Key columns "price_unit" and "id" are of incompatible types: numeric and integer.

有关如何将该产品price字段与stock.picking相关联的任何想法?

stock.move它可行,但这里有一些我看不到的东西。

提前致谢!

0 个答案:

没有答案