diff --git a/addons/sale/models/sale_order_line.py b/addons/sale/models/sale_order_line.py index 9fccf03fc82..416a036a85f 100644 --- a/addons/sale/models/sale_order_line.py +++ b/addons/sale/models/sale_order_line.py @@ -1078,12 +1078,6 @@ class SaleOrderLine(models.Model): **self.env.context, **self._get_action_add_from_catalog_extra_context(order), }, - 'help': _("""
- Create a new product -
- You must define a product for everything you sell or purchase, - whether it's a storable product, a consumable or a service. -
"""), } #=== BUSINESS METHODS ===# diff --git a/addons/sale/static/src/js/product_catalog/kanban_controller.js b/addons/sale/static/src/js/product_catalog/kanban_controller.js new file mode 100644 index 00000000000..9a66fcaa5ab --- /dev/null +++ b/addons/sale/static/src/js/product_catalog/kanban_controller.js @@ -0,0 +1,48 @@ +/** @odoo-module **/ + +import { KanbanController } from "@web/views/kanban/kanban_controller"; +import { onWillStart } from "@odoo/owl"; +import { useService } from "@web/core/utils/hooks"; + + +export class ProductCatalogKanbanController extends KanbanController { + static template = "sale.ProductCatalogKanbanController"; + + setup() { + super.setup(); + this.action = useService("action"); + this.orm = useService("orm"); + this.orderId = this.props.context.order_id; + + onWillStart(async () => { + // Define the content of the button. + const orderStateInfo = await this.orm.searchRead( + "sale.order", [["id", "=", this.orderId]], ["state"] + ); + const orderIsQuotation = ["draft", "sent"].includes(orderStateInfo[0].state); + this.buttonString = `Back to ${orderIsQuotation ? "Quotation" : "Order"}` + }) + } + + // Force the slot for the "Back to Quotation" button to always be shown. + get canCreate() { + return true; + } + + async backToQuotation() { + // Restore the last form view from the breadcrumbs if breadcrumbs are available. + // If, for some weird reason, the user reloads the page then the breadcrumbs are + // lost, and we fall back to the form view ourselves. + if (this.env.config.breadcrumbs.length > 1) { + await this.action.restore(); + } else { + await this.action.doAction({ + type: "ir.actions.act_window", + res_model: "sale.order", + views: [[false, "form"]], + view_mode: "form", + res_id: this.orderId, + }); + } + } +} diff --git a/addons/sale/static/src/js/product_catalog/kanban_controller.xml b/addons/sale/static/src/js/product_catalog/kanban_controller.xml new file mode 100644 index 00000000000..3b97e40ed5d --- /dev/null +++ b/addons/sale/static/src/js/product_catalog/kanban_controller.xml @@ -0,0 +1,8 @@ + +
+ No products could be found.
+
+
+ You must define a product for everything you sell or purchase, + whether it's a storable product, a consumable or a service. +
+