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

account_financial_risk: "Expected singleton: res.company(1, 2)" while evaluating 'model._autopost_draft_entries() #147

Closed
1 task done
jvbp opened this issue Sep 2, 2021 · 3 comments · Fixed by #148
Closed
1 task done
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.

Comments

@jvbp
Copy link

jvbp commented Sep 2, 2021

Odoo Version:

  • 13.0

I think it can be reproduced in 13.0 and above versions

Hi, the cron that calls the method _autopost_daft_entries() is raising an error due to account_financial_risk.

The error occurs when:

  • More than one company in odoo
  • More than one draft move in each company with auto_post = True.

The error is:

   File "/opt/odoo/auto/addons/account_financial_risk/models/account_invoice.py", **line 65, in post
     or self.company_id.allow_overrisk_invoice_validation**
   File "/opt/odoo/custom/src/odoo/odoo/fields.py", line 1021, in __get__
     record.ensure_one()
   File "/opt/odoo/custom/src/odoo/odoo/models.py", line 5104, in ensure_one
     raise ValueError("Expected singleton: %s" % self)
 ValueError: <class 'ValueError'>: "Expected singleton: res.company(1, 2)" while evaluating
 'model._autopost_draft_entries()'

We fixed the issue (was urgently in our instance ) with:

Original code:

    def action_post(self):
        if (
            self.env.context.get("bypass_risk", False)
            or self.company_id.allow_overrisk_invoice_validation
        )

Fixed code:

    def action_post(self):
        for sel in self:
            if (
                self.env.context.get("bypass_risk", False)
                or sel.company_id.allow_overrisk_invoice_validation
            ):
                return super().post()

Don't know if it's the best way to fix the issue.

@pedrobaeza
Copy link
Member

Please wait in English in this repository. Odoo version?

@jvbp
Copy link
Author

jvbp commented Sep 2, 2021

Please wait in English in this repository. Odoo version?

Done. Sorry for bad English.

carlosdauden added a commit to Tecnativa/credit-control that referenced this issue Sep 3, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
carlosdauden added a commit to Tecnativa/credit-control that referenced this issue Sep 3, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
carlosdauden added a commit to Tecnativa/credit-control that referenced this issue Sep 6, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
carlosdauden added a commit to Tecnativa/credit-control that referenced this issue Sep 6, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
carlosdauden added a commit to Tecnativa/credit-control that referenced this issue Sep 6, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
carlosdauden added a commit to Tecnativa/credit-control that referenced this issue Sep 6, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
AaronHForgeFlow pushed a commit to ForgeFlow/credit-control that referenced this issue Nov 26, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
MiquelRForgeFlow pushed a commit to ForgeFlow/credit-control that referenced this issue Nov 30, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
MiquelRForgeFlow pushed a commit to ForgeFlow/credit-control that referenced this issue Dec 1, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
MiquelRForgeFlow pushed a commit to ForgeFlow/credit-control that referenced this issue Dec 1, 2021
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
@github-actions
Copy link

github-actions bot commented Mar 6, 2022

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 Mar 6, 2022
BT-atornero pushed a commit to BT-atornero/credit-control that referenced this issue Jan 23, 2023
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
Vandan-OSI pushed a commit to ursais/credit-control that referenced this issue Mar 27, 2023
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
olveracuenca pushed a commit to Jarsa-dev/credit-control that referenced this issue Jun 5, 2023
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
ernesto-garcia-tecnativa pushed a commit to Tecnativa/credit-control that referenced this issue Jul 4, 2023
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
ernesto-garcia-tecnativa pushed a commit to Tecnativa/credit-control that referenced this issue Jul 4, 2023
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
Mat-moran pushed a commit to dm-integrations/credit-control that referenced this issue Dec 14, 2023
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
hea-bmya pushed a commit to bmya/credit-control that referenced this issue May 20, 2024
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
hea-bmya pushed a commit to bmya/credit-control that referenced this issue May 20, 2024
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
sbiosca-s73 pushed a commit to Studio73/credit-control that referenced this issue May 22, 2024
… invoices from wizard. Avoid singleton with multi-company _autopost_draft_entries.

 When we post from validate.account.move wizard, validate_move returns 'ir.actions.act_window_close'.
 Fixed issue OCA#147
 TT30969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
3 participants