Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
2753 Vizualizări

in my case I have an object relay.point and i used inherits to stock.warehouse 

the objectif i want when i create my relay.point automatically create to me stock.warehouse instance 


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

type = fields.Selection([('value1', 'Value 1'), ('Value2', 'Value 2')], string='Type')
warehouse_id = fields.Many2one('stock.warehouse', string='Related Warehouse',
ondelete='restrict', required=False,
auto_join=True, help='Warehouse-related data of the Relay point')
i have also :

class StockWarehouse(models.Model):
_inherit = 'stock.warehouse'

relay_point_ids = fields.One2many(
'relay.point', 'warehouse_id',
string='Relay Point',
auto_join=True)
when i want to create my relay.point instance i get msg that the stock.warehouse have a required code 
so i want to passe in my create the code and the name of warehouse 
any ideas please ?
Imagine profil
Abandonează
Cel mai bun răspuns

Hi,

In this first case when you use inherits, definitely when you create a record in the new model it will also create record in the model you have specified in inherits , this is delegation inheritance. 

In the second case when you inherit , you are adding new field to an existing model, so on creating new record, you have to provide value for all the required fields. If you check below image, you will get idea about the inheritance mechanism.


Thanks 

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
2
dec. 22
24010
1
dec. 20
18747
1
oct. 19
5691
1
aug. 19
3744
1
dec. 22
5576