Odoo many2one, many2many, & one2many explained

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 16

  • @CrazySquareRoot
    @CrazySquareRoot 5 месяцев назад

    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 mode 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).

  • @HamzaAslam-f9o
    @HamzaAslam-f9o 4 месяца назад +1

    Finally I understood. Thanks Richard.

  • @pandarikkal
    @pandarikkal Месяц назад

    can you please create a demo how a master detail form is created using odoo studio and explain how one2many and many2on is applied in it ?

  • @hydrandt
    @hydrandt 4 года назад +5

    Maybe a better way to explain One2many would be that we have ONE quotation, to which MANY records in the sale.order.line table (model) correspond?

  • @mrsaafan1
    @mrsaafan1 2 года назад +1

    that's incredibly awesome

  • @zkhater63
    @zkhater63 3 месяца назад

    perfect

  • @carloseugnio
    @carloseugnio 4 года назад

    Great explanation!

  • @MuhammadUmarAkram4
    @MuhammadUmarAkram4 3 года назад

    Hi. My question is, if I put a compute in the main form view and having a many2many field of that form in another form, does the compute work there in 2nd form?

    • @richardshall9582
      @richardshall9582  3 года назад +1

      Hi Muammad, Sorry for not getting back to you more quickly. Yes the compute will work in the second form.

    • @MuhammadUmarAkram4
      @MuhammadUmarAkram4 3 года назад

      @@richardshall9582 thanks alot for your reply. Can you make a video on auto populating many2many field based on a condition. Like selecting a purchase order items in invoice will be in many2many of invoice item line. Will be grateful if you will do that.

  • @manhngo2724
    @manhngo2724 4 года назад

    Thanks for your explanation .

  • @ceeril
    @ceeril 3 года назад

    This video > Amy Caroline > all Odoo documents.

  • @satriolantip7668
    @satriolantip7668 5 лет назад

    how to display different many2one data while in the same relation comodel ? I've confuse about that...can you explain it on next video?

    • @richardshall9582
      @richardshall9582  5 лет назад

      Hey Satrio,
      Can you give me more information on what is the use case you are hoping to achieve? I'm not entirely sure what you mean exactly.

    • @maherkhalil007
      @maherkhalil007 4 года назад

      @@richardshall9582 if i have one field with multiple checkboxes. how to deal with them?

    • @Weblearns
      @Weblearns 4 года назад

      @@maherkhalil007 Use in this case many2many field