diff --git a/addons/sale/static/src/js/sale_product_field.js b/addons/sale/static/src/js/sale_product_field.js index b2d90d2f14c..28e3e152b45 100644 --- a/addons/sale/static/src/js/sale_product_field.js +++ b/addons/sale/static/src/js/sale_product_field.js @@ -47,6 +47,14 @@ export class SaleOrderLineProductField extends Many2OneField { } } + get isProductClickable() { + // product form should be accessible if the widget field is readonly + // or if the line cannot be edited (e.g. locked SO) + return ( + this.props.record.isReadonly(this.props.name) + || this.props.record.model.root.isReadonly('order_line') + ) + } get hasExternalButton() { // Keep external button, even if field is specified as 'no_open' so that the user is not // redirected to the product when clicking on the field content @@ -71,6 +79,17 @@ export class SaleOrderLineProductField extends Many2OneField { return 'fa-pencil'; } + onClick(ev) { + // Override to get internal link to products in SOL that cannot be edited + if (this.props.readonly) { + ev.stopPropagation(); + this.openAction(); + } + else { + super.onClick(ev); + } + } + async _onProductTemplateUpdate() { } async _onProductUpdate() { } // event_booth_sale, event_sale, sale_renting diff --git a/addons/sale/static/src/xml/sale_product_field.xml b/addons/sale/static/src/xml/sale_product_field.xml index 89cb3390f23..4fa01d57225 100644 --- a/addons/sale/static/src/xml/sale_product_field.xml +++ b/addons/sale/static/src/xml/sale_product_field.xml @@ -3,6 +3,14 @@ + + + + !isProductClickable + + +