Odoo api.depends and non stored field - odoo

Lets say I have a One2Many field which is computed and not stored. Now I have a Boolean field which is computed and stored. The compute method of the Boolean field has the decorator api.depends('non_stored_field'). The non stored field would be the One2Many field in my case. Does the function still trigger when the One2Many field changes?

Related

How to copy a one2many field in odoo

I would like to know how to copy a one2many field in odoo 14 .
Suppose i have a Model called "ModelA" with a one2many field ,which is related to a field stored in another model called "ModelB".
When i change a value of this one2many field in "ModelA", this change is passed on the "ModelB" field .
So i just want to copy the values of the one2many field in the "ModelA", so that changes will affect only the "modelA".
If possible i would like to keep the "one2many" type in the "modelA".
Thanks

Filter one2many Field In many2one Field

I have a one2many tree field which contains many columns, every column uses a many2one field, the picture below shows two columns:
Is there a way to use a many2one field to get the values, let us say for the first column (prod1, prod2).
I am a beginner and do not know where to start from, any suggestions will be much appreciated!
P.S.: I am working with odoo v9
you can use this documentation form odoo:Odoo documentation
One2many field; the value of such a field is the recordset of all the records in comodel_name such that the field inverse_name is equal to the current record.
you can use these Parameters:
comodel_name -- name of the target model (string)
inverse_name -- name of the inverse Many2one field in comodel_name (string)
domain -- an optional domain to set on candidate values on the client side (domain or string)
context -- an optional context to use on the client side when handling that field (dictionary)
auto_join -- whether JOINs are generated upon search through that field (boolean, by default False)
limit -- optional limit to use upon read (integer)
if you need toĆ  use domain like this:
field.One2many(comodel_name="model_name", inverse_name="inverse_field_name", string=None, domain=[('filed_name_in_comodel', 'operators', 'Value')])

How to pass value of a field from one model to another model in Odoo, when they are present in same view?

I have view for A model which contain following fields
Student_name field many2one
x_course_id field many2one
one2many field named 'b_ids' which refer B model.
b_ids is made as a tree in same view which contains following fields
some_field_name many2one
x_course_id field many2one
a_id field many2one which refer A model
Now, the problem is that the field some_field_name must be listed according to the value of course_id field which should be same as course_id field inAmodel.
I related field for course_id as
It is fetching value after saving that record, because of which my domain for some_field_name doesn't works
domain for some_field_name is written as [('x_course_id','=' x_course_id)]
But since this x_course_id on right hand side doesn't exist before saving the form, this domain doesn't works.
So, i wanted to know, is there a way by which i can get value of x_course_id in tree before saving the form.
Can any of the following fields be helpful in these case?? If yes, how?

search in One2many custom field odoo

I install the model product_custom_info who add specified field to product (Custom Properties)
And Now I would create a filter by this field ( It's one2many field)
i would recommend you to use many2many field instead and you can make it searchable like the way you do to other fields (char, many2one etc.)
hope it helps

What is Main difference between #api.onchange and #api.depends in Odoo(openerp)?

In Odoo v8 there are many API decorators used. But I don't understand the main difference between #api.depends and #api.onchange.
Can anyone help me out from this one?
Thank You.
#api.depends
This decorator is specifically used for "fields.function" in odoo. For a "field.function", you can calculate the value and store it in a field, where it may possible that the calculation depends on some other field(s) of same table or some other table, in that case you can use '#api.depends' to keep a 'watch' on a field of some table.
So, this will trigger the call to the decorated function if any of the fields in the decorator is 'altered by ORM or changed in the form'.
Let's say there is a table 'A' with fields "x,y & z" and table 'B' with fields "p", where 'p' is a field.function depending upon the field 'x' from table 'A', so if any of the change is made in the field 'x', it will trigger the decorated function for calculating the field 'p' in table 'B'.
Make sure table "A" and "B" are related in some way.
#api.onchange
This decorator will trigger the call to the decorated function if any of the fields specified in the decorator is changed in the form. Here scope is limited to the same screen / model.
Let's say on form we have fields "DOB" and "Age", so we can have #api.onchange decorator for "DOB", where as soon as you change the value of "DOB", you can calculate the "age" field.
You may field similarities in #api.depends and #api.onchange, but the some differences are that scope of onchange is limited to the same screen / model while #api.depends works other related screen / model also.
For more info, Here is the link that describe all API of Odoo v8.
#api.onchange works in virtual records assignment on these records is not written to the database, just used to know which value to send back to the client.
Fields can be computed (instead of read from the database) using the compute parameter, it must assign the computed value to the field, it uses the values of other fields from the same model or others model (unlike #api.onchange which work only with the fields in the same view), it should specify fields using api.depends().
For more information. Please check out our blog :
https://odooforbeginnersblog.wordpress.com/2017/03/01/how-to-override-an-api-depends-decorated-method/
#api.depends
The function defined with this decorator will be called if any change happens in the fields specified. Moreover, the change to the field can be from ORM or changes in the form. Furthermore, if a compute function value depends on another field, then it must be specified using depends.
#api.onchange
The function of this decorator will be called when the field value changes. Moreover, it supports only single field names; on the contrary, dotted names such as parent_id.field_name will not be considered. Furthermore, onchange methods are invoked on pseudo-records that contain values of the form. The following is an example of the same:
Reference for better understanding with example : https://www.cybrosys.com/blog/method-decorators-odoo-13