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 @@ - -