This question has been flagged
2360 Views

i'm using odoo 9 and i want to override the function which calculate the due date . i want to modify the calcul in case i have a partial payment . I just found this function in account_invoice.py which calculate due date but when i override it it always the same result i don't want that odoo calculate automatically date due . Is there another function to use ? Any idea for help please, i'm blocked with this problem ?

@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.date_due or self.date_invoice
    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 = max(line[0] for line in pterm_list) 
Avatar
Discard