openerp - How to Create a function in python to calculate the Supplier Invoice due date on change of Invoice date in Accounting in Open ERP -


i trying calculate due date on changing invoice date not working def onchange_date_invoice(self,cr,uid,ids,type,partner_id,date_invoice=false,payment_term=false): partner_payment_term = false

    raise osv.except_osv(_('onchangedateinvoice'), _('start'))      if date_invoice != time.strftime('%y-%m-%d'):         if not payment_term_id:             return {'value':{'date_due': date_invoice}}         pterm_list = self.pool.get('account.payment.term').compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)          if payment_term != partner_payment_term:            if partner_payment_term:                to_update = self.onchange_payment_term_date_invoice(                   cr, uid, ids, partner_payment_term, date_invoice)                result['value'].update(to_update['value'])                 if pterm_list:                    pterm_list = [line[0] line in pterm_list]                    pterm_list.sort()                    result = {'value':{'date_due': pterm_list[-1]}}         else:                result['value']['date_due'] = false      raise osv.except_osv(_('onchangedateinvoice'), _('end'))     return result 

you'r code should look's like:

def onchange_invoice_date(self, cr, uid, ids, payment_term_id, date_invoice):     res = {}     import time     if date_invoice != time.strftime('%y-%m-%d'):         due_date = # calculate you'r date here         res['due_date'] = due_date     return {'value': res} 

Comments

Popular posts from this blog

javascript - JS causing window size to be bigger than necessary - Dropdown bug -

php - Calling a template part from a post -

How to mention the localhost in android -