Sunday, June 25, 2023
1 change · master
Miscellaneous changes
When ```_seek_for_lines``` returns multiple ```suspense_line``` for ```transaction_amount``` calculation, then the user will face this issue 'Expected singleton: account.move.line(516, 517)'. Steps to reproduce: - Create a new transaction in Journal (Bank) by Accounting Journal > Bank Reconcilation > Add a Transaction. - While creating a transaction add a partner, amount (amount > 0), Foreign Currency, Amount in currency and then save it. - Go to Journal Entries by Accounting > Journ
Original PR description
When ```_seek_for_lines``` returns multiple ```suspense_line``` for ```transaction_amount``` calculation, then the user will face this issue 'Expected singleton: account.move.line(516, 517)'. Steps…
When ```_seek_for_lines``` returns multiple ```suspense_line``` for
```transaction_amount``` calculation, then the user will face this
issue 'Expected singleton: account.move.line(516, 517)'.
Steps to reproduce:
- Create a new transaction in Journal (Bank) by
Accounting Journal > Bank Reconcilation > Add a Transaction.
- While creating a transaction add a partner, amount (amount > 0),
Foreign Currency, Amount in currency and then save it.
- Go to Journal Entries by Accounting > Journal Entries
and then open your recently created journal entry.
- Click on reset to draft and then in 'Journal Items'
add a line with some credit amount such that total credit and debit should be
equal. (Under Account it should be Bank Suspense Account).
- Now click on 'Bank Transaction' button in the form view.
By following above steps you will be able to reproduce the error.
```
ValueError: too many values to unpack (expected 1)
File "odoo/models.py", line 5199, in ensure_one
_id, = self._ids
ValueError: Expected singleton: account.move.line(516, 517)
File "odoo/http.py", line 2116, in __call__
response = request._serve_db()
File "odoo/http.py", line 1698, in _serve_db
return service_model.retrying(self._serve_ir_http, self.env)
File "odoo/service/model.py", line 134, in retrying
result = func()
File "odoo/http.py", line 1725, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
File "odoo/http.py", line 1923, in dispatch
result = self.request.registry['ir.http']._dispatch(endpoint)
File "odoo/addons/base/models/ir_http.py", line 154, in _dispatch
result = endpoint(**request.params)
File "odoo/http.py", line 715, in route_wrapper
result = endpoint(self, *args, **params_ok)
File "addons/web/controllers/dataset.py", line 28, in call_kw
return self._call_kw(model, method, args, kwargs)
File "addons/web/controllers/dataset.py", line 24, in _call_kw
return call_kw(request.env[model], method, args, kwargs)
File "odoo/api.py", line 461, in call_kw
result = _call_kw_multi(method, model, args, kwargs)
File "odoo/api.py", line 448, in _call_kw_multi
result = method(recs, *args, **kwargs)
File "home/odoo/src/enterprise/saas-16.2/account_accountant/models/bank_rec_widget.py", line 923, in onchange
return super(BankRecWidget, self.with_context(recursive_onchanges=False)).onchange(values, field_name, field_onchange)
File "odoo/models.py", line 6529, in onchange
record._onchange_eval(name, field_onchange[name], result)
File "odoo/models.py", line 6240, in _onchange_eval
method_res = method(self)
File "home/odoo/src/enterprise/saas-16.2/account_accountant/models/bank_rec_widget.py", line 659, in _onchange_todo_command
self._ensure_loaded_lines()
File "home/odoo/src/enterprise/saas-16.2/account_accountant/models/bank_rec_widget.py", line 1481, in _ensure_loaded_lines
self.line_ids
File "odoo/fields.py", line 4287, in __get__
return super().__get__(records, owner)
File "odoo/fields.py", line 2793, in __get__
return super().__get__(records, owner)
File "odoo/fields.py", line 1155, in __get__
self.recompute(record)
File "odoo/fields.py", line 1365, in recompute
apply_except_missing(self.compute_value, recs)
File "odoo/fields.py", line 1338, in apply_except_missing
func(records)
File "odoo/fields.py", line 1387, in compute_value
records._compute_field_value(self)
File "odoo/models.py", line 4312, in _compute_field_value
fields.determine(field.compute, self)
File "odoo/fields.py", line 99, in determine
return needle(*args)
File "home/odoo/src/enterprise/saas-16.2/account_accountant/models/bank_rec_widget.py", line 231, in _compute_line_ids
wizard._lines_widget_add_auto_balance_line()
File "home/odoo/src/enterprise/saas-16.2/account_accountant/models/bank_rec_widget.py", line 1021, in _lines_widget_add_auto_balance_line
auto_balance_line_vals = self._lines_widget_prepare_auto_balance_line()
File "home/odoo/src/enterprise/saas-16.2/account_accountant/models/bank_rec_widget.py", line 972, in _lines_widget_prepare_auto_balance_line
= self.st_line_id._get_accounting_amounts_and_currencies()
File "addons/account/models/account_bank_statement_line.py", line 492, in _get_accounting_amounts_and_currencies
transaction_amount = -suspense_line.amount_currency
File "odoo/fields.py", line 1151, in __get__
record.ensure_one()
File "odoo/models.py", line 5202, in ensure_one
raise ValueError("Expected singleton: %s" % self)
```
Applying the changes will resolve the issue.
sentry-4217912848
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
Forward-Port-Of: odoo/odoo#123405