From dd9220459c857dc98e76e3d050ce95246dc8da84 Mon Sep 17 00:00:00 2001 From: clesgow Date: Fri, 2 Sep 2022 07:44:48 +0000 Subject: [PATCH] [REF] stock: reception_report into WOWL Converts the legacy reception report into WOWL. Fixes 'Assign All' buttons disappearing from the report until it is reloaded when clicking on them. Removes references to 'report_type == html' from xml since it is only used as PDF now. Part of the global conversion of stock to WOWL. Task-2885757 closes odoo/odoo#102687 X-original-commit: f310d8f16b57c776ad92406bd52daa707ad45a88 Signed-off-by: Arnold Moyaux (arm) Signed-off-by: Quentin Wolfs (quwo) --- addons/stock/report/report_stock_reception.py | 49 +++++ .../stock/report/report_stock_reception.xml | 65 +----- .../stock_reception_report_line.js | 75 +++++++ .../stock_reception_report_line.xml | 35 +++ .../stock_reception_report_main.js | 150 +++++++++++++ .../stock_reception_report_main.xml | 48 +++++ .../stock_reception_report_table.js | 96 +++++++++ .../stock_reception_report_table.xml | 42 ++++ .../static/src/js/report_stock_reception.js | 202 ------------------ 9 files changed, 500 insertions(+), 262 deletions(-) create mode 100644 addons/stock/static/src/components/reception_report_line/stock_reception_report_line.js create mode 100644 addons/stock/static/src/components/reception_report_line/stock_reception_report_line.xml create mode 100644 addons/stock/static/src/components/reception_report_main/stock_reception_report_main.js create mode 100644 addons/stock/static/src/components/reception_report_main/stock_reception_report_main.xml create mode 100644 addons/stock/static/src/components/reception_report_table/stock_reception_report_table.js create mode 100644 addons/stock/static/src/components/reception_report_table/stock_reception_report_table.xml delete mode 100644 addons/stock/static/src/js/report_stock_reception.js diff --git a/addons/stock/report/report_stock_reception.py b/addons/stock/report/report_stock_reception.py index 1bd43b93a19..a1247230afc 100644 --- a/addons/stock/report/report_stock_reception.py +++ b/addons/stock/report/report_stock_reception.py @@ -11,6 +11,16 @@ class ReceptionReport(models.AbstractModel): _name = 'report.stock.report_reception' _description = "Stock Reception Report" + @api.model + def get_report_data(self, docids, data): + report_values = self._get_report_values(docids, data) + report_values['docs'] = self._format_html_docs(report_values.get('docs', False)) + report_values['sources_info'] = self._format_html_sources_info(report_values.get('sources_to_lines', {})) + report_values['sources_to_lines'] = self._format_html_sources_to_lines(report_values.get('sources_to_lines', {})) + report_values['sources_to_formatted_scheduled_date'] = self._format_html_sources_to_date(report_values.get('sources_to_formatted_scheduled_date', {})) + report_values['show_uom'] = self.env.user.has_group('uom.group_uom') + return report_values + @api.model def _get_report_values(self, docids, data=None): ''' This report is flexibly designed to work with both individual and batch pickings. @@ -325,3 +335,42 @@ class ReceptionReport(models.AbstractModel): def _action_unassign(self, in_move, out_move): """ For extension purposes only """ return + + def _format_html_docs(self, docs): + """ Format docs to be sent in an html request. """ + return [{ + 'id': doc.id, + 'name': doc.display_name, + 'state': doc.state, + 'display_state': dict(doc._fields['state']._description_selection(self.env)).get(doc.state), + } for doc in docs] if docs else docs + + def _format_html_sources_to_date(self, sources_to_dates): + """ Format sources_to_formatted_scheduled_date to be sent in an html request. """ + return {str(source): date for (source, date) in sources_to_dates.items()} + + def _format_html_sources_to_lines(self, sources_to_lines): + """ Format sources_to_lines to be sent in an html request, while adding an index for OWL's t-foreach. """ + return { + str(source): [{**line, 'index': i, 'move_out_id': line['move_out'].id} for i, line in enumerate(lines)] + for source, lines in sources_to_lines.items() + } + + def _format_html_sources_info(self, sources_to_lines): + """ Format used info from sources of sources_to_lines to be sent in an html request. """ + return {str(source): [self._format_html_source(s, index == 0) for index, s in enumerate(source)] for source in sources_to_lines.keys()} + + def _format_html_source(self, source, is_picking=False): + """ Format used info from a single source to be sent in an html request. """ + formatted = { + 'id': source.id, + 'model': source._name, + 'name': source.display_name, + } + if is_picking: + formatted.update({ + 'priority': source.priority, + 'partner_id': source.partner_id.id if source.partner_id else False, + 'partner_name': source.partner_id.name if source.partner_id else False, + }) + return formatted diff --git a/addons/stock/report/report_stock_reception.xml b/addons/stock/report/report_stock_reception.xml index da29ac41954..700c3ec3fb5 100644 --- a/addons/stock/report/report_stock_reception.xml +++ b/addons/stock/report/report_stock_reception.xml @@ -59,9 +59,9 @@ -
+
- + - - - + - - @@ -151,16 +99,13 @@
@@ -78,71 +78,19 @@ Expected Delivery: - - - -
- - - - - -

No allocation need found. -

+