This question has been flagged

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)

Avatar
Discard
Best Answer

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.



Avatar
Discard