openerp - How do I access a model's attribute from inside of the model's function -


I want to use the attribute of a model from within a function. Take a look at line (Lennon (self.order_line)> 0):

How do I do this correctly? Because the above mentioned code does not work.

The purpose of this function field is to read and modify the other attributes of the same model which is order_line . Therefore, it acts as a bridge to simplify the UI, the user needs to specify a property unit to represent only order_line so that I get from the function order_line Requires reaching .

And I want to set the order_line value based on property_unit_rel sales.order before the value How can I do that _property_unit_inv function?

Total code:

  from osv import osv, field class custom_sale_order (osv.osv): _name = "sale.order" _inherit = 'sale.order' def _property_unit_read (Self, CR, UID, IID, Property_init_Rail, AGR, context): If (Lane (order orderline)> 0): Second pass: return any def_property_unit_inv (self, CR, UID, IID, property_ent_lil, ARG, context) ): Pass # this one sales_order_line__columns = {'property_unit_rel'}: fields.function (_property_unit_read, fnct_inv = _property_unit_inv, type =}} (), (), (), (), (), (), (), (), (),>  

operap Most of the callers in the DP have themselves, CR, UID, ID, .... parameters. is pool (see object pool pattern), cr is the database cursor, uid is the user id and the id id or the list of the id of the objects that you call to call. If you want to get the number of order lines you must first order the object Have to get. You can do this with a = self.browse (cr, uid, id, context = context) to get the object (or object) specified by id . If id is int or long you will get browse_record but if this is the list, you will get it again Browse_record_list (list of browse records). To get some order lines, you can call a.order_line (or a [0] .order_line if id was a list) You can.

So if you can get an attribute of the object that you want to call for browse_record.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -