0

我正在尝试计算更改发票日期的到期日期,但它不起作用 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] for 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
4

1 回答 1

0

您的代码应如下所示:

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}
于 2013-07-20T18:35:56.593 回答