Thursday, March 28, 2024
2 changes
Resolved issues and error corrections
This fix resolves a critical issue that prevented demo data from loading when using the sales planning features. The problem occurred due to a timing conflict in how certain calculations were being recomputed during module updates. By adjusting when these calculations are forced to recalculate, the system now loads demo data successfully without errors.
Original PR description
Steps to reproduce: ------------------- 1. create a new database with industry_fsm_sale_report, planning and no demo data; 2. enable debug mode; 3. go to settings; 4. load demo data. Issue: ------…
Steps to reproduce: ------------------- 1. create a new database with industry_fsm_sale_report, planning and no demo data; 2. enable debug mode; 3. go to settings; 4. load demo data. Issue: ------ Fails to load demo data due because of a `KeyError` on `planning.slot.allocated_hours`. Cause: ------ When we update the module and instantiate the field, we will call _recompute_all method but the method _compute_planning_hours_planned of sale.order.line does an `add_to_compute` of planning.slot() field allocated_hours. So after _recompute_all, there is still something to compute. Then we when we apply allocated_hours override (from sale_planning module) we change the field object: ```py from models.py Model._setup_base if len(fields_) == 1 and fields_[0]._direct and fields_[0].model_name == cls._name: cls._fields[name] = fields_[0] # we reuse the field else: Field = type(fields_[-1]) self._add_field(name, Field(_base_fields=fields_)) # new reference ``` and when we do the recompute, it is going to be done with the old field reference that is now no longer on the model. Solution: --------- The issue comes from using add_to_compute inside a compute, in this particular case (order of compute, field that is overriden, module update that modify records/recompute values, ...) it is causing an issue. So to avoid this issue, we force the recomputation directly after the add_to_compute. Note: ----- This is only happening in saas-16.4 and over because by chance, the _recompute_all in saas-16.3 and below recomputes sale.order.line.planning_hours_planned before planning.slot.allocated_hours. So by chance, when we add allocated_hours to be recomputed, it was already going to be done. In saas-16.4 planning.slot.allocated_hours is computed before planning_hours_planned and so the _recompute_all still has something to compute after _recompute_all. opw-3517083 opw-3691750 Closes odoo/odoo#139603 # note There was another PR previously about this issue (https://github.com/odoo/odoo/pull/139603) but this one should more sharply fix the origin of the issue. Forward-Port-Of: odoo/enterprise#57804
This update corrects critical issues in the Belgian Partner VAT listing report where data was being incorrectly calculated and grouped. The report was applying query limits incorrectly, causing the last column to show empty values, and VAT numbers were not being properly grouped together. These fixes ensure the report now displays accurate and properly organized data when generated or exported.
Original PR description
The aim of this commit is having a correct Partner VAT listing report. Before this fix, the report has a SQL query that uses the load_more_limit value as the limit. The issue was that we applied the limit on a set of 3 queries, as each of these query computes one column, the report gave us enough line but the last column was wrongly computed (as we exceed the limit after the second query). This means that we had an empty column. It was totally wrong. In the same time, other bugs were found. Report lines are by default ordered by using the res.partner order (based on the complete name), causing that when we generate the xml report, the groupby (from itertools) wrongly grouped lines as we don't sort these lines on the groupby key (vat number). To avoid this issue, we changed the groupby by using the one from odoo.tools. opw-3802689 opw-3766777 opw-3797584 opw-3791023 Forward-Port-Of: odoo/enterprise#59454