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

[8.0]Error Expected singleton: account.account.type(25, 37) creating "Accounting Set-Up" #20

Open
Nick-OpusVL opened this issue Jul 19, 2019 · 2 comments

Comments

@Nick-OpusVL
Copy link
Contributor

Nick-OpusVL commented Jul 19, 2019

How to reproduce

  • Restore a copy of the database where this singleton error would occur
    • We don't know cause yet so can't prescribe how to set this up, but we do have a database that has this issue, but don't want to identify it in a public place such as this.
    • Internally, see T15292 for more context info on which database this refers to.
  • Install account_mtd_vat
  • Add group MTD/Administrator and MTD/User to admin account
  • Refresh browser window
  • Click Accounting -> Making Tax Digital -> MTD Set-up -> Accounting Set-up -> Create

What should happen

Should not have an error, so we can fill in fields.

What happens

In the GUI we see Odoo Warning dialogue with body Expected singleton: account.account.type(25, 37)

In the logs, we see this:

openerp.http: Exception during JSON request handling.
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 546, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 583, in dispatch
    result = self._call_function(**self.params)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 319, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 118, in wrapper
    return f(dbname, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 316, in checked_call
    return self.endpoint(*a, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 812, in __call__
    return self.method(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 412, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 944, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/addons/web/controllers/main.py", line 936, in _call_kw
    return getattr(request.registry.get(model), method)(request.cr, request.uid, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 268, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 399, in old_api
    result = method(recs, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5998, in onchange
    newval = record[name]
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5654, in __getitem__
    return self._fields[key].__get__(self, type(self))
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 838, in __get__
    self.determine_draft_value(record)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 946, in determine_draft_value
    self._compute_value(record)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 885, in _compute_value
    self.compute(records)
  File "/mnt/extra-addons-bundles/OpusVL_mtd/account_mtd_vat/models/hmrc_posting_configuration.py", line 39, in _compute_company_id
    ('name', '=', 'Output Tax')])
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 851, in __set__
    value = self.convert_to_cache(value, record)
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 1051, in convert_to_cache
    return int(value or 0)
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5624, in __int__
    return self.id
  File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 1909, in __get__
    return record.ensure_one()._ids[0]
  File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5320, in ensure_one
    raise except_orm("ValueError", "Expected singleton: %s" % self)
except_orm: ('ValueError', 'Expected singleton: account.account.type(25, 37)')
@Nick-OpusVL
Copy link
Contributor Author

Nick-OpusVL commented Jul 19, 2019

Consider whether this is likely to be an issue in:

  • 8.0
  • 10.0
  • 11.0
  • 12.0

Fix the issue in:

  • 8.0

@Nick-OpusVL
Copy link
Contributor Author

Nick-OpusVL commented Jul 19, 2019

Effectively, there are at least two taxes that satisfy the following condition in the database in question:

        self.output_account_type = self.env['account.account.type'].search([
            ('code', '=', 'Output Tax'),
            ('name', '=', 'Output Tax')])

but when assigning to a many2one there can only be zero or one records (this makes sense if you think about it).

There's a possibility the line below it might also suffer the same fate, which does similar in the same way but looks for Input Tax.

We need to decide if it's a data bug or it's reasonable to have this situation and therefore should handle it in the code. If it's a data bug, we could at least trap the >2 matches case and throw a more user-friendly error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant