예제 #1
0
    def get_object(self, data):

        dayofWeek = [
            'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
        ]

        data_list = []
        for timetable_obj in pooler.get_pool(
                self.cr.dbname).get('op.timetable').browse(
                    self.cr, self.uid, data['time_table_ids']):

            oldDate = datetime.strptime(timetable_obj.start_datetime,
                                        "%Y-%m-%d %H:%M:%S")
            day = dayofWeek[datetime.weekday(oldDate)]

            timetable_data = {
                'period': timetable_obj.period_id.name,
                'sequence': timetable_obj.period_id.sequence,
                'start_datetime': timetable_obj.start_datetime,
                'day': day,
                'subject': timetable_obj.subject_id.name,
            }
            data_list.append(timetable_data)

        ttdl = sorted(data_list, key=lambda k: k['sequence'])
        final_list = self.sort_tt(ttdl)
        return final_list
예제 #2
0
 def create(self, cr, uid, ids, datas, context=None):
     recursion = True
     if self._report_int__name == 'report.product.product.spare.parts.pdf.one':
         recursion=  False
     self.processedObjs = []
     self.pool = pooler.get_pool(cr.dbname)
     componentType = self.pool.get('product.product')
     bomType = self.pool.get('mrp.bom')
     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(customTest=(True, msg))
     components = componentType.browse(cr, uid, ids, context=context)
     for component in components:
         self.processedObjs = []
         buf = self.getFirstPage(cr, uid, [component.id], context)
         output.addPage((buf,''))
         self.getSparePartsPdfFile(cr, uid, context, component, output, componentType, bomType, recursion)
     if output is not None:
         pdf_string = StringIO.StringIO()
         output.collector.write(pdf_string)
         self.obj = external_pdf(pdf_string.getvalue())
         self.obj.render()
         pdf_string.close()
         return (self.obj.pdf, 'pdf')
     return (False, '')
예제 #3
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"))
예제 #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)
예제 #5
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
예제 #6
0
    def create(self, cr, uid, ids, datas, context=None):
        self.pool = pooler.get_pool(cr.dbname)
        checkoutType = self.pool.get('plm.checkout')
        output = PdfFileWriter()
        children = []
        packed = []
        checkouts = checkoutType.browse(cr, uid, ids)
        for checkout in checkouts:
            document = checkout.documentid
            if document.printout:
                if not document.id in packed:
                    input1 = PdfFileReader(
                        StringIO.StringIO(
                            base64.decodestring(document.printout)))
                    output.addPage(input1.getPage(0), document.state)
                    packed.append(document.id)

        pdf_string = StringIO.StringIO()
        output.write(pdf_string)
        self.obj = external_pdf(pdf_string.getvalue())
        self.obj.render()
        pdf_string.close()
        return (self.obj.pdf, 'pdf')