diff --git a/plm_pdf_workorder/models/mrp_routing_workcenter.py b/plm_pdf_workorder/models/mrp_routing_workcenter.py
index d61ea8d4..e03d0ecc 100755
--- a/plm_pdf_workorder/models/mrp_routing_workcenter.py
+++ b/plm_pdf_workorder/models/mrp_routing_workcenter.py
@@ -23,26 +23,10 @@
Created on Mar 30, 2016
@author: Daniel Smerghetto
"""
-from odoo import _, api, fields, models
+from odoo import _, fields, models
class MrpRoutingWorkcenter(models.Model):
_inherit = "mrp.routing.workcenter"
- use_plm_pdf = fields.Boolean(_("Use PLM PDF"))
- plm_pdf = fields.Binary(_("Plm PDF"), compute="_compute_plm_pdf_data")
-
- def refresh_plm_instruction_pdf(self):
- self.ensure_one()
- for workorder_id in self.workorder_ids.filtered(lambda x: x.use_plm_pdf):
- workorder_id.refresh_plm_instruction_pdf()
-
- def _compute_plm_pdf_data(self):
- workorder_id = self.env["mrp.workorder"].search([
- ("operation_id", "in", self.ids)
- ], limit=1)
- for rec in self:
- if rec.use_plm_pdf:
- rec.plm_pdf = workorder_id.plm_pdf
- else:
- rec.plm_pdf = False
+ use_plm_docs = fields.Boolean(_("Use PLM Docs"))
diff --git a/plm_pdf_workorder/models/mrp_workorder.py b/plm_pdf_workorder/models/mrp_workorder.py
index 2eae83c7..94a57fa5 100755
--- a/plm_pdf_workorder/models/mrp_workorder.py
+++ b/plm_pdf_workorder/models/mrp_workorder.py
@@ -30,9 +30,8 @@
class MrpWorkorder(models.Model):
_inherit = "mrp.workorder"
- plm_pdf = fields.Binary(_("Plm PDF"), compute="_compute_production_pdf", store=True)
- use_plm_pdf = fields.Boolean(
- related="operation_id.use_plm_pdf", string=_("Use PLM PDF")
+ use_plm_docs = fields.Boolean(
+ related="operation_id.use_plm_docs", string=_("Use PLM Docs")
)
production_doc_ids = fields.Many2many("ir.attachment",
compute="_compute_production_doc_ids",
@@ -41,27 +40,10 @@ class MrpWorkorder(models.Model):
@api.depends("product_id.linkeddocuments.is_production_doc")
def _compute_production_doc_ids(self):
for rec in self:
- if rec.product_id.linkeddocuments:
- rec.production_doc_ids = rec.product_id.linkeddocuments.filtered(
- lambda doc: doc.is_production_doc == True
- )
- else:
- rec.production_doc_ids = False
-
- @api.model_create_multi
- def create(self, vals):
- ret = super(MrpWorkorder, self).create(vals)
- for r in ret:
- r.refresh_plm_instruction_pdf()
- return ret
-
- def refresh_plm_instruction_pdf(self):
- self.ensure_one()
- if self.operation_id.use_plm_pdf:
- self.plm_pdf = base64.b64encode(self.getAttachmentWorkorderPDF())
-
- def getAttachmentWorkorderPDF(self):
- self.ensure_one()
- report_model = self.env["report.plm.product_production_one_pdf_latest"]
- return report_model._render_qweb_pdf(self.product_id, checkState=True)
-
+ if rec.use_plm_docs:
+ if rec.product_id.linkeddocuments:
+ rec.production_doc_ids = rec.product_id.linkeddocuments.filtered(
+ lambda doc: doc.is_production_doc == True
+ )
+ else:
+ rec.production_doc_ids = False
diff --git a/plm_pdf_workorder/views/ir_attachment.xml b/plm_pdf_workorder/views/ir_attachment.xml
index 9a0ab697..46aae19c 100644
--- a/plm_pdf_workorder/views/ir_attachment.xml
+++ b/plm_pdf_workorder/views/ir_attachment.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/plm_pdf_workorder/views/mrp_routing_workcenter.xml b/plm_pdf_workorder/views/mrp_routing_workcenter.xml
index 303e3506..3c225f8e 100755
--- a/plm_pdf_workorder/views/mrp_routing_workcenter.xml
+++ b/plm_pdf_workorder/views/mrp_routing_workcenter.xml
@@ -7,22 +7,22 @@
-
-
-
+
+
+
+
- use_plm_pdf == True
+ use_plm_docs == True
- use_plm_pdf == True or worksheet_type != 'pdf'
+ use_plm_docs == True or worksheet_type != 'pdf'
- use_plm_pdf == True or worksheet_type != 'google_slide'
+ use_plm_docs == True or worksheet_type != 'google_slide'
- use_plm_pdf == True or worksheet_type != 'text'
+ use_plm_docs == True or worksheet_type != 'text'
diff --git a/plm_pdf_workorder/views/mrp_workorder.xml b/plm_pdf_workorder/views/mrp_workorder.xml
index 0209ac2f..364b38ec 100755
--- a/plm_pdf_workorder/views/mrp_workorder.xml
+++ b/plm_pdf_workorder/views/mrp_workorder.xml
@@ -7,10 +7,10 @@
- use_plm_pdf == True or not worksheet and not worksheet_google_slide and not operation_note
+ use_plm_docs == True or not worksheet and not worksheet_google_slide and not operation_note
-
+
-
- plm.pdf.show.document.workorder
- mrp.workorder
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/plm_pdf_workorder_enterprise/__init__.py b/plm_pdf_workorder_enterprise/__init__.py
new file mode 100644
index 00000000..4213b8b1
--- /dev/null
+++ b/plm_pdf_workorder_enterprise/__init__.py
@@ -0,0 +1,2 @@
+# -*- encoding: utf-8 -*-
+from . import models
diff --git a/plm_pdf_workorder_enterprise/models/__init__.py b/plm_pdf_workorder_enterprise/models/__init__.py
new file mode 100644
index 00000000..cb4d6977
--- /dev/null
+++ b/plm_pdf_workorder_enterprise/models/__init__.py
@@ -0,0 +1,2 @@
+# -*- encoding: utf-8 -*-
+from . import mrp_workorder
diff --git a/plm_pdf_workorder_enterprise/models/mrp_workorder.py b/plm_pdf_workorder_enterprise/models/mrp_workorder.py
index e5c5aa05..2a3764a9 100644
--- a/plm_pdf_workorder_enterprise/models/mrp_workorder.py
+++ b/plm_pdf_workorder_enterprise/models/mrp_workorder.py
@@ -30,11 +30,9 @@ def action_open_workorder_kanban(self):
"plm.document_kanban_view"
)
ctx = self.env.context.copy()
- domain = [
- ('is_plm', '=', True),
- ('is_production_doc', '=', True),
- ('id', 'in', self.production_doc_ids.ids)
- ]
+ domain = [('is_plm', '=', True),
+ ('is_production_doc', '=', True),
+ ('id', 'in', self.production_doc_ids.ids)]
ctx.update({
"create": False,
"delete": False,
diff --git a/plm_pdf_workorder_enterprise/static/src/mrpDisplayRecord.xml b/plm_pdf_workorder_enterprise/static/src/mrpDisplayRecord.xml
index e8d10509..e3beea3c 100644
--- a/plm_pdf_workorder_enterprise/static/src/mrpDisplayRecord.xml
+++ b/plm_pdf_workorder_enterprise/static/src/mrpDisplayRecord.xml
@@ -2,17 +2,22 @@
-
-
+
+
-
-
- Plm WorkSheet
+
+
+
+ Plm WorkSheet
+
+
+
+
+
diff --git a/plm_pdf_workorder_enterprise/static/src/mrpWorksheet.js b/plm_pdf_workorder_enterprise/static/src/mrpWorksheet.js
index 29bf6bf2..ef1e0b4d 100644
--- a/plm_pdf_workorder_enterprise/static/src/mrpWorksheet.js
+++ b/plm_pdf_workorder_enterprise/static/src/mrpWorksheet.js
@@ -1,40 +1,36 @@
/** @odoo-module **/
-
import { MrpWorksheet } from "@mrp_workorder/mrp_display/mrp_record_line/mrp_worksheet";
-import { MrpWorksheetDialog } from "@mrp_workorder/mrp_display/dialog/mrp_worksheet_dialog";
import { MrpDisplayRecord } from '@mrp_workorder/mrp_display/mrp_display_record'
-import { markup } from "@odoo/owl";
+
export class PlmMrpWorksheet extends MrpWorksheet{
- setup(){
+ async setup(){
super.setup();
+ this.showPlmDocs = false;
+ if(this.props && this.props.record && this.props.record.data && this.props.record.data.operation_id && this.props.record.data.operation_id.length !=0){
+ let displayDocs = await this.props.record.model.orm.read(
+ "mrp.routing.workcenter",
+ [ this.props.record.data.operation_id[0]],
+ ["use_plm_docs"]
+ );
+ if(displayDocs.length !=0){
+ this.showPlmDocs = displayDocs[0].use_plm_docs;
+ this.render();
+ }
+ }
+ }
+
+ get showPlmDocCheck() {
+ return this.showPlmDocs;
}
+
async clicked() {
- debugger;
let action_open_workorder_kanban = await this.props.record.model.orm.call("mrp.workorder", "action_open_workorder_kanban", [this.props.record.resId]);
return this.action.doAction(action_open_workorder_kanban);
-// let worksheetData = false;
-// const sheet = await this.props.record.model.orm.read(
-// "mrp.workorder",
-// [this.props.record.resId],
-// ["plm_pdf"]
-// );
-// if(sheet && sheet.length !=0){
-//
-// worksheetData = {
-// resModel: "mrp.workorder",
-// resId: this.props.record.resId,
-// resField: "plm_pdf",
-// value: sheet[0].plm_pdf,
-// page: 1,
-// };
-// this.dialog.add(MrpWorksheetDialog, {
-// worksheetText: markup(''),
-// worksheetData,
-// });
-// }
}
}
+
PlmMrpWorksheet.template = 'plm_pdf_workorder_enterprise.MrpWorksheet'
+
MrpDisplayRecord.components = {
...MrpDisplayRecord.components,
PlmMrpWorksheet,