[IMP] sale: always give access to the product form
Users were not able to access the product (product/template) form view when the product was readonly (cf product_updatable field logic). This commit makes sure that a user can always access the product form view through either the external button or clicking on the product field itself (when readonly). Task-3063622 closes odoo/odoo#107237 X-original-commit: 7bf45b022e73a83d9b04350b8899919714e59223 Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com> Co-authored-by: Valentin Vallaeys <vava@odoo.com>
This commit is contained in:
co-authored by
Valentin Vallaeys
parent
6202c296d8
commit
71737f4cb9
@@ -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
|
||||
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="sale.SaleProductField" t-inherit="web.Many2OneField" t-inherit-mode="primary" owl="1">
|
||||
<!-- Make the product label clickable (to open its form view) when the user cannot
|
||||
access it through the external button (because the product/line is readonly) -->
|
||||
<xpath expr="//t[@t-if='!props.canOpen']" position="attributes">
|
||||
<attribute name="t-if">
|
||||
!isProductClickable
|
||||
</attribute>
|
||||
</xpath>
|
||||
<!-- Show configuration button for custom lines/products -->
|
||||
<xpath expr="//t[@t-if='hasExternalButton']" position="before">
|
||||
<t t-if="hasConfigurationButton">
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user