Skip to content

Commit

Permalink
[IMP] add plm_many2one_image widget for list view
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Jan 27, 2025
1 parent c5e90eb commit eb8d14b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
5 changes: 2 additions & 3 deletions plm/static/src/js/many2one_widget/many2one_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class PlmMany2oneWidget extends Many2OneField {

async setup() {
super.setup();
console.log("..........1");
this.imageData = false;
this.relatedField = false;
this.imageToolTipData = false;
Expand Down Expand Up @@ -56,8 +55,8 @@ export class PlmMany2oneWidget extends Many2OneField {
}
}

onImageClicked() {

onImageClicked(event) {
event.stopPropagation(); // It stops the event from triggering any additional event handlers
let selectedProductId = this.props.record.data.product_id[0];
let relatedFieldName = this.props.options.linked_field;
let model = this.props.record.model.root.model.config.fields[this.props.name].relation;
Expand Down
13 changes: 12 additions & 1 deletion plm/static/src/js/many2one_widget/many2one_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@

<templates xml:space="preserve">
<t t-name="plm.PlmMany2oneWidget" t-inherit="web.Many2OneField" t-inherit-mode="primary">
<!-- plm_many2one_widget for form view -->
<xpath expr="//div[hasclass('o_field_many2one_selection')]/Many2XAutocomplete" position="before">
<span t-if="imageData">
<span t-if="imageData" style="padding:0px 10px 0px 0px;">
<img data-tooltip-template="web.ImageZoomTooltip"
t-att-data-tooltip-info="imageToolTipData"
style="width:30px;height:30px" t-att-src="imageData"
t-on-click="onImageClicked"
/>
</span>
</xpath>
<!-- plm_many2one_widget for list view -->
<xpath expr="//t[@t-if='!props.canOpen']" position="before">
<span t-if="imageData" style="padding:0px 10px 0px 0px;" class="plm_m2o_avatar">
<img data-tooltip-template="web.ImageZoomTooltip"
t-att-data-tooltip-info="imageToolTipData"
style="width:30px;height:30px" t-att-src="imageData"
t-on-click="onImageClicked"
/>
</span>
</xpath>
</t>
</templates>

0 comments on commit eb8d14b

Please sign in to comment.