diff --git a/plm/__manifest__.py b/plm/__manifest__.py index ed4b5f07..76d703d8 100644 --- a/plm/__manifest__.py +++ b/plm/__manifest__.py @@ -20,7 +20,7 @@ ############################################################################## { "name": "Product Lifecycle Management", - "version": "16.0.25", + "version": "16.0.26", "author": "OmniaSolutions", "website": "https://odooplm.omniasolutions.website", "category": "Manufacturing/Product Lifecycle Management (PLM)", diff --git a/plm/controllers/main.py b/plm/controllers/main.py index 8c324e0a..a416d0c6 100755 --- a/plm/controllers/main.py +++ b/plm/controllers/main.py @@ -247,22 +247,24 @@ def get_preview(self, id): ir_attachement = request.env['ir.attachment'].sudo() for record in ir_attachement.search_read([('id','=', id)], ['preview']): return base64.b64decode(record.get('preview')) - + + @route('/plm/ir_attachment_printout/', type='http', auth='user', methods=['GET'], csrf=False) @webservice def get_printout(self, id): try: - ir_attachement = request.env['ir.attachment'].sudo() - for ir_attachement_id in ir_attachement.search_read([('id','=', id)], - ['printout','name']): - print_out_data = ir_attachement_id.get('printout') + for ir_attachement_id in request.env['ir.attachment'].sudo().browse(id): + if ir_attachement_id.printout: + print_out_data = request.env['report.plm.ir_attachment_pdf']._render_qweb_pdf(ir_attachement_id) + print_out_data = print_out_data[0] if print_out_data: - data = base64.b64decode(print_out_data) headers = [('Content-Type', 'application/pdf'), - ('Content-Length', len(data)), - ('Content-Disposition', 'inline; filename="%s"' % ir_attachement_id.get('name','no_name') + '.pdf')] - return request.make_response(data, headers) + ('Content-Length', len(print_out_data)), + ('Content-Disposition', f'inline; filename="{ir_attachement_id.engineering_code}_{ir_attachement_id.engineering_revision}.pdf"')] + return request.make_response(print_out_data, headers) else: - return request.not_found("Pdf document %s not Available" % ir_attachement_id.get('name','no_name')) + return request.not_found(f"Pdf document {ir_attachement_id.engineering_code} not Available") + else: + return request.not_found(f"Pdf document {ir_attachement_id.engineering_code} not Available") except Exception as ex: return Response(f"{ex}", status=500) diff --git a/plm/models/ir_attachment.py b/plm/models/ir_attachment.py index 69dfbf89..28f75bc9 100755 --- a/plm/models/ir_attachment.py +++ b/plm/models/ir_attachment.py @@ -115,9 +115,9 @@ def _compute_must_update_from_cad(self): for ir_attachment in self: ir_attachment.must_update_from_cad=False if ir_attachment.document_type =='2d': - ir_attachment.must_update_from_cad=ir_attachment_relation.is_2d_ok(ir_attachment) - if ir_attachment.document_type =='pr': - ir_attachment.must_update_from_cad=ir_attachment_relation.is_pr_ok(ir_attachment) + ir_attachment.must_update_from_cad= not ir_attachment_relation.is_2d_ok(ir_attachment) + elif ir_attachment.document_type =='pr': + ir_attachment.must_update_from_cad= not ir_attachment_relation.is_pr_ok(ir_attachment) def _getPrintoutName(self): for ir_attachment_id in self: @@ -126,7 +126,13 @@ def _getPrintoutName(self): def getPrintoutUrl(self): self.ensure_one() base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url') - return "%s/plm/ir_attachment_printout/%s" % (base_url, self.id) + return f"{base_url}/plm/ir_attachment_printout/{self.id}" + + def download_printout(self): + return {'type': 'ir.actions.act_url', + 'url': self.getPrintoutUrl(), + 'target': 'new', + } @property def actions(self): diff --git a/plm/models/ir_attachment_relations.py b/plm/models/ir_attachment_relations.py index 265d1b6d..d6f9aa08 100755 --- a/plm/models/ir_attachment_relations.py +++ b/plm/models/ir_attachment_relations.py @@ -183,10 +183,10 @@ def is_2d_ok(self, from_ir_attachment_id): ('link_kind', '=', 'LyTree') ]): if relation_id.parent_id.document_type=='2d' and relation_id.child_id.document_type in ['3d','pr']: - if relation_id.parent_id.write_date < relation_id.child_id.write_date: + if relation_id.parent_id.getLastCadSave() < relation_id.child_id.getLastCadSave(): return False if relation_id.child_id.document_type=='2d' and relation_id.parent_id.document_type in ['3d','pr'] : - if relation_id.child_id.write_date - + + + + Unrelease User + + + + PLM Integration Readonly diff --git a/plm/views/ir_attachment_view.xml b/plm/views/ir_attachment_view.xml index 4b5e0b95..1d0a0ea0 100755 --- a/plm/views/ir_attachment_view.xml +++ b/plm/views/ir_attachment_view.xml @@ -57,6 +57,18 @@ string="Confirm Document" class="oe_highlight" attrs="{'invisible': ['|',('is_checkout','=',True),('engineering_state','!=','draft')]}"/> +