Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[15.0] account_financial_risk - Error in auto_post scheduled action: Expected singleton: res.company(1,2,3,4) #252

Closed
jvbp opened this issue Feb 8, 2023 · 3 comments
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@jvbp
Copy link

jvbp commented Feb 8, 2023

Odoo version

15.0

Module

account_financial_risk

Describe the bug

Scheduled Actions: Account; Post draft entries with auto_post set to True up to today fails with the following mensage:

ValueError: <class 'ValueError'>: "Expected singleton: res.company(1, 7, 6, 2, 3)" while evaluating
'model._autopost_draft_entries()'

To Reproduce

Affected versions:

Steps to reproduce the behavior:

  1. Create auto_post entries in more than one company
  2. Run the schedule action

Expected behavior
The scheduled action to run fine.

Additional context
In our instance we did the following fix in method _first_invoice_exception_msg:

Original code

    def _first_invoice_exception_msg(self):
        """
        Method used to return the first invoice with exception message.
        """
        ret = False, False
        if (
            self.env.context.get("bypass_risk", False)
            or self.company_id.allow_overrisk_invoice_validation
        ):
            return ret
        for invoice in self.filtered(lambda x: x.move_type == "out_invoice"):
            exception_msg = invoice.risk_exception_msg()
            if exception_msg:
                ret = invoice, exception_msg
                break
        return 

New code

    def _first_invoice_exception_msg(self):
        """
        Method used to return the first invoice with exception message.
        """
        ret = False, False
        if (
            self.env.context.get("bypass_risk", False)
        ):
            return ret
        for invoice in self.filtered(
            lambda x: x.move_type == "out_invoice" 
            and not x.company_id.allow_overrisk_invoice_validation
        ):
            exception_msg = invoice.risk_exception_msg()
            if exception_msg:
                ret = invoice, exception_msg
                break
        return 
@jvbp jvbp added the bug label Feb 8, 2023
@jvbp jvbp changed the title [15.0] account_financial_risk - Error un auto_post scheduled action: Expected singleton: res.company(1,2,3,4) [15.0] account_financial_risk - Error in auto_post scheduled action: Expected singleton: res.company(1,2,3,4) Feb 8, 2023
@carlosdauden
Copy link
Contributor

Waiting fw-port:
#243

@github-actions
Copy link

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Aug 13, 2023
@pedrobaeza
Copy link
Member

Forward-ported on #303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

No branches or pull requests

3 participants