تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
1 الرد
5807 أدوات العرض

i have a object called relay.point that inherit from logistic.entity and also inherits from stock.warehouse, about what i understood from delegation inheritance when i create my relay.point object must create a stock.warehouse also but i have error said :

ERROR: null value in column "warehouse_id" violates not-null constraint

my code :


class RelayPoint(models.Model):
_name = 'relay.point'
_inherit = ['logistic.entity', 'mail.thread', 'mail.activity.mixin']
_inherits = {'stock.warehouse': 'warehouse_id'}
_description = 'Relay Point'

warehouse_id = fields.Many2one('stock.warehouse', string='Related Warehouse',
ondelete='restrict', required=True, auto_join=True,
help='Warehouse-related data of the Relay point')

class LogisticEntity(models.Model):
_name = 'logistic.entity'
_description = 'Logistic Entity'

name = fields.Char(string='Name', required=True)
code_le = fields.Char(string='Code', required=False)
  warehouse_id = fields.Many2one('stock.warehouse', string='Warehouse', required=False)
  partner_id = fields.Many2one('res.partner', string='Partner', required=True)

الصورة الرمزية
إهمال
أفضل إجابة

The relaypoint inherit ​LogisticEntity and the warehouse_id already exists in ​LogisticEntity so you just override it in  relaypoint so you are getting the error.

Try to remove warehouse_id  from LogisticEntity.



الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
7
يونيو 24
24700
0
سبتمبر 20
2240
0
أكتوبر 18
3839
1
فبراير 24
11983
2
يوليو 23
3150