diff --git a/plm/__manifest__.py b/plm/__manifest__.py index 3b55af3c..b052cb6e 100644 --- a/plm/__manifest__.py +++ b/plm/__manifest__.py @@ -21,7 +21,7 @@ ############################################################################## { "name": "Product Lifecycle Management", - "version": "18.0.1.0.0", + "version": "18.0.2.0.0", "author": "OmniaSolutions", "website": "https://odooplm.omniasolutions.website", "category": "Manufacturing/Product Lifecycle Management (PLM)", diff --git a/plm/models/plm_mixin.py b/plm/models/plm_mixin.py index a89052fa..f14739e4 100644 --- a/plm/models/plm_mixin.py +++ b/plm/models/plm_mixin.py @@ -60,8 +60,6 @@ UPPERCASE_LETTERS = [ chr(i) for i in range(ord('A'), ord('Z') + 1) ] - - # def convert_to_letter(l, n): n_o_w = len(l) @@ -71,9 +69,6 @@ def convert_to_letter(l, n): else: out = l[n] return out - - -# # class RevisionBaseMixin(models.AbstractModel): _name = 'revision.plm.mixin' @@ -81,7 +76,8 @@ class RevisionBaseMixin(models.AbstractModel): _description = 'Revision Mixin' engineering_code = fields.Char(string="Engineering Code") - engineering_revision = fields.Integer(string="Engineering Revision index") + engineering_revision = fields.Integer(string="Engineering Revision index", + default=0) engineering_revision_letter = fields.Char( string="Engineering Revision letter", default="A" diff --git a/plm_pdf_workorder/models/mrp_routing_workcenter.py b/plm_pdf_workorder/models/mrp_routing_workcenter.py index 442f1c68..d61ea8d4 100755 --- a/plm_pdf_workorder/models/mrp_routing_workcenter.py +++ b/plm_pdf_workorder/models/mrp_routing_workcenter.py @@ -32,6 +32,11 @@ class MrpRoutingWorkcenter(models.Model): 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) diff --git a/plm_pdf_workorder/models/mrp_workorder.py b/plm_pdf_workorder/models/mrp_workorder.py index 82c2a4dd..3e5182ce 100755 --- a/plm_pdf_workorder/models/mrp_workorder.py +++ b/plm_pdf_workorder/models/mrp_workorder.py @@ -70,13 +70,19 @@ def action_switch_pdf(self): def create(self, vals): ret = super(MrpWorkorder, self).create(vals) for r in ret: - if r.operation_id.use_plm_pdf: - r.plm_pdf = base64.b64encode(self.getPDF(r)) + r.refresh_plm_instruction_pdf() return ret - def getPDF(self, workorder_id): + 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(workorder_id.product_id, checkState=True) + return report_model._render_qweb_pdf(self.product_id, + checkState=True) def fetch_release_attachment(self, workorder_id): if self.view_plm_pdf: diff --git a/plm_pdf_workorder/views/mrp_routing_workcenter.xml b/plm_pdf_workorder/views/mrp_routing_workcenter.xml index 159e6acf..c23a9fe9 100755 --- a/plm_pdf_workorder/views/mrp_routing_workcenter.xml +++ b/plm_pdf_workorder/views/mrp_routing_workcenter.xml @@ -8,6 +8,9 @@ +