Daily updates from Odoo
Thursday, June 27, 2024
1 change
Resolved issues and error corrections
This fix resolves a memory error that occurred during system upgrades when calculating outstanding amounts for customers with very large numbers of transactions. The issue affected the account follow-up feature when processing partners with hundreds of thousands of transaction records, causing the system to run out of memory. The fix optimizes how these calculations are performed to handle large datasets more efficiently.
Original PR description
During upgrade `_compute_total_due` method calculate for `total_due` and `total_overdue`, with too many move lines, so raises MemoryError queries: ``` jard_1413607=> select partner_id, count(id)…
During upgrade `_compute_total_due` method calculate for `total_due` and `total_overdue`,
with too many move lines, so raises MemoryError
queries:
```
jard_1413607=> select partner_id, count(id) total_move_lines from account_move_line where partner_id is not null group by partner_id order by total_move_lines desc limit 5;
partner_id | total_move_lines
------------+------------------
1905 | 547530
1371 | 288578
1396 | 18423
3223 | 10945
1244 | 6988
```
traceback:
```py
Traceback (most recent call last):
File "/tmp/tmpj_23hd3k/migrations/testing.py", line 208, in test_check
self.check(value)
File "/tmp/tmpj_23hd3k/migrations/base/tests/test_mock_crawl.py", line 151, in check
self.assertFalse(diff, msg)
AssertionError: [('account.menu_action_move_journal_line_form', 125, 'Accounting > Accounting > Journals > Journal Entries', 205), ('purchase.menu_procurement_management_supplier_name', 247, 'Purchase > Orders > Vendors', 218), ('account.menu_account_customer', 115, 'Accounting > Customers > Customers', 217), ('account.menu_action_move_out_refund_type', 111, 'Accounting > Customers > Credit Notes', 207), ('account.menu_account_supplier', 122, 'Accounting > Vendors > Vendors', 218), ('account.menu_action_move_out_invoice_type', 110, 'Accounting > Customers > Invoices', 206), ('account.menu_action_move_in_refund_type', 118, 'Accounting > Vendors > Refunds', 209), ('account.menu_action_account_moves_all', 126, 'Accounting > Accounting > Journals > Journal Items', 204), ('account.menu_action_move_in_invoice_type', 117, 'Accounting > Vendors > Bills', 208), ('sale.res_partner_menu', 179, 'Sales > Orders > Customers', 217), ('point_of_sale.menu_point_of_sale_customer', 461, 'Point of Sale > Orders > Customers', 217)] is not false : At least one menu or view working before upgrade is not working after upgrade.
('account.menu_action_move_journal_line_form', 125, 'Accounting > Accounting > Journals > Journal Entries', 205):
Traceback (most recent call last):
File "/tmp/tmpj_23hd3k/migrations/base/tests/test_mock_crawl.py", line 252, in crawl_menu
self.mock_action(action_vals)
File "/tmp/tmpj_23hd3k/migrations/base/tests/test_mock_crawl.py", line 409, in mock_action
mock_method(model, view, fields_list, domain, group_by)
File "/tmp/tmpj_23hd3k/migrations/base/tests/test_mock_crawl.py", line 438, in mock_view_form
[data] = record.read(fields_list)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 3538, in read
return self._read_format(fnames=fields, load=load)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 3749, in _read_format
vals[name] = convert(record[name], record, use_display_name)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 6590, in __getitem__
return self._fields[key].__get__(self, self.env.registry[self._name])
File "/home/odoo/src/odoo/17.0/odoo/fields.py", line 1207, in __get__
self.compute_value(recs)
File "/home/odoo/src/odoo/17.0/odoo/fields.py", line 1389, in compute_value
records._compute_field_value(self)
File "/home/odoo/src/odoo/17.0/addons/base_automation/models/base_automation.py", line 745, in _compute_field_value
return _compute_field_value.origin(self, field)
File "/home/odoo/src/odoo/17.0/addons/mail/models/mail_thread.py", line 424, in _compute_field_value
return super()._compute_field_value(field)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 4867, in _compute_field_value
fields.determine(field.compute, self)
File "/home/odoo/src/odoo/17.0/odoo/fields.py", line 102, in determine
return needle(*args)
File "/home/odoo/src/odoo/17.0/addons/stock_landed_costs/models/account_move.py", line 19, in _compute_landed_costs_visible
account_move.landed_costs_visible = any(line.is_landed_costs_line for line in account_move.line_ids)
File "/home/odoo/src/odoo/17.0/addons/stock_landed_costs/models/account_move.py", line 19, in <genexpr>
account_move.landed_costs_visible = any(line.is_landed_costs_line for line in account_move.line_ids)
File "/home/odoo/src/odoo/17.0/odoo/fields.py", line 1182, in __get__
recs._fetch_field(self)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 3775, in _fetch_field
self.fetch(fnames)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 3825, in fetch
fetched = self._fetch_query(query, fields_to_fetch)
File "/home/odoo/src/odoo/17.0/odoo/models.py", line 3930, in _fetch_query
self.env.cache.insert_missing(fetched, field, values)
File "/home/odoo/src/odoo/17.0/odoo/api.py", line 1108, in insert_missing
field_cache.setdefault(id_, val)
MemoryError
```
Failed request: UPG-1403488
Ticket: 3797437