Exemplo n.º 1
0
 def create(self, cr, uid, ids, datas, context=None):
     self.pool = pooler.get_pool(cr.dbname)
     docRepository = self.pool.get('plm.document')._get_filestore(cr)
     componentType = self.pool.get('product.product')
     user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
     msg = "Printed by " + \
         str(user.name) + " : " + str(time.strftime("%d/%m/%Y %H:%M:%S"))
     output = BookCollector(jumpFirst=False,
                            customTest=(False, msg),
                            bottomHeight=10)
     children = []
     documents = []
     components = componentType.browse(cr, uid, ids, context=context)
     for component in components:
         documents.extend(component.linkeddocuments)
         idcs = componentType._getChildrenBom(cr,
                                              uid,
                                              component,
                                              0,
                                              1,
                                              context=context)
         children = componentType.browse(cr, uid, idcs, context=context)
         for child in children:
             documents.extend(child.linkeddocuments)
     if len(documents):
         return packDocuments(docRepository, list(set(documents)), output)
     if context.get("raise_report_warning", True):
         raise UserError(_("No Document found"))
Exemplo n.º 2
0
 def create(self, cr, uid, ids, datas, context=None):
     self.pool = pooler.get_pool(cr.dbname)
     docType=self.pool.get('plm.document')
     docRepository=docType._get_filestore(cr)
     documents = docType.browse(cr, uid, ids, context=context)
     userType=self.pool.get('res.users')
     user=userType.browse(cr, uid, uid, context=context)
     msg = "Printed by "+str(user.name)+" : "+ str(time.strftime("%d/%m/%Y %H:%M:%S"))
     output  = BookCollector(jumpFirst=False,customTest=(False,msg),bottomHeight=10)
     return packDocuments(docRepository,documents,output)
Exemplo n.º 3
0
 def create(self, cr, uid, ids, datas, context={}):
     components, documents, docRepository, output, _componentType = commonInfos(cr, uid, ids, context)
     for component in components:
         for idDoc in component.linkeddocuments:
             if idDoc.state in ['released', 'undermodify']:
                 documents.extend(idDoc)
     if len(documents):
         return packDocuments(docRepository, documents, output)
     if context.get("raise_report_warning", True):
         raise UserError(_("No Document found"))
     return False, False
Exemplo n.º 4
0
 def create(self, cr, uid, ids, datas, context=None):
     self.pool = pooler.get_pool(cr.dbname)
     docType = self.pool.get('plm.document')
     docRepository = docType._get_filestore(cr)
     documents = docType.browse(cr, uid, ids, context=context)
     userType = self.pool.get('res.users')
     user = userType.browse(cr, uid, uid, context=context)
     msg = "Printed by " + str(user.name) + " : " + str(
         time.strftime("%d/%m/%Y %H:%M:%S"))
     output = BookCollector(jumpFirst=False,
                            customTest=(False, msg),
                            bottomHeight=10)
     return packDocuments(docRepository, documents, output)
Exemplo n.º 5
0
 def create(self, cr, uid, ids, datas, context=None):
     self.pool = pooler.get_pool(cr.dbname)
     docRepository=self.pool.get('plm.document')._get_filestore(cr)
     componentType=self.pool.get('product.product')
     user=self.pool.get('res.users').browse(cr, uid, uid, context=context)
     msg = "Printed by "+str(user.name)+" : "+ str(time.strftime("%d/%m/%Y %H:%M:%S"))
     output  = BookCollector(jumpFirst=False,customTest=(False,msg),bottomHeight=10)
     children=[]
     documents=[]
     components=componentType.browse(cr, uid, ids, context=context)
     for component in components:
         documents.extend(component.linkeddocuments)
     return packDocuments(docRepository,documents,output)
Exemplo n.º 6
0
 def create(self, cr, uid, ids, datas, context=None):
     components, documents, docRepository, output, componentType = commonInfos(cr, uid, ids, context)
     children = []
     for component in components:
         documents.extend(component.linkeddocuments)
         idcs = componentType._getChildrenBom(component, 0, 1)
         children = componentType.browse(idcs)
         for child in children:
             documents.extend(child.linkeddocuments)
     if len(documents):
         return packDocuments(docRepository, list(set(documents)), output)
     if context.get("raise_report_warning", True):
         raise UserError(_("No Document found"))
Exemplo n.º 7
0
 def create(self, cr, uid, ids, datas, context=None):
     env = odoo.api.Environment(cr, uid, context or {})
     docType = env['plm.document']
     docRepository = docType._get_filestore()
     documents = docType.browse(ids)
     userType = env['res.users']
     user = userType.browse(uid)
     to_zone = tz.gettz(context.get('tz', 'Europe/Rome'))
     from_zone = tz.tzutc()
     dt = datetime.now()
     dt = dt.replace(tzinfo=from_zone)
     localDT = dt.astimezone(to_zone)
     localDT = localDT.replace(microsecond=0)
     msg = "Printed by " + str(user.name) + " : " + str(localDT.ctime())
     output = BookCollector(jumpFirst=False,
                            customTest=(False, msg),
                            bottomHeight=10)
     return packDocuments(docRepository, documents, output)
Exemplo n.º 8
0
 def create(self, cr, uid, ids, datas, context=None):
     components, documents, docRepository, output, _componentType = commonInfos(cr, uid, ids, context)
     for component in components:
         documents.extend(component.linkeddocuments)
     if len(documents):
         return packDocuments(docRepository, documents, output)
     if context.get("raise_report_warning", True):
         # To avoid error when no PDF is returned
         import StringIO
         from reportlab.pdfgen import canvas
         pdf_string = StringIO.StringIO()
         c = canvas.Canvas(pdf_string)
         c.drawString(20, 20, str('      '))
         c.showPage()
         c.save()
         obj = external_pdf(pdf_string.getvalue())
         obj.render()
         pdf_string.close()
         return (obj.pdf, 'pdf')
Exemplo n.º 9
0
 def create(self, cr, uid, ids, datas, context={}):
     self.pool = pooler.get_pool(cr.dbname)
     objTemplateDoc = self.pool.get('plm.document')
     docRepository = objTemplateDoc._get_filestore(cr)
     componentType = self.pool.get('product.product')
     user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
     msg = "Printed by " + \
         str(user.name) + " : " + str(time.strftime("%d/%m/%Y %H:%M:%S"))
     output = BookCollector(jumpFirst=False,
                            customTest=(False, msg),
                            bottomHeight=10)
     documents = []
     components = componentType.browse(cr, uid, ids, context=context)
     for component in components:
         for idDoc in component.linkeddocuments:
             if idDoc.state in ['released', 'undermodify']:
                 documents.extend(idDoc)
     if len(documents):
         return packDocuments(docRepository, documents, output)
     if context.get("raise_report_warning", True):
         raise UserError(_("No Document found"))
     return False, False