Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
5810 Переглядів

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.



Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
7
черв. 24
24706
0
вер. 20
2243
0
жовт. 18
3848
1
лют. 24
11989
2
лип. 23
3154