首页 > 解决方案 > 如何更改到期日,使其取决于最后付款日期

问题描述

我正在使用 odoo 9,我想覆盖定义到期日期的函数。我的问题是我有部分付款(例如,对于我的付款条件,我有 2 种类型,30J、15J、.. 或“50% 预付款+50% 在接待处”)并且我希望每次发票更改的日期到期根据我最后的付款日期。所以我重写了这个函数来满足我的需要,但是我的到期日期字段中什么也没有。请问有什么好办法吗??

   @api.onchange('payment_term_id', 'date_invoice')
   def _onchange_payment_term_date_invoice(self):
date_invoice = self.date_invoice
if not date_invoice:
    date_invoice = fields.Date.context_today(self)
if not self.payment_term_id:
    # When no payment term defined
    self.date_due = self.payment_date
else:
    pterm = self.payment_term_id
    pterm_list = \
    pterm.with_context(currency_id=self.company_id.currency_id.id).compute(value=1, date_ref=date_invoice)[0]
    self.date_due = self.payment_date

标签: python-2.7odoo-9

解决方案


推荐阅读