我不明白为什么,但我有这个错误。 customers_group_id出现在我的表格中
我所有的关系。
你有什么想法吗?
谢谢。
IntegrityError: insert or update on table "products_group" violates foreign key constraint "products_group_customers_group_i_fkey"
DETAIL: Key (customers_group_id)=(25) is not present in table "customers_group".
我的代码
from openerp.osv import fields, osv
from openerp.tools.translate import _
class customers_group(osv.osv):
_name = 'customers.group'
_rec_name = 'customers_group_name'
_columns = {
'customers_group_id': fields.integer('Group Id', size=5, help="Id customer group"),
'customers_group_name': fields.char('Group Name', size=30, required=True),
.....
}
class res_partner(osv.osv):
_inherit = 'res.partner'
_columns = {
'partner_customer_group_id': fields.many2one('customers.group','Customers Group', help='Customers group.')
}
产品组
from openerp.osv import orm, fields
from openerp.tools.translate import _
class products_group(orm.Model):
_name = 'products.group'
_columns = {
'customers_group_id': fields.integer('Customer group Id', size=20, help='id of customers group'),
'products_id': fields.integer('Product Id', size=5, help="Id product must be unique"),
'products_model_group': fields.char('Product model group', size=30, help='Product model'),
.....
}
答案 0 :(得分:0)
我修复了类似的情况(根据您的代码进行调整):
var fullPath = Environment.ExpandEnvironmentVariables("$HOME/myfolder");
var exists = Directory.Exists("$HOME/myfolder");
我重新启动了服务,并删除了方法_set_null和compute属性,因为25的值已替换为Null,因此不再发生完整性错误。