Ir al contenido
Menú
Se marcó esta pregunta
4 Respuestas
14831 Vistas


HI, I'm a beginner in odoo. Please I went to no the difference bettwen fields
Avatar
Descartar
Mejor respuesta

Hi,

Refer this,

https://www.odoo.com/forum/help-1/question/can-anybody-tell-difference-between-many2one-and-one2many-with-example-144734

Thanks !!!  

Aswini @ iWesabe


Avatar
Descartar
Mejor respuesta

x2y - x refers to the source model (the model having the field) y refers to the target model


1. One2One 

Not explicitly used by Odoo. 

Meaning: that every source model is related by the field to at most one target model. And vice versa. 

Logical meaning: From the source model we can uniquely determine the target model and vice versa.

Abstract Example: The social security number of a person is unique. Given the person (source model), we can uniquely determine his/her social security number (target model), and given the social security number, we can uniquely determine the person.

Usual database representation: two columns (fields) in a single table. Meaning that we don't usually use separate models. E.g.: There is no separate 'social security number' model. The 'person' model has a 'social security number' field on itself.

Odoo field type: not distinguished (keeps such data in a single table)


2. Many2One 

Meaning: source model can point to at most one target model, but many different source models can point to the same target model 

Logical meaning: From the source model field we can uniquely determine the target model. But from the target model, we can't uniquely determine the source model (there are potentially many source models pointing to it). 

Abstract Example: A customer (source model) can have just one surname (target model). However, any particular surname can be shared by different customers. Given the specific customer, we can uniquely determine his/her surname, but given the specific surname, we can't uniquely determine the customer. 

Usual database representation: column on source model pointing to target model id

Odoo field type: usually an integer type pointing to target model id (target models have array type fields pointing to sources)


3. One2Many

Meaning: the reverse of point 2 from a different perspective.

Logical meaning: From the source model field we can't uniquely determine the target model (we are potentially pointing to many target models). But from the target model, we can uniquely determine the source model. 

Abstract Example: A surname (source model) can point to many different customers. But a particular customer has just one surname.

Usual database representation: column on target model pointing to source model id

Odoo field type: usually an array of target model ids (target models have integer type field pointing to source).


4. Many2Many

Meaning: every source/target model can point to many different target/source models 

Logical meaning: we can't - as a rule - uniquely determine the target model from the source model and the source model from the target model.

Abstract Example: A person can have many nicknames and a particular nickname can potentially be shared by different people. A  person (source model) can point to many different nicknames (target models), and any nickname can point to many different persons.

Usual database representation: separate table with columns relating source model with target model. A row in such table looks like this: row_id, source_id, target_id. 

Odoo field type: usually an array pointing to the target model ids (target models have analogous fields pointing to source models).

Avatar
Descartar
Mejor respuesta

Hello,

Check this: https://www.odoo.com/documentation/10.0/reference/orm.html#relational-fields

Thanks & Regards

Avinash N K


Avatar
Descartar
Mejor respuesta

Odoo is one of the best option for the ERP.
#odoo #openerp #ERP #customization
#tips #training #development #guide #python
These tips help you to get the basic idea about customization in odoo
Odoo Tips

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
3
sept 24
4530
1
mar 23
2220
0
dic 22
2864
0
jun 21
2871
0
jun 20
5339