我正在尝试计算更改发票日期的到期日但不起作用 def onchange_date_invoice(self,cr,uid,ids,type,partner_id,date_invoice = False,payment_term = False): partner_payment_term =错误
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
答案 0 :(得分: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}