Odoo Help


how to get value from another function?

on 4/18/15, 9:27 AM 893 views

def _get_commitment_date(self, cr, uid, ids, name, arg, context=None):

    """Compute the commitment date"""

    res = {}

    dates_list = []

    for order in self.browse(cr, uid, ids, context=context):

        dates_list = []

        order_datetime = datetime.strptime(order.date_order, DEFAULT_SERVER_DATETIME_FORMAT)

        for line in order.order_line:

            dt = order_datetime + timedelta(days=line.delay or 0.0)

            dt_s = dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)


        if dates_list:

            res[order.id] = min(dates_list)

    return res


def on_change_date_order(self, cr, uid, ids, order_date, arg,context=None):

    result = {}

    if order_date is not False:

        result['delivery_date'] =self._get_commitment_date(cr, uid, ids, field_name, arg, context=context)  **ERROR !!

    return {'value': result}


xml file :

<field name="date_order" on_change="on_change_date_order(order_date,context)"/>


Dhinesh - Technical Consultant, Sodexis Inc

--Dhinesh - Technical Consultant, Sodexis Inc--
| 5 4 9
Pondicherry, India
--Dhinesh - Technical Consultant, Sodexis Inc--

Passionate coder in Python/OpenERP. Knows Django/Flask MVC frameworks. Did code in Java, PHP.

Contact me at: dvdhinesh.mail@gmail.com

Dhinesh - Technical Consultant, Sodexis Inc
On 4/20/15, 3:33 AM

I hope your first method is a functional field method ("""Compute the commitment date""" ). You don't need to call the method directly. You can call the "commitment date" field. Obviously it will call the method and return the data you expected.

Because computed/functional fields require, some signature which is not provided correctly.

In order to get the field value you have to know the ids to browse. Since it is a onchange you won't get the ids. So you can't directly call the field itself. You need to do a work around in the onchange by rewriting all the computation you done in the functional field method also in onchange method.

Or define the real computation in separate method and use that method in both because the final result which going to save is the functional method result.

 def on_change_date_order(self, cr, uid, ids, order_date, arg,context=None): 
    result = {}
     if order_date is not False:
        result['delivery_date'] = commitment_field_name #will not work (so compute again)
return {'value': result}

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 4/18/15, 9:27 AM
Seen: 893 times
Last updated: 4/20/15, 3:57 AM