Skip to content

Commit

Permalink
IMP: add customization of the reports easely
Browse files Browse the repository at this point in the history
  • Loading branch information
mboscolo committed Nov 21, 2023
1 parent fbc1726 commit 05436c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions plm/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ def get_preview(self, id):
for record in ir_attachement.search_read([('id','=', id)], ['preview']):
return base64.b64decode(record.get('preview'))

@route('/plm/product_product_preview/<int:product_id>', type='http', auth='user', methods=['GET'], csrf=False)
@webservice
def get_pp_preview(self, product_id):
product_product_sudo = request.env['product.product'].sudo()
for product_product_id in product_product_sudo.search([('id','=', product_id)]):
return base64.b64decode(product_product_id.image_1920)

@route('/plm/ir_attachment_printout/<int:id>', type='http', auth='user', methods=['GET'], csrf=False)
@webservice
Expand Down
16 changes: 11 additions & 5 deletions plm/report/document_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ class ReportDocumentPdf(models.AbstractModel):
_name = 'report.plm.ir_attachment_pdf'
_description = 'Report Document PDF'

@api.model
def _render_qweb_pdf(self, documents=None, data=None):
docType = self.env['ir.attachment']
docRepository = docType._get_filestore()
def get_custom_text(self):
to_zone = tz.gettz(self.env.context.get('tz', 'Europe/Rome'))
from_zone = tz.tzutc()
dt = datetime.now()
Expand All @@ -48,7 +45,16 @@ def _render_qweb_pdf(self, documents=None, data=None):
'date_now': localDT.ctime(),
'state': 'doc_obj.engineering_state',
}
output = BookCollector(jumpFirst=False, customText=(msg, msg_vals), bottomHeight=10, poolObj=self.env)
return (msg, msg_vals)

@api.model
def _render_qweb_pdf(self, documents=None, data=None):
docType = self.env['ir.attachment']
docRepository = docType._get_filestore()
output = BookCollector(jumpFirst=False,
customText=self.get_custom_text(),
bottomHeight=10,
poolObj=self.env)
return packDocuments(docRepository, documents, output)

@api.model
Expand Down

0 comments on commit 05436c5

Please sign in to comment.