Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
5804 Vistas

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
Descartar
Mejor respuesta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
7
jun 24
24700
0
sept 20
2240
0
oct 18
3839
1
feb 24
11983
2
jul 23
3148