Odoo Help

Welcome!

This community 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.

0

_get_commitment_date parameters

By
SEAN CALLAHAN
on 6/28/16, 6:04 AM 172 views

Hello,


How would I inherit the _get_commitment_date function? Do the parameters need to be the same or what? I've tried every variation, not sure what I am missing here. (odoo9e)


Original:

class sale_order_dates(osv.osv):
"""Add several date fields to Sale Orders, computed or user-entered"""
_inherit = 'sale.order'
 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:
if line.state == 'cancel':
continue
dt = order_datetime + timedelta(days=line.customer_lead or 0.0)
dt_s = dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
dates_list.append(dt_s)
if dates_list:
res[order.id] = min(dates_list)
return res

My test function (which does not do anything):

class test_sale_order(models.Model):    
_inherit = 'sale.order'
@api.model
def _get_commitment_date(self, cr, uid, ids, name, arg, context=None):



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 6/28/16, 6:04 AM
Seen: 172 times
Last updated: 6/28/16, 7:18 AM