示例#1
0
            def tr(src, ttype):
                # We try to do the same as the _(), but without the frame
                # inspection, since we aready are wrapping an osv function
                # trans_obj = self.get('ir.translation') cannot work yet :(
                ctx = {}
                if not kwargs:
                    if args and isinstance(args[-1], dict):
                        ctx = args[-1]
                elif isinstance(kwargs, dict):
                    ctx = kwargs.get('context', {})

                uid = 1
                if args and isinstance(args[0], (long, int)):
                    uid = args[0]

                lang = ctx and ctx.get('lang')
                if not (lang or hasattr(src, '__call__')):
                    return src

                # We open a *new* cursor here, one reason is that failed SQL
                # queries (as in IntegrityError) will invalidate the current one.
                cr = False

                if hasattr(src, '__call__'):
                    # callable. We need to find the right parameters to call
                    # the  orm._sql_message(self, cr, uid, ids, context) function,
                    # or we skip..
                    # our signature is f(osv_pool, dbname [,uid, obj, method, args])
                    try:
                        if args and len(args) > 1:
                            obj = self.get(args[1])
                            if len(args) > 3 and isinstance(
                                    args[3], (long, int, list)):
                                ids = args[3]
                            else:
                                ids = []
                        cr = pooler.get_db_only(dbname).cursor()
                        return src(obj, cr, uid, ids, context=(ctx or {}))
                    except Exception:
                        pass
                    finally:
                        if cr: cr.close()

                    return False  # so that the original SQL error will
                    # be returned, it is the best we have.

                try:
                    cr = pooler.get_db_only(dbname).cursor()
                    res = translate(cr,
                                    name=False,
                                    source_type=ttype,
                                    lang=lang,
                                    source=src)
                    if res:
                        return res
                    else:
                        return src
                finally:
                    if cr: cr.close()
            def tr(src, ttype):
                # We try to do the same as the _(), but without the frame
                # inspection, since we aready are wrapping an osv function
                # trans_obj = self.get('ir.translation') cannot work yet :(
                ctx = {}
                if not kwargs:
                    if args and isinstance(args[-1], dict):
                        ctx = args[-1]
                elif isinstance(kwargs, dict):
                    ctx = kwargs.get('context', {})

                uid = 1
                if args and isinstance(args[0], (long, int)):
                    uid = args[0]

                lang = ctx and ctx.get('lang')
                if not (lang or hasattr(src, '__call__')):
                    return src

                # We open a *new* cursor here, one reason is that failed SQL
                # queries (as in IntegrityError) will invalidate the current one.
                cr = False
                
                if hasattr(src, '__call__'):
                    # callable. We need to find the right parameters to call
                    # the  orm._sql_message(self, cr, uid, ids, context) function,
                    # or we skip..
                    # our signature is f(osv_pool, dbname [,uid, obj, method, args])
                    try:
                        if args and len(args) > 1:
                            obj = self.get(args[1])
                            if len(args) > 3 and isinstance(args[3], (long, int, list)):
                                ids = args[3]
                            else:
                                ids = []
                        cr = pooler.get_db_only(dbname).cursor()
                        return src(obj, cr, uid, ids, context=(ctx or {}))
                    except Exception:
                        pass
                    finally:
                        if cr: cr.close()
                   
                    return False # so that the original SQL error will
                                 # be returned, it is the best we have.

                try:
                    cr = pooler.get_db_only(dbname).cursor()
                    res = translate(cr, name=False, source_type=ttype,
                                    lang=lang, source=src)
                    if res:
                        return res
                    else:
                        return src
                finally:
                    if cr: cr.close()
示例#3
0
def login(db, login, password):
    cr = pooler.get_db_only(db).cursor()
    nb = _get_number_modules(cr, testlogin=True)
    patch_failed = [0]
    cr.execute("SELECT relname FROM pg_class WHERE relkind IN ('r','v') AND relname='patch_scripts'")
    if cr.rowcount:
        cr.execute("SELECT count(id) FROM patch_scripts WHERE run = \'f\'")
        patch_failed = cr.fetchone()
    to_update = False
    if not nb:
        to_update = updater.test_do_upgrade(cr)
    cr.close()
    if nb or to_update:
        s = threading.Thread(target=pooler.get_pool, args=(db,),
                kwargs={'threaded': True})
        s.start()
        raise Exception("ServerUpdate: Server is updating modules ...")


    pool = pooler.get_pool(db)
    user_obj = pool.get('res.users')
    user_res = user_obj.login(db, login, password)

    if user_res != 1 and patch_failed[0]:
        raise Exception("PatchFailed: A script during upgrade has failed. Login is forbidden. Please contact your administrator")

    return user_res
示例#4
0
    def db_list(self):
        #return pooler.pool_dic.keys()
        s = netsvc.ExportService.getService('db')
        result = s.exp_list()
        self.db_name_list = []
        for db_name in result:
            db, cr = None, None
            try:
                db = pooler.get_db_only(db_name)
                cr = db.cursor()
                cr.execute(
                    "SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'"
                )
                if not cr.fetchone():
                    continue

                cr.execute(
                    "select id from ir_module_module where name like 'document_sftp' and state='installed' "
                )
                res = cr.fetchone()
                if res and len(res):
                    self.db_name_list.append(db_name)
                cr.commit()
            except Exception, e:
                log(e)
                if cr:
                    cr.rollback()
            finally:
示例#5
0
    def db_list(self):
        """Get the list of available databases, with FTPd support
        """
        s = netsvc.ExportService.getService('db')
        result = s.exp_list(document=True)
        self.db_name_list = []
        for db_name in result:
            db, cr = None, None
            try:
                try:
                    db = pooler.get_db_only(db_name)
                    cr = db.cursor()
                    cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
                    if not cr.fetchone():
                        continue

                    cr.execute("SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to install', 'to upgrade') ")
                    res = cr.fetchone()
                    if res and len(res):
                        self.db_name_list.append(db_name)
                    cr.commit()
                except Exception:
                    self._log.warning('Cannot use db "%s"', db_name)
            finally:
                if cr is not None:
                    cr.close()
        return self.db_name_list
def _post_process(db,
                  uid,
                  passwd,
                  object,
                  method,
                  steps,
                  type='execute',
                  *args):
    security.check(db, uid, passwd)
    pool = pooler.get_pool(db)
    res = False
    if pool.get('game.scenario') and steps:
        cr = pooler.get_db_only(db).cursor()
        for step in steps:
            _execute(cr, uid, object, method, step, type, 'post', *args)
        ids = ','.join(map(lambda x: str(x['id']), steps))
        cr.execute(
            'update game_scenario_step set state=%s where id in (' + ids + ')',
            ('done', ))
        cr.execute(
            'update game_scenario_step set state=%s where id in (select next_step_id from next_step_rel where step_id in ('
            + ids + ')) and state=%s', ('running', 'draft'))
        cr.commit()
        cr.close()
    return res
示例#7
0
 def db_list(self):
     #return pooler.pool_dic.keys()
     s = netsvc.LocalService('db')
     result = s.list(document=True)
     self.db_name_list = []
     for db_name in result:
         db, cr = None, None
         try:
             try:
                 db = pooler.get_db_only(db_name)
                 cr = db.cursor()
                 cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
                 if not cr.fetchone():
                     continue
 
                 cr.execute("select id from ir_module_module where name like 'document%' and state='installed' ")
                 res = cr.fetchone()
                 if res and len(res):
                     self.db_name_list.append(db_name)
                 cr.commit()
             except Exception, e:
                 log(e)
         finally:
             if cr is not None:
                 cr.close()
             #if db is not None:
             #    pooler.close_db(db_name)        
     return self.db_name_list
示例#8
0
    def db_list(self):
        """Get the list of available databases, with FTPd support
        """
        s = netsvc.ExportService.getService("db")
        result = s.exp_list(document=True)
        self.db_name_list = []
        for db_name in result:
            db, cr = None, None
            try:
                try:
                    db = pooler.get_db_only(db_name)
                    cr = db.cursor()
                    cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
                    if not cr.fetchone():
                        continue

                    cr.execute(
                        "SELECT id FROM ir_module_module WHERE name = 'document_ftp' AND state IN ('installed', 'to install', 'to upgrade') "
                    )
                    res = cr.fetchone()
                    if res and len(res):
                        self.db_name_list.append(db_name)
                    cr.commit()
                except Exception:
                    self._log.warning('Cannot use db "%s"', db_name)
            finally:
                if cr is not None:
                    cr.close()
        return self.db_name_list
 def upload_report(self, cr, uid, report_id, file_sxw, file_type, context):
     '''
     Untested function
     '''
     pool = pooler.get_pool(cr.dbname)
     sxwval = StringIO(base64.decodestring(file_sxw))
     if file_type == 'sxw':
         fp = tools.file_open(
             'normalized_oo2rml.xsl',
             subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
         rml_content = str(sxw2rml(sxwval, xsl=fp.read()))
     if file_type == 'odt':
         fp = tools.file_open(
             'normalized_odt2rml.xsl',
             subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
         rml_content = str(sxw2rml(sxwval, xsl=fp.read()))
     if file_type == 'html':
         rml_content = base64.decodestring(file_sxw)
     report = pool.get('ir.actions.report.xml').write(
         cr, uid, [report_id], {
             'report_sxw_content': base64.decodestring(file_sxw),
             'report_rml_content': rml_content,
         })
     cr.commit()
     db = pooler.get_db_only(cr.dbname)
     interface.register_all(db)
     return True
示例#10
0
    def check_security(self, dbname, username, key):
        db, cr, res = None, None, False
        try:
            db = pooler.get_db_only(dbname)
            cr = db.cursor()
            cr.execute(
                "SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'"
            )
            if not cr.fetchone():
                return False
            if allowed_auths == 'publickey':
                cr.execute("select distinct users.login,users.password,users.id from ir_module_module module,res_users users "+ \
                           "where module.name like 'document_sftp' and module.state='installed' "+ \
                           " and users.active=True and users.login='******'"%(username))
                results = cr.fetchone()
                if results:
                    pool = pooler.get_pool(cr.dbname)
                    user = pool.get('res.users').browse(
                        cr, results[2], results[2])
                    key_obj = pool.get('sftp.public.keys')
                    for k in user.ssh_key_ids:
                        user_pubkey = k.ssh_key
                        if user_pubkey:
                            filekey = user_pubkey.split(' ')
                            if len(filekey) > 1:
                                user_pubkey = filekey[1]
                            else:
                                continue
                            custKey = paramiko.RSAKey(
                                data=base64.decodestring(user_pubkey))
                            if custKey == key:
                                res = results[2]
                                break
                            else:
                                continue

            elif allowed_auths == 'password':
                cr.execute("select distinct users.login,users.password,users.id from ir_module_module module,res_users users "+ \
                           "where module.name like 'document%' and module.state='installed' "+ \
                           " and users.active=True and users.login='******' and users.password='******'"%(username,key))
                results = cr.fetchone()
                if results and results[1] == key:
                    res = results[2]
            else:
                cr.execute("select distinct users.login,users.password,users.id from ir_module_module module, res_users users "+ \
                           "where module.name like 'document%' and module.state='installed' "+ \
                           " and users.active=True")
                if results:
                    res = results[2]

        finally:
            if cr is not None:
                cr.close()
        return res
示例#11
0
	def db_list(self):
		s = netsvc.LocalService('db')
		result = s.list()
		self.db_name_list=[]
		for db_name in result:
			db = pooler.get_db_only(db_name)
			cr = db.cursor()
			cr.execute("select id from ir_module_module where name = 'document' and state='installed' ")
			res=cr.fetchone()
			if res and len(res):
				self.db_name_list.append(db_name)
			cr.close()
		return self.db_name_list
def _post_process(db,uid,passwd,object,method,steps,type='execute',*args):
    security.check(db, uid, passwd)
    pool = pooler.get_pool(db)
    res=False
    if  pool.get('game.scenario') and steps:
        cr = pooler.get_db_only(db).cursor()
        for step in steps:
           _execute(cr, uid, object, method,step,type, 'post',*args)
        ids = ','.join(map(lambda x: str(x['id']), steps))
        cr.execute('update game_scenario_step set state=%s where id in ('+ids+')', ('done',))
        cr.execute('update game_scenario_step set state=%s where id in (select next_step_id from next_step_rel where step_id in ('+ids+')) and state=%s', ('running','draft'))
        cr.commit()
        cr.close()
    return res
示例#13
0
    def check_security(self, dbname, username, key):        
        db, cr, res = None, None, False
        try:            
            db = pooler.get_db_only(dbname)
            cr = db.cursor()
            cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
            if not cr.fetchone():
                return False
            if allowed_auths == 'publickey':
                cr.execute("select distinct users.login,users.password,users.id from ir_module_module module,res_users users "+ \
                           "where module.name like 'document_sftp' and module.state='installed' "+ \
                           " and users.active=True and users.login='******'"%(username))
                results = cr.fetchone()
                if results:
                    pool = pooler.get_pool(cr.dbname)
                    user = pool.get('res.users').browse(cr,results[2],results[2])
                    key_obj = pool.get('sftp.public.keys')
                    for k in user.ssh_key_ids:
                        user_pubkey = k.ssh_key
                        if user_pubkey: 
                            filekey = user_pubkey.split(' ')
                            if len(filekey)> 1:
                                user_pubkey = filekey[1]
                            else:
                                continue
                            custKey = paramiko.RSAKey(data=base64.decodestring(user_pubkey))
                            if custKey == key:
                                res = results[2]
                                break
                            else:
                                continue

            elif allowed_auths == 'password':
                cr.execute("select distinct users.login,users.password,users.id from ir_module_module module,res_users users "+ \
                           "where module.name like 'document%' and module.state='installed' "+ \
                           " and users.active=True and users.login='******' and users.password='******'"%(username,key))
                results = cr.fetchone()                 
                if results and results[1] == key:                                       
                    res = results[2]
            else:                    
                cr.execute("select distinct users.login,users.password,users.id from ir_module_module module, res_users users "+ \
                           "where module.name like 'document%' and module.state='installed' "+ \
                           " and users.active=True")
                if results:                    
                    res = results[2]                         
            
        finally:
            if cr is not None:
                cr.close()                        
        return res    
示例#14
0
 def db_list(self):
     s = netsvc.LocalService('db')
     result = s.list()
     self.db_name_list = []
     for db_name in result:
         db = pooler.get_db_only(db_name)
         cr = db.cursor()
         cr.execute(
             "select id from ir_module_module where name = 'document' and state='installed' "
         )
         res = cr.fetchone()
         if res and len(res):
             self.db_name_list.append(db_name)
         cr.close()
     return self.db_name_list
def _pre_process(db,uid,passwd,object,method,type='execute',*args):
    security.check(db, uid, passwd)
    pool = pooler.get_pool(db)
    steps=False
    if pool.get('game.scenario'):
        cr = pooler.get_db_only(db).cursor()
        cr.execute('select s.* from game_scenario_step s left join game_scenario g on (s.scenario_id=g.id) where g.state=%s and s.state=%s', ('running', 'running'))
        steps_orig = cr.dictfetchall()
        steps=[]
        for step in steps_orig:
            res = _execute(cr, uid, object, method, step, type,'pre',*args)
            if res:
                steps.append(step)
        cr.close()
    return steps
示例#16
0
文件: dav_fs.py 项目: lbiemans/docker
 def db_list(self):
     s = netsvc.ExportService.getService('db')
     result = s.exp_list()
     self.db_name_list=[]
     for db_name in result:
         cr = None
         try:
             db = pooler.get_db_only(db_name)
             cr = db.cursor()
             cr.execute("SELECT id FROM ir_module_module WHERE name = 'document' AND state='installed' ")
             res=cr.fetchone()
             if res and len(res):
                 self.db_name_list.append(db_name)
         except Exception, e:
             self.parent.log_error("Exception in db list: %s" % e)
         finally:
示例#17
0
def _pre_process(db, uid, passwd, object, method, type='execute', *args):
    security.check(db, uid, passwd)
    pool = pooler.get_pool(db)
    steps = False
    if pool.get('game.scenario'):
        cr = pooler.get_db_only(db).cursor()
        cr.execute(
            'select s.* from game_scenario_step s left join game_scenario g on (s.scenario_id=g.id) where g.state=%s and s.state=%s',
            ('running', 'running'))
        steps_orig = cr.dictfetchall()
        steps = []
        for step in steps_orig:
            res = _execute(cr, uid, object, method, step, type, 'pre', *args)
            if res:
                steps.append(step)
        cr.close()
    return steps
示例#18
0
    def _save(self, cr, uid, data, context):
        pool = pooler.get_pool(cr.dbname)
        file_sxw = base64.decodestring(data['form']['datas'])
        sxwval = StringIO(file_sxw)
        debug(sxwval)
        file_type = 'sxw'
        if file_type == 'sxw':
            fp = open('D:/workspace/eMobility/wizard/tiny_sxw2rml/normalized_oo2rml.xsl','r')
        if file_type == 'odt':
            fp = tools.file_open('normalized_odt2rml.xsl',
                    subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
        xsl=fp.read()
        fp.close()
        report_content=str(sxw2rml(sxwval, xsl))
        fpp = open('D:/workspace/eMobility/report/test_report.rml','a+')
        fpp.write(report_content)
        debug(report_content)
        fpp.close()
        report_id=112
        report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
            'report_sxw_content': file_sxw,
            'report_rml_content': report_content,
            'report_type':'pdf'
        })
        cr.commit()
        db = pooler.get_db_only(cr.dbname)
        interface.register_all(db)
                                                      
#            'report_rml_content': report_content,})
#        report = pooler.get('ir.actions.report.xml').create(cr, uid, {
#            'auto':False,
#            'model':'cmc.assessment',
#            'type':'ir.actions.report.xml',
#            'report_name':'test.report',
#            'report_sxw_content': file_sxw,
#            'report_rml_content': report_content,
#            'report_rml':'eMobility/report/test_report.rml'
#        })
#        
#        cr.commit()
#        db = pooler.get_db_only(cr.dbname)
#        interface.register_all(db)
        data['form']['name']='CHECK HECKEC'
        debug(data)
        return data['form']
 def upload_report(self, cr, uid, report_id, file_sxw,file_type, context):
     '''
     Untested function
     '''
     pool = pooler.get_pool(cr.dbname)
     sxwval = StringIO(base64.decodestring(file_sxw))
     if file_type=='sxw':
         fp = tools.file_open('normalized_oo2rml.xsl',
                 subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
     if file_type=='odt':
         fp = tools.file_open('normalized_odt2rml.xsl',
                 subdir='addons/base_report_designer/wizard/tiny_sxw2rml')
     report = pool.get('ir.actions.report.xml').write(cr, uid, [report_id], {
         'report_sxw_content': base64.decodestring(file_sxw),
         'report_rml_content': str(sxw2rml(sxwval, xsl=fp.read())),
     })
     cr.commit()
     db = pooler.get_db_only(cr.dbname)
     interface.register_all(db)
     return True
示例#20
0
 def send_all_sms(self, cr, uid, ids=None, context=None):
     if ids is None:
         ids = []
     if context is None:
         context = {}
     #8888888888888 SENDS SMS IN OUTBOX 8888888888888888888#
     #get ids of smss in outbox
     filters = [('folder', '=', 'outbox'), ('state', '!=', 'sending')]
     if 'filters' in context.keys():
         for each_filter in context['filters']:
             filters.append(each_filter)
     limit = context.get('limit', None)
     order = "date_sms desc"
     ids = self.search(cr,
                       uid,
                       filters,
                       limit=limit,
                       order=order,
                       context=context)
     LOGGER.notifyChannel('Power SMS', netsvc.LOG_INFO,
                          'Sending All SMS (PID: %s)' % os.getpid())
     # To prevent resend the same sms in several send_all_sms() calls
     # We put this in a new cursor/transaction to avoid concurrent
     # transaction isolation problems
     db = pooler.get_db_only(cr.dbname)
     cr_tmp = db.cursor()
     try:
         self.write(cr_tmp, uid, ids, {'state': 'sending'}, context)
         cr_tmp.commit()
     except:
         cr_tmp.rollback()
     finally:
         cr_tmp.close()
     #send sms one by one
     if ids:
         self.async_send_this_sms(cr, uid, ids, context)
     return True
    def db_list(self):
        #return pooler.pool_dic.keys()
        s = netsvc.ExportService.getService('db')
        result = s.exp_list()
        self.db_name_list = []
        for db_name in result:
            db, cr = None, None
            try:
                db = pooler.get_db_only(db_name)
                cr = db.cursor()
                cr.execute("SELECT 1 FROM pg_class WHERE relkind = 'r' AND relname = 'ir_module_module'")
                if not cr.fetchone():
                    continue

                cr.execute("select id from ir_module_module where name like 'document_sftp' and state='installed' ")
                res = cr.fetchone()
                if res and len(res):
                    self.db_name_list.append(db_name)
                cr.commit()
            except Exception,e:
                log(e)
                if cr:
                    cr.rollback()
            finally:
示例#22
0
 def _get_db(self):
     # find current DB based on thread/worker db name (see netsvc)
     db_name = getattr(threading.currentThread(), 'dbname', None)
     if db_name:
         return pooler.get_db_only(db_name)
示例#23
0
def number_update_modules(db):
    cr = pooler.get_db_only(db).cursor()
    n = _get_number_modules(cr)
    cr.close()
    return n
    def send_empowering_report(self, cursor, uid, reports, context=None):
        if context is None:
            context = {}

        logger = logging.getLogger('openerp.{0}.send_empowering_report'.format(
            __name__
        ))

        cl_obj = self.pool.get('empowering.customize.profile.channel.log')
        pe_send_obj = self.pool.get('poweremail.send.wizard')
        imd_obj = self.pool.get('ir.model.data')
        attach_obj = self.pool.get('ir.attachment')
        tmpl_obj = self.pool.get('poweremail.templates')

        for report in reports:
            polissa = self.browse(cursor, uid, report['contract_id'],
                context=context)
            if not polissa.empowering_profile_id:
                continue

            vals = {
                'name': report['report_name'],
                'datas': report['pdf'],
                'datas_fname': report['report_name'],
                'res_model': 'giscedata.polissa',
                'res_id': polissa.id
            }
            try:
                db = pooler.get_db_only(cursor.dbname)
                cr_new = None
                cr_new = db.cursor()
                attachment_id = attach_obj.create(cr_new, uid, vals, context)
                cr_new.commit()
            except:
                if not cr_new:
                    cr_new.rollback()
            finally:
                cr_new.close()
            now = datetime.now()
            for channel in polissa.empowering_profile_id.channels_ids:
                measure = channel.interval_id.measure
                number = channel.interval_id.number
                if measure and measure != 'on_demand':
                    cl = cl_obj.search_reader(cursor, uid, [
                        ('channel_id.id', '=', channel.id),
                        ('contract_id.id', '=', polissa.id)
                    ], ['last_generated'], order='last_generated desc', limit=1)
                    if cl:
                        last_generated = datetime.strptime(
                            cl[0]['last_generated'], '%Y-%m-%d %H:%M:%S'
                        )
                    else:
                        last_generated = datetime(1, 1, 1)
                    last_generated += relativedelta(**{measure: number})
                    if last_generated > now:
                        continue
                period = context.get('period')
                if not period:
                    period = now.strftime('%Y%m')
                body_common = context.get('body', '')
                body_personal = report.get('body', '')
                channel_code = channel.channel_id.code

                template_id = imd_obj.get_object_reference(
                    cursor, uid, 'empowering_customize', 'env_empowering_report'
                )[1]

                tmpl = tmpl_obj.browse(cursor, uid, template_id)

                ctx = context.copy()
                ctx.update({
                    'period': period,
                    'body_common': body_common,
                    'body_personal': body_personal,
                    'empowering_channel': channel_code,
                    'src_rec_ids': [polissa.id],
                    'src_model': 'giscedata.polissa',
                    'template_id': template_id,
                    'active_id': polissa.id
                })
                logger.info(
                    'Sending email to contract {polissa.name} channel: '
                    '{channel.code} ane period: {period}'.format(
                        polissa=polissa, channel=channel.channel_id,
                        period=period
                    )
                )
                send_id = pe_send_obj.create(cursor, uid, {}, context=ctx)
                pe_send_obj.write(cursor, uid, [send_id],
                    {'from': tmpl.enforce_from_account.id,
                     'attachment_ids': [(6, 0, [attachment_id])]}, context=ctx)
                sender = pe_send_obj.browse(cursor, uid, send_id, context=ctx)
                sender.send_mail(context=ctx)
示例#25
0
 def _get_db(self):
     # find current DB based on thread/worker db name (see netsvc)
     db_name = getattr(threading.currentThread(), 'dbname', None)
     if db_name:
         return pooler.get_db_only(db_name)