Skip to Content
Menú
This question has been flagged
1 Respondre
317 Vistes

Hi


I am planning to replace the field upon the creation of invoice. Currently the Invoice Date is already avaiable but, the user must manually fill in the date. But, I want to automate to when the Order Date is confirmed. Is there a way for this to be performed?


Sales Quotation

Invoice

Avatar
Descartar
Best Answer

Hi,

Please refer to the code:


class SaleOrder(models.Model):

    _inherit = 'sale.order'

   

def _prepare_invoice(self):

    """Function that update the date in invoice"""

    res = super(SaleOrder, self)._prepare_invoice()

    res.update({

        'invoice_date': self.date_order,

    })

    return res


Hope it helps.

Avatar
Descartar