代码之家  ›  专栏  ›  技术社区  ›  Dhouha

如何更改到期日,使其取决于最后一个付款日期

  •  1
  • Dhouha  · 技术社区  · 6 年前

       @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
    
    0 回复  |  直到 6 年前