Skip to Content
Menu
This question has been flagged
1337 Views

Could anyone check if that inheritance is correct? or should I remove 'res' variable and a return? Thank you


    @api.model

    def cron_recurring_create_invoice(self, date_ref=None):

        if self.type == 'invoice':    ################################ my extra line

            res = super(ContractContract, self).cron_recurring_create_invoice()

            return res


    ### original def ######### 

    @api.model

    def cron_recurring_create_invoice(self, date_ref=None):

        if not date_ref:

            date_ref = fields.Date.context_today(self)

        domain = self._get_contracts_to_invoice_domain(date_ref)

        invoices = self.env["account.invoice"]

        # Invoice by companies, so assignation emails get correct context

        companies_to_invoice = self.read_group(domain, ["company_id"], ["company_id"])

        for row in companies_to_invoice:

            contracts_to_invoice = self.search(row["__domain"]).with_context(

                allowed_company_ids=[row["company_id"][0]]

            )

            invoices |= contracts_to_invoice._recurring_create_invoice(date_ref)

        return invoices



Avatar
Discard
Related Posts Replies Views Activity
7
Jun 24
21697
1
Jun 20
8968
1
Aug 19
5570
1
Aug 24
425
2
Nov 24
762