[FIX] stock: allow "Print" of MRP reception report
During the OWL refactoring of the reception report, the "Print" button was hardcoded to only work for pickings. Unfortunately this means the button did NOT work when the report was opened for a MO. This is due to the report printing being dependent on the report's context values which can either be `default_picking_ids` or `default_production_ids` (and this is by design to avoid additional file extensions to handle both cases). When this button was used in the previous legacy_web_report's client_action, the entire action's context + data used to be passed as part of the Print action: https://github.com/odoo/odoo/blob/30fcb2e60fed17a473353b21bac4916e9ab77b10/addons/stock/static/src/legacy_web_report/client_action.js#L109-L119 The `data` and `context` is then stringified and added into the reportURL: https://github.com/odoo/odoo/blob/30fcb2e60fed17a473353b21bac4916e9ab77b10/addons/web/static/src/webclient/actions/action_service.js#L1042-L1050 But passing of the data isn't necessary in this case, and most of the context's content is not needed since the backend is still receiving + apply the current user's context thanks to the action_service: https://github.com/odoo/odoo/blob/30fcb2e60fed17a473353b21bac4916e9ab77b10/addons/web/static/src/webclient/actions/action_service.js#L1079 always providing it to the backend https://github.com/odoo/odoo/blob/30fcb2e60fed17a473353b21bac4916e9ab77b10/addons/web/controllers/report.py#L87 Therefore, to avoid an extra long report URL of all of the report's data/context, this fix has been designed to capture only the necessary context value and manually build the print URL accordingly. Noticed during task: 3046178 closes odoo/odoo#120935 X-original-commit: 5d66b73cddce1aae2c52f0a0ec8f9885be67b7ae Signed-off-by: Steve Van Essche <svs@odoo.com> Signed-off-by: Tiffany Chang <tic@odoo.com>
This commit is contained in:
+4
-2
@@ -16,6 +16,8 @@ export class ReceptionReportMain extends Component {
|
||||
this.ormService = useService("orm");
|
||||
this.actionService = useService("action");
|
||||
this.reportName = "stock.report_reception";
|
||||
const defaultDocIds = Object.entries(this.context).find(([k,v]) => k.startsWith("default_"));
|
||||
this.contextDefaultDoc = { field: defaultDocIds[0], ids: defaultDocIds[1] };
|
||||
this.state = useState({
|
||||
sourcesToLines: {},
|
||||
});
|
||||
@@ -29,7 +31,7 @@ export class ReceptionReportMain extends Component {
|
||||
|
||||
async getReportData() {
|
||||
const args = [
|
||||
this.context.default_picking_ids,
|
||||
this.contextDefaultDoc.ids,
|
||||
{ context: this.context, report_type: "html" },
|
||||
];
|
||||
return this.ormService.call(
|
||||
@@ -78,7 +80,7 @@ export class ReceptionReportMain extends Component {
|
||||
return this.actionService.doAction({
|
||||
type: "ir.actions.report",
|
||||
report_type: "qweb-pdf",
|
||||
report_name: `${this.reportName}/${this.context.default_picking_ids.join(",")}`,
|
||||
report_name: `${this.reportName}/?context={"${this.contextDefaultDoc.field}": ${JSON.stringify(this.contextDefaultDoc.ids)}}`,
|
||||
report_file: this.reportName,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user