This question has been flagged
3 Replies
2607 Views

how can i override create_invoice funtion in sale.advance.payment.inv transient model

Avatar
Discard
Best Answer

Hello Shibin,

Please update following code:

class CustomSaleAdvancePaymentInv(models.TransientModel):

    _inherit = "sale.advance.payment.inv"

    _description = "Custom Sales Advance Payment Invoice"


    @api.multi

    def _create_invoice(self, order, so_line, amount):

        val = super(CustomSaleAdvancePaymentInv, self)._create_invoice(order, so_line, amount)

# Add Your operation here

        return val

Avatar
Discard
Best Answer

Hi,

Try like this,


class SaleAdvancePaymentInv(models.TransientModel):
_inherit = "sale.advance.payment.inv"

@api.multi
def _create_invoice(self, order, so_line, amount):
res = super(SaleAdvancePaymentInv, self)._create_invoice(order, so_line, amount)
print("Test")
        # Do necessary operations here
return res


Thanks

Avatar
Discard
Best Answer

class SaleAdvancePaymentInv(models.TransientModel):

    _inherit = "sale.advance.payment.inv"

    @api.multi

    def _create_invoice(self, order, so_line, amount)

        ## update whatever you want here if any changes in order,line,amount

        invoice = super(SaleAdvancePaymentInv, self)._create_invoice(order, so_line, amount)

        ## update whatever you want here

        return invoice

Avatar
Discard