Skip to content

Commit

Permalink
[MOD] update plm_many2one_image widget for product template
Browse files Browse the repository at this point in the history
  • Loading branch information
jayraj-omnia committed Jan 28, 2025
1 parent 452d19b commit a956eb1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plm/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
##############################################################################
{
"name": "Product Lifecycle Management",
"version": "18.0.3.0.0",
"version": "18.0.3.0.1",
"author": "OmniaSolutions",
"website": "https://odooplm.omniasolutions.website",
"category": "Manufacturing/Product Lifecycle Management (PLM)",
Expand Down
1 change: 1 addition & 0 deletions plm/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -1936,6 +1936,7 @@ def action_open_linked_field(self, related_field):
})

return {
"name": "Linked Documents",
"type": "ir.actions.act_window",
"view_mode": "kanban",
'domain': domain,
Expand Down
9 changes: 5 additions & 4 deletions plm/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,13 @@ class ProductTemplate(models.Model):
compute=lambda self: self._compute_eng_code_editable()
)
kit_bom = fields.Boolean(_('KIT Bom Type'))

linkeddocuments = fields.Many2many(related="product_variant_id.linkeddocuments")

def action_open_linked_field(self, related_field):
return self.product_variant_id.action_open_linked_field(related_field)

product_id = self.env['product.product'].browse(self.id)
return product_id.action_open_linked_field(related_field)

def unlinkCheckBomRelations(self):

def print_where_struct(self, where_struct):
Expand Down Expand Up @@ -212,7 +213,7 @@ def init(self):
""")

def getSequenceFrom(self, prefix, digit, start_number= 0):
plm_prefix = f"PLM_SEQUENCE_{prefix}"
plm_prefix = f"PLM_SEQUENCE_{prefix}"
sequence=None
for sequence in self.env['ir.sequence'].sudo().search([('code','=', plm_prefix)]):
break
Expand Down
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 @@ -38,7 +38,6 @@ export class PlmMany2oneWidget extends Many2OneField {
});
if (this.props && this.props.record && this.props.record.data && this.props.record.data[this.props.name] && this.props.record.data[this.props.name].length != 0) {


let imageData = await this.env.model.orm.call(this.relation, "search_read", [], {
domain: [["id", "=", this.props.record.data[this.props.name][0]]],
fields: [this.props.options.image_field],
Expand All @@ -55,12 +54,12 @@ export class PlmMany2oneWidget extends Many2OneField {
}
}

onImageClicked(event) {
async 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;
let action_open_linked_field = this.props.record.model.orm.call(model, "action_open_linked_field", [selectedProductId, relatedFieldName]);
let action_open_linked_field = await this.props.record.model.orm.call(model, "action_open_linked_field", [selectedProductId, relatedFieldName]);
return this.action.doAction(action_open_linked_field);
}
}
Expand Down

0 comments on commit a956eb1

Please sign in to comment.