Monday, April 29, 2024
1 change · saas-17.2
Resolved issues and error corrections
Users can now duplicate several customer invoices at once even when they belong to different journals. This prevents an error screen and keeps bulk invoice workflows running smoothly.
Original PR description
When the user tries to duplicate multiple invoices of different journals, a traceback will appear. Steps to reproduce the error: - Go to Accounting > Configuration > Journals > Create new journal…
When the user tries to duplicate multiple invoices of different journals,
a traceback will appear.
Steps to reproduce the error:
- Go to Accounting > Configuration > Journals > Create new journal (Type: Sales)
- Go to Customers > Invoices > Create new invoice with newly created journal
- Create another invoice with a different journal
- Select both invoices > Duplicate
Traceback:
```
ValueError: too many values to unpack (expected 1)
File "odoo/models.py", line 5848, in ensure_one
_id, = self._ids
ValueError: Expected singleton: account.journal(17, 11)
File "odoo/http.py", line 2251, in __call__
response = request._serve_db()
File "odoo/http.py", line 1827, in _serve_db
return self._transactioning(_serve_ir_http, readonly=ro)
File "odoo/http.py", line 1847, in _transactioning
return service_model.retrying(func, env=self.env)
File "odoo/service/model.py", line 134, in retrying
result = func()
File "odoo/http.py", line 1825, in _serve_ir_http
return self._serve_ir_http(rule, args)
File "odoo/http.py", line 1832, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "odoo/http.py", line 2057, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "odoo/addons/base/models/ir_http.py", line 220, in _dispatch
result = endpoint(**request.params)
File "odoo/http.py", line 739, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "addons/web/controllers/dataset.py", line 38, in call_kw
return self._call_kw(model, method, args, kwargs)
File "addons/web/controllers/dataset.py", line 34, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "odoo/api.py", line 458, in call_kw
result = getattr(recs, name)(*args, **kwargs)
File "addons/account/models/account_move.py", line 2652, in copy
new_moves = super().copy(default)
File "odoo/models.py", line 5563, in copy
vals_list = self.with_context(active_test=False).copy_data(default)
File "addons/stock_account/models/account_move.py", line 29, in copy_data
vals_list = super().copy_data(default=default)
File "addons/account/models/account_move.py", line 2646, in copy_data
if not self.journal_id.active and 'journal_id' in vals_list:
File "odoo/fields.py", line 1202, in __get__
record.ensure_one()
File "odoo/models.py", line 5851, in ensure_one
raise ValueError("Expected singleton: %s" % self)
```
https://github.com/odoo/odoo/blob/6c621e62d4b501bb0626276df798b3f8f585fa75/addons/account/models/account_move.py#L2657
Here, self has multiple records when the user duplicates multiple invoices,
So, it will lead to the above traceback.
sentry-5231989306
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr