Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
5809 Näkymät

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
Hylkää
Paras vastaus

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
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
7
kesäk. 24
24701
0
syysk. 20
2242
0
lokak. 18
3840
1
helmik. 24
11984
2
heinäk. 23
3151