python-2.7 - 如何更改到期日,使其取决于最后付款日期
问题描述
我正在使用 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
解决方案
推荐阅读
- apache-poi - 图表未显示在 Google 表格中
- php - 所有 TextTypes 都是 NULL Symfony 3
- c++ - 对象指针的联合(对不同的实例仅使用一种类型)
- date - 应用脚本编辑器 - “找不到方法 formatDate(object,string,string)”
- go - 如何解释 os.FileMode 的显示值?
- charts - Google 图表 vAxis 格式未正确显示 %
- data-science-experience - Watson Studio 在 Rstudio 中使用 ibmdbr 连接到 DB2 Z/OS
- typescript - 从 Vue 组件中的 index.html 访问全局窗口变量
- python - 2D滚动窗口分位数的最快方法?
- reactjs - 根据 id 更改 url 并从本地存储中获取值。反应JS