i'm using odoo 9 and i want to override the function that define the date due. My problem is that i have partial payment (for example for my payment condition i have 2 types either 30J,15J,.. or "50% advance+50% in the reception") and i want that date due of invoice change every time according to my last payment date.So i override this function to satisfy my needs but i got nothing in my date due field . Any idea for help please ??
@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