This question has been flagged
6 Replies
3003 Views

In Odoo 9 Community version:

One2Many record gets created only when a value to any of M2O field is set. Until unless it is not set then odoo doesn't allow you to create that record.


For Instance: Consider the below example:

Line Object has only 3 fields (plus link to its parent object)

1. name (text - non mandatory)

2. qty (float - non mandatory)

3. comment (text - non mandatory)


Odoo did not allow me create this record.

Hence, now I brought another field to this view,


4. uom_id (M2O - non mandatory)


Now after I brought this new field into the view, the minute I supplied a value to this uom_id which happened to a M2O, a record got created.


So by looking at these scenarios,  unless until you set any value to  any M2O field present in the O2M, odoo does not create that record.

So what if my lines doesn't have any M2O type field? then I can never create a record, which is utterly nuisance.

I don't understand why this kind of behaviour is implied, Anybody faced same kind of situation, How do we handle this.


Avatar
Discard

No. There is no any condition like first fill 1st field, probably its due to your code. You can check the Customer invoices in which product_id is the first field and its not required you can add new one2many record without adding product.

Author

@pinakin, Yes even I agree with you, initially I too wondered how could tat be, But later on I realized, some validation is added to check whether any value present in any of M2O field.

Author

Further, in Invoice Line, account_id is mandatory, hence record gets created, I suggest you to check, by adding non mandatory fields, and try creating a record, without filling data to any of M2O field present in it.

Author

I guess my question is misleading, will edit it in a better manner.

yes, its little confusing, I think you have to add details about parent object too and brief explanation about the scenario about object will be helpful. [And please include the code too]. Hope this helps

Author Best Answer

Problem resolved:

https://github.com/odoo/odoo/issues/12461

Avatar
Discard