Ejemplo n.º 1
0
 def master_data_export(self):
     for m in self.browse(ids):
         path = get_module_resource(m.name, '', '__openerp__.py')
         mod_meta=eval(file(path).read())
         files=mod_meta['update_xml']
         for f in files:
             p,fn=os.path.split(f)
             #fn.split('.')
             model = fn[:-4]#.split('.')
             dest_fn=get_module_resource(m.name,p, fn)
             export_data(self.env, cr, uid, model, dest_fn, db_only=True, module=m.name)
             #print p,fn
         
     return {'ok':'done'}
Ejemplo n.º 2
0
    def test_ods_success(self):
        ods_file_path = get_module_resource('base_import', 'tests', 'test.ods')
        file_content = open(ods_file_path, 'rb').read()
        import_wizard = self.env['base_import.import'].create({
            'res_model': 'base_import.tests.models.preview',
            'file': file_content,
            'file_type': 'application/vnd.oasis.opendocument.spreadsheet'
        })

        result = import_wizard.parse_preview({
            'headers': True,
        })
        self.assertIsNone(result.get('error'))
        self.assertEqual(result['matches'], {0: ['name'], 1: ['somevalue'], 2: None})
        self.assertEqual(result['headers'], ['name', 'Some Value', 'Counter'])
        self.assertItemsEqual(result['fields'], [
            ID_FIELD,
            {'id': 'name', 'name': 'name', 'string': 'Name', 'required': False, 'fields': [], 'type': 'char'},
            {'id': 'somevalue', 'name': 'somevalue', 'string': 'Some Value', 'required': True, 'fields': [], 'type': 'integer'},
            {'id': 'othervalue', 'name': 'othervalue', 'string': 'Other Variable', 'required': False, 'fields': [], 'type': 'integer'},
        ])
        self.assertEqual(result['preview'], [
            ['foo', '1', '2'],
            ['bar', '3', '4'],
            ['aux', '5', '6'],
        ])
        # Ensure we only have the response fields we expect
        self.assertItemsEqual(result.keys(), ['matches', 'headers', 'fields', 'preview', 'headers_type', 'options', 'advanced_mode', 'debug'])
Ejemplo n.º 3
0
    def test_crm_lead_message(self):
        # Give the access rights of Salesman to communicate with customer
        # Customer interested in our product, so he sends request by email to get more details.
        # Mail script will fetch his request from mail server. Then I process that mail after read EML file.
        request_file = open(get_module_resource('crm', 'tests', 'customer_request.eml'), 'rb')
        request_message = request_file.read()
        self.env['mail.thread'].sudo(self.crm_salesman).message_process('crm.lead', request_message)

        # After getting the mail, I check details of new lead of that customer
        lead = self.env['crm.lead'].sudo(self.crm_salesman).search([('email_from', '=', 'Mr. John Right <*****@*****.**>')], limit=1)
        self.assertTrue(lead.ids, 'Fail to create merge opportunity wizard')
        self.assertFalse(lead.partner_id, 'Customer should be a new one')
        self.assertEqual(lead.name, 'Fournir votre devis avec le meilleur prix.', 'Subject does not match')

        # I reply his request with welcome message.
        # TODO revert mail.mail to mail.compose.message (conversion to customer should be automatic).
        lead = self.env['crm.lead'].search([('email_from', '=', 'Mr. John Right <*****@*****.**>')], limit=1)
        mail = self.env['mail.compose.message'].with_context(active_model='crm.lead', active_id=lead.id).create({
            'body': "Merci de votre intérêt pour notre produit, nous vous contacterons bientôt. Bien à vous",
            'email_from': '*****@*****.**'
        })
        try:
            mail.send_mail()
        except:
            pass

        # Now, I convert him into customer and put him into regular customer list
        lead = self.env['crm.lead'].search([('email_from', '=', 'Mr. John Right <*****@*****.**>')], limit=1)
        lead.handle_partner_assignation()
Ejemplo n.º 4
0
    def test_subscribe_issues(self):
        # In Order to test process of Issue in Odoo, Customer send the issue by email.
        request_file = open(module.get_module_resource('project_issue', 'tests', 'issue.eml'), 'rb')
        request_message = request_file.read()
        self.env["mail.thread"].message_process('project.issue', request_message)

        # After getting the mail, Check details of new issue of that customer.
        issue = self.ProjectIssue.search([('email_from', '=', 'Robert Adersen <*****@*****.**>')], limit=1)
        self.assertEquals(len(issue), 1, "Issue is not created after getting request")
        self.assertFalse(issue.partner_id, "Customer should be a new")
        self.assertEquals(issue.name, "Error in the account module", "Subject does not match")
Ejemplo n.º 5
0
 def _get(self): #,field_name,arg):
     res={}
     for t in self: #.browse(ids):
         #path = get_module_resource('hr', 'static/src/img', 'default_image.png')
         if t.module and t.path and t.fn:
             path = get_module_resource(t.module, t.path, t.fn)
             if os.path.isfile(path):
                 source=file(path).read()
             else:
                 source=''
             res[t.id] = {'source':source,'source_fn':path}                
         else:
             res[t.id] = {'source':'na','source_fn':'na'}                
     return res
Ejemplo n.º 6
0
 def _get(self):#,field_name,arg):
     res={}
     for f in self:#.browse(ids):
         #path = get_module_resource('hr', 'static/src/img', 'default_image.png')
         t=f.template_id
         path = get_module_resource(t.module, t.path, t.fn)
         if t.model:#'active_id' in context:
             print 'file _get: f.res_id', [t.model, f.res_id]
             obj=self.env[t.model].browse(f.res_id )
             if t.type in ['template','bash']:
                 ctx={#'context':context,
                      'o':obj,
                      't':t,
                      'to_ascii':to_ascii,
                      'value':value,
                      'to_ascii':to_ascii,
                     #'html_indent':html_indent,                                  
                      }
                 #print ctx
                 try:
                     ret=render_mako_file(path,ctx)
                 except:
                     logging.exception('Got exception on main handler')
                     ret='%s,%s,%s,%s'%(t,obj,ctx,path)
             elif t.type in ['python']:
                 ret=file(path).read()
             ctx2={'o':obj }
             try:
                 out_file=render_mako_str(str(t.out_fn),ctx2)
             except:
                 out_file="%s,%s"%(t,ctx2)
             file_ctx={'f':f,'o':obj}
             res[f.id] = {'content_generated':ret,'source_fn':path,
                          'file_generated':out_file,
                          'who':f.user_id.who,
                          'user':render_mako_str(f.template_id.target_user, file_ctx),
                          'group':render_mako_str(f.template_id.target_group, file_ctx),}
         else:
             res[f.id] = {'content_generated':'', #file(path).read(),
                          'source_fn':'', #path,
                          'file_generated':'',
                          'who':f.user_id.who,
                          'user':'', #render_mako_str(f.template_id.target_user, file_ctx),
                          'group':'', #render_mako_str(f.template_id.target_group, file_ctx)}
                          }
         #fp = misc.file_open(pathname)
     return res
Ejemplo n.º 7
0
    def test_ubl_invoice_import(self):
        xml_file_path = get_module_resource('l10n_be_edi', 'test_xml_file', 'efff_test.xml')
        xml_file = open(xml_file_path, 'rb').read()
        invoice_id = self.env['account.invoice'].with_context(default_type='in_invoice').create({})

        attachment_id = self.env['ir.attachment'].create({
            'name': 'efff_test.xml',
            'datas_fname': 'efff_test.xml',
            'datas': base64.encodestring(xml_file),
            'res_id': invoice_id.id,
            'res_model': 'account.invoice',
        })

        invoice_id.message_post(attachment_ids=[attachment_id.id])

        self.assertEqual(invoice_id.amount_total, 666.50)
        self.assertEqual(invoice_id.amount_tax, 115.67)
        self.assertEqual(invoice_id.partner_id, self.partner_id)
Ejemplo n.º 8
0
    def test_00_recruitment_process(self):
        """ Test recruitment process """

        # Create a new HR Recruitment Officer
        self.res_users_hr_recruitment_officer = self.env['res.users'].create({
            'company_id': self.env.ref('base.main_company').id,
            'name': 'HR Recruitment Officer',
            'login': "******",
            'email': "*****@*****.**",
            'groups_id': [(6, 0, [self.env.ref('hr_recruitment.group_hr_recruitment_user').id])]
        })

        # An applicant is interested in the job position. So he sends a resume by email.
        # In Order to test process of Recruitment so giving HR officer's rights
        with open(get_module_resource('hr_recruitment', 'tests', 'resume.eml'), 'rb') as request_file:
            request_message = request_file.read()
        self.env['mail.thread'].sudo(self.res_users_hr_recruitment_officer.id).message_process(
            'hr.applicant', request_message, custom_values={"job_id": self.env.ref('hr.job_developer').id})

        # After getting the mail, I check the details of the new applicant.
        applicant = self.env['hr.applicant'].search([('email_from', '=', 'Mr. Richard Anderson <*****@*****.**>')], limit=1)
        self.assertTrue(applicant, "Applicant is not created after getting the mail")
        resume_ids = self.env['ir.attachment'].search([
            ('datas_fname', '=', 'resume.pdf'),
            ('res_model', '=', self.env['hr.applicant']._name),
            ('res_id', '=', applicant.id)])
        self.assertEquals(applicant.name, 'Application for the post of Jr.application Programmer.', 'Applicant name does not match.')
        self.assertEquals(applicant.stage_id, self.env.ref('hr_recruitment.stage_job1'),
            "Stage should be 'Initial qualification' and is '%s'." % (applicant.stage_id.name))
        self.assertTrue(resume_ids, 'Resume is not attached.')
        # I assign the Job position to the applicant
        applicant.write({'job_id': self.env.ref('hr.job_developer').id})
        # I schedule meeting with applicant for interview.
        applicant_meeting = applicant.action_makeMeeting()
        self.assertEquals(applicant_meeting['context']['default_name'], 'Application for the post of Jr.application Programmer.',
            'Applicant name does not match.')
Ejemplo n.º 9
0
 def load_odoopb_proto(self):        
     for settings in self:
         fn=get_module_resource('galtys_skynet','models/protodir','odoopb.proto')
         settings.odoopb_proto = file(fn).read()
Ejemplo n.º 10
0
Archivo: hr.py Proyecto: brain-tec/odoo
 def _default_image(self):
     image_path = get_module_resource('hr', 'static/src/img', 'default_image.png')
     return tools.image_process(base64.b64encode(open(image_path, 'rb').read()), size=tools.IMAGE_BIG_SIZE)
Ejemplo n.º 11
0
 def _default_image(self):
     image_path = get_module_resource('website_branch_map', 'static/src/img', 'spotlight-poi2_hdpi.png')
     return tools.image_resize_image_big(base64.b64encode(open(image_path, 'rb').read()))
Ejemplo n.º 12
0
 def _default_image(self):
     image_path = get_module_resource('hr',
                                      'static/src/img',
                                      'default_image.png')
     return tools.image_resize_image_big(
         base64.b64encode(open(image_path, 'rb').read()))
Ejemplo n.º 13
0
 def _default_image(self):
     image_path = get_module_resource('hr', 'static/src/img',
                                      'default_image.png')
     return tools.image_process(base64.b64encode(
         open(image_path, 'rb').read()),
                                size=tools.IMAGE_BIG_SIZE)
Ejemplo n.º 14
0
 def _default_image(self):
     image_path = get_module_resource('lunch', 'static/img', 'lunch.png')
     return base64.b64encode(open(image_path, 'rb').read())
Ejemplo n.º 15
0
 def getFile(self, filename):
     path = get_module_resource('l10n_it_fatturapa_out', 'tests', 'data',
                                filename)
     return self.getFilePath(path)
Ejemplo n.º 16
0
    def test_csv_file_import(self):
        # Get OFX file content
        csv_file_path = get_module_resource(
            'account_bank_statement_import_csv', 'test_csv_file',
            'test_csv.csv')
        csv_file = open(csv_file_path, 'rb').read()

        # Create a bank account and journal corresponding to the CSV file (same currency and account number)
        bank_journal = self.env['account.journal'].create({
            'name':
            'Bank 123456',
            'code':
            'BNK67',
            'type':
            'bank',
            'bank_acc_number':
            '123456'
        })
        bank_journal_id = bank_journal.id
        if bank_journal.company_id.currency_id != self.env.ref("base.USD"):
            bank_journal.write({'currency_id': self.env.ref("base.USD").id})

        # Use an import wizard to process the file
        import_wizard = self.env['base_import.import'].create({
            'res_model':
            'account.bank.statement.line',
            'file':
            csv_file,
            'file_name':
            'test_csv.csv',
            'file_type':
            'text/csv'
        })

        options = {
            'date_format': '%m %d %y',
            'keep_matches': False,
            'encoding': 'utf-8',
            'fields': [],
            'quoting': '"',
            'bank_stmt_import': True,
            'headers': True,
            'separator': ';',
            'float_thousand_separator': ',',
            'float_decimal_separator': '.',
            'advanced': False
        }
        fields = ['date', False, 'name', 'amount', 'balance']
        import_wizard.with_context(journal_id=bank_journal_id).do(fields, [],
                                                                  options,
                                                                  dryrun=False)

        # Check the imported bank statement
        bank_st_record = self.env['account.bank.statement'].search([
            ('reference', '=', 'test_csv.csv')
        ])[0]
        self.assertEqual(bank_st_record.balance_start, 21699.55)
        self.assertEqual(bank_st_record.balance_end_real, 23462.55)

        # Check an imported bank statement line
        line = bank_st_record.line_ids.filtered(
            lambda r: r.name == 'ACH CREDIT"CHECKFLUID INC -013015')
        self.assertEqual(str(line.date), '2015-02-03')
        self.assertEqual(line.amount, 2500.00)
Ejemplo n.º 17
0
    def input_handle(message, session):
        _logger.info(message)
        from .. import client
        entry = client.wxenv(request.env)
        client = entry
        serviceid = message.target
        openid = message.source
        mtype = message.type
        _logger.info('>>> wx msg: %s' % message.__dict__)
        if message.message_id == entry.OPENID_LAST.get(openid):
            _logger.info('>>> 重复的微信消息')
            return ''
        entry.OPENID_LAST[openid] = message.message_id
        origin_content = ''
        attachment_ids = []
        if mtype == 'image':
            pic_url = message.img
            media_id = message.__dict__.get('MediaId', '')
            _logger.info(pic_url)
            _data = get_img_data(pic_url)
            _filename = datetime.datetime.now().strftime("%m%d%H%M%S") + os.path.basename(pic_url)
            attachment = request.env['ir.attachment'].sudo().create({
                'name': '__wx_image|%s' % media_id,
                'datas': base64.b64encode(_data),
                'datas_fname': _filename,
                'res_model': 'mail.channel',
                'res_id': int(0)
            })
            attachment_ids.append(attachment.id)
        elif mtype in ['voice']:
            media_id = message.media_id
            media_format = message.format
            r = client.wxclient.download_media(media_id)
            _filename = '%s.%s' % (media_id, media_format)
            # _filename = '%s.%s' % (media_id, 'mp3')
            _data = r.content
            attachment = request.env['ir.attachment'].sudo().create({
                'name': '__wx_voice|%s' % message.media_id,
                'datas': base64.b64encode(_data),
                'datas_fname': _filename,
                'res_model': 'mail.channel',
                'res_id': int(0)
            })
            wx_file_path = get_module_resource('wx_tools', 'static/wx')
            wx_file = os.path.join(wx_file_path, _filename)
            with open(wx_file, 'wb') as str2datas:
                str2datas.write(_data)
            attachment_ids.append(attachment.id)
            origin_content = message.Recognition
            try:  # 启用新线程进行音频处理,加快返回速度
                _thread.start_new_thread(audio_conversion.armtomp3, (wx_file,))
            except Exception as e:
                print("Error: 无法启动线程%s" % e)
        elif mtype in ['video']:
            media_id = message.media_id
            media_format = 'mp4'
            r = client.wxclient.download_media(media_id)
            _filename = '%s.%s' % (media_id, media_format)
            _data = r.content
            attachment = request.env['ir.attachment'].sudo().create({
                'name': '__wx_video|%s' % message.media_id,
                'datas': base64.b64encode(_data),
                'datas_fname': _filename,
                'res_model': 'mail.channel',
                'res_id': int(0)
            })
            attachment_ids.append(attachment.id)

        elif mtype == 'location':
            origin_content = '对方发送位置: %s 纬度为:%s 经度为:%s' % (message.label, message.location[0], message.location[1])
        elif mtype == 'text':
            origin_content = message.content
        if not origin_content:
            origin_content = ''

        content = origin_content.lower()
        wxuserinfo = request.env()['wx.autoreply'].sudo().search([])
        for rc in wxuserinfo:
            _key = rc.key.lower()
            if rc.type == 1:
                if content == _key:
                    ret_msg = rc.action.get_wx_reply()
                    return ret_msg
            elif rc.type == 2:
                if _key in content:
                    ret_msg = rc.action.get_wx_reply()
                    return ret_msg
            elif rc.type == 3:
                try:
                    flag = re.compile(_key).match(content)
                except:
                    flag = False
                if flag:
                    ret_msg = rc.action.get_wx_reply()
                    return ret_msg

        partner = request.env['res.partner'].sudo().search([('wx_user_id.openid', '=', openid)])
        partner_user_id = None  # 导购
        if partner.exists():  # 查询微信关联的客户
            if partner[0].user_id:  # 存在导购
                partner_user_id = partner[0].user_id  # 联系当前导购

        # 客服对话 uuid:对话UUID
        # uuid, record_uuid = entry.get_uuid_from_openid(openid)
        ret_msg = ''
        cr, uid, context, db = request.cr, request.uid or odoo.SUPERUSER_ID, request.context, request.db
        uuid = ''  # 获取上次连接会话
        active_id = ''  # 会话ID用户于连接到会话
        reminder_type = "在线客服咨询"
        wxuserinfo = request.env['wx.user'].sudo().search([('openid', '=', openid)])
        if not wxuserinfo.exists():
            info = client.wxclient.get_user_info(openid)  # 获取用户信息
            info['group_id'] = ''
            wx_user = request.env['wx.user'].sudo().create(info)
        else:
            wx_user = wxuserinfo[0]
        wxuseruuid = request.env['wx.user'].sudo().search([('openid', '=', openid)])
        if wxuseruuid:
            channel = request.env['mail.channel'].sudo().search([('uuid', '=', wxuseruuid.last_uuid)])
            if channel.exists():
                uuid = wxuseruuid.last_uuid   # 根据微信用户找出,上次会话的
                active_id = channel.id
        uuid_type = 'USER'

        if partner_user_id and not partner_user_id.vacation_status:  # 上班
            if partner_user_id and uuid:  # 需要联系客服要 and  存在上次会话
                _logger.info('需要联系客服要 存在上次会话')
                # 查询上次会话是否是用户类型
                uuid_type = 'USER'
                uuid_session = request.env['wx.user.uuid'].sudo().search(
                    [('uuid', '=', uuid), ('uuid_type', '=', uuid_type), ('uuid_user_id', '=', partner_user_id.id)],
                    limit=1)
                if uuid_session.exists():  # 是导购 UUID是用户类型
                    _now = fields.datetime.now()
                    if _now - uuid_session.last_uuid_time >= datetime.timedelta(seconds=30 * 60):
                        entry.send_text(openid, "正在联系您的专属客户经理%s,我们将竭诚为您服务,欢迎咨询! " % (partner_user_id.name))
                else:  # 如果不满足条件重新选择发起会话
                    uuid = None
            elif not partner_user_id and uuid:  # 如果是联系客服 如果有UUID
                uuid_type = 'service'
                uuid_session = request.env['wx.user.uuid'].sudo().search(
                    [('uuid', '=', uuid), ('uuid_type', '=', uuid_type)],
                    limit=1)  # 如果会话是服务类型
                if not uuid_session.exists():  # 会话不是服务类型
                    uuid_session = request.env['wx.user.uuid'].sudo().search(
                        [('wx_user_id', '=', wx_user.id), ('uuid_type', '=', uuid_type)],
                        limit=1)  # 选择一个服务类型的会话
                    if uuid_session.exists():
                        uuid = uuid_session.uuid
                    else:
                        uuid = None
            if partner_user_id and not uuid:
                _logger.info('需要联系导购,没有会话')
                entry.send_text(openid, "正在联系您的专属客户经理%s,我们将竭诚为您服务,欢迎咨询! " % (partner_user_id.name))
        else:  # 休假 或者联系客服
            _logger.info('联系客户。')
            partner_user_id = None  #
            if uuid:
                uuid_type = 'service'
                uuid_session = request.env['wx.user.uuid'].sudo().search([('uuid', '=', uuid),
                                                                          ('uuid_type', '=', uuid_type)],
                                                                         limit=1)  # 如果会话是服务类型
                if not uuid_session.exists():  # 会话不是服务类型
                    uuid_session = request.env['wx.user.uuid'].sudo().search(
                        [('wx_user_id', '=', wx_user.id), ('uuid_type', '=', uuid_type)], limit=1)  # 选择一个服务类型的会话
                    if uuid_session.exists():
                        uuid = uuid_session.uuid
                    else:
                        uuid = None
                else:
                    partner_user_id = uuid_session.uuid_user_id

        if not uuid:  # 没有会话创建会话
            anonymous_name = wx_user.nickname
            if not partner_user_id:  # 联系在线客户   当在线客服不在线的时候,选择其它用户
                channel = request.env.ref('wx_tools.channel_wx')
                channel_id = channel.id
                # 创建一个channel
                session_info, ret_msg = request.env["im_livechat.channel"].create_mail_channel(channel_id,
                                                                                               anonymous_name,
                                                                                               content)
                if session_info:
                    active_id = session_info["id"]
                else:  # 如果没有选择到在线用户从客服列表中选择一个关联微信用户的
                    session_info = request.env["im_livechat.channel"].with_context(lang=False).get_online_mail_channel(channel_id, anonymous_name)
                    if session_info:  # 再次选择到了
                        active_id = session_info["id"]
                if active_id:
                    # 当前对话对应客服
                    active_res_partner_id = session_info['operator_pid'][0]
                    active_res_partner = request.env['res.partner'].sudo().search([('id', '=', active_res_partner_id)], limit=1)
                    # 设置在线客服为当前服务人员
                    partner_user_id = request.env['res.users'].sudo().search([('partner_id', '=', active_res_partner.id)], limit=1)
                    # 发送微信信息给在线客服
                    # wx_user.consultation_reminder(active_res_partner, active_res_partner.wx_user_id.openid,
                    #                               origin_content,
                    #                               active_id, reminder_type="在线客服咨询")

            else:  # 联系客户经理
                _logger.info('需要联系客服要,创建新的会话')
                obj = request.env['wx.user.odoouser'].sudo().search([('openid', '=', openid)])
                uid = request.session.authenticate(request.session.db, obj.user_id.login, obj.password)
                # partners_to = [partner_user_id.partner_id.id, partner.id]
                partners_to = [partner_user_id.partner_id.id]  # 增加导购到会话
                # session_info = request.env["mail.channel"].create_user(partners_to);
                session_info = request.env["mail.channel"].channel_get(partners_to)
                active_id = session_info["id"]
                _logger.info('需要联系客服要,创建新的会话')
            if session_info:
                uuid = session_info['uuid']
                entry.create_uuid_for_openid(openid, uuid)
                # if not record_uuid:
                #wx_user.update_last_uuid(uuid, partner_user_id.id if partner_user_id else None, uuid_type, wx_user,partner.id)

        if uuid:
            if partner_user_id:
                # 发送信息到导购
                if partner_user_id.partner_id.im_status == 'offline' and partner_user_id.partner_id.wx_user_id:
                    wx_user.consultation_reminder(partner, partner_user_id.partner_id.wx_user_id.openid,
                                                  origin_content,
                                                  active_id, reminder_type)
            wx_user.update_last_uuid(uuid, partner_user_id.id if partner_user_id else None, uuid_type, wx_user, partner.id)
            localkwargs = {'weixin_id': openid, 'wx_type': 'wx'}
            message_type = "message"
            message_content = origin_content
            request_uid = request.session.uid or odoo.SUPERUSER_ID
            author_id = False  # message_post accept 'False' author_id, but not 'None'
            author = request.env['res.partner'].sudo().search([('wx_user_id.openid', '=', openid)], limit=1)
            if author:
                author_id = author.id
            else:
                pater_id = request.env['res.partner'].sudo().search([('wx_user_id.openid', '=', openid)], limit=1)
                if pater_id:
                    author = request.env['res.users'].sudo().search([('partner_id', '=', pater_id.id)], limit=1)
                    author_id = author.id
            if request.session.uid:
                author_id = request.env['res.users'].sudo().browse(request.session.uid).partner_id.id
            mail_channel = request.env["mail.channel"].sudo(request_uid).search([('uuid', '=', uuid)], limit=1)
            msg = mail_channel.sudo(request_uid).with_context(mail_create_nosubscribe=True).message_post(
                author_id=author_id, email_from=mail_channel.anonymous_name, body=message_content,
                message_type='comment', subtype='mail.mt_comment', content_subtype='plaintext',
                attachment_ids=attachment_ids, weixin_id=localkwargs)
            partner.message_post(body=message_content, author_id=author_id, attachment_ids=attachment_ids)
        if ret_msg:
            return ret_msg
Ejemplo n.º 18
0
    def setUp(self):
        super(TestPayrollSEPACreditTransfer, self).setUp()

        self.res_partner_bank = self.env['res.partner.bank'].create({
            'acc_number': 'BE32707171912447',
            'partner_id': self.ref('base.res_partner_12'),
            'acc_type': 'bank',
            'bank_id': self.ref('base.res_bank_1'),
        })

        self.ir_sequence = self.env['ir.sequence'].create({
            'name' : 'SEQ',
            'padding' : 4,
            'number_increment' : 1,
        })

        self.bank_partner = self.env['res.partner.bank'].create({
            'acc_number' : 'BE84567968814145',
            'acc_type': 'iban',
            'partner_id': self.env.ref('base.main_company').partner_id.id,
        })

        self.bank = self.env['res.bank'].create({
            'name':'BNP',
            'bic': 'GEBABEBB',
        })

        self.hr_employee_john = self.env['hr.employee'].create({
            'address_home_id': self.ref('base.res_partner_address_2'),
            'address_id': self.ref('base.res_partner_address_27'),
            'birthday': '1984-05-01',
            'children': 0.0,
            'country_id': self.ref('base.in'),
            'department_id': self.ref('hr.dep_rd'),
            'gender': 'male',
            'marital': 'single',
            'name': 'John',
            'bank_account_id': self.res_partner_bank.bank_id.id,
        })

        self.account_journal = self.env['account.journal'].create({
            'name' : 'MISC',
            'code' : 'MSC',
            'type' : 'general',
            'sequence_id' : self.ir_sequence.id,
        })

        self.bank_journal = self.env['account.journal'].create({
            'name' : 'Bank',
            'code' : 'BNK',
            'type' : 'bank',
            'sequence_id' : self.ir_sequence.id,
            'bank_id' : self.bank.id,
            'bank_account_id': self.bank_partner.id,
        })

        self.hr_structure_softwaredeveloper = self.env['hr.payroll.structure'].create({
            'name': 'Salary Structure for Software Developer',
            'rule_ids': [(6, 0, [
                self.ref('hr_payroll.hr_salary_rule_houserentallowance1'),
                self.ref('hr_payroll.hr_salary_rule_convanceallowance1'),
                self.ref('hr_payroll.hr_salary_rule_professionaltax1'),
                self.ref('hr_payroll.hr_salary_rule_providentfund1'),
                self.ref('hr_payroll.hr_salary_rule_meal_voucher'),
            ])],
            'journal_id' : self.account_journal.id,
            'type_id': self.env.ref('hr_payroll.structure_type_employee').id,
        })

        self.hr_structure_type = self.env['hr.payroll.structure.type'].create({
            'name': 'Salary Structure Type',
            'struct_ids': [(4, self.hr_structure_softwaredeveloper.id)],
        })

        self.hr_contract_john = self.env['hr.contract'].create({
            'date_end': Date.to_string(datetime.now() + timedelta(days=365)),
            'date_start': Date.today(),
            'name': 'Contract for John',
            'wage': 5000.0,
            'employee_id': self.hr_employee_john.id,
            'structure_type_id': self.hr_structure_type.id,
            'state': 'open',
        })

        self.hr_payslip_john = self.env['hr.payslip'].create({
            'employee_id': self.hr_employee_john.id,
            'struct_id' : self.hr_structure_softwaredeveloper.id,
            'contract_id': self.hr_contract_john.id,
            'journal_id': self.account_journal.id,
            'name': 'Test Payslip John',
        })
        self.hr_payslip_john.compute_sheet()

        self.payslip_run = self.env['hr.payslip.run'].create({
            'date_end': '2011-09-30',
            'date_start': '2011-09-01',
            'name': 'Payslip for Employee'
        })

        # Get a pain.001.001.03 schema validator
        schema_file_path = get_module_resource('account_sepa', 'schemas', 'pain.001.001.03.xsd')
        self.xmlschema = etree.XMLSchema(etree.parse(open(schema_file_path)))
Ejemplo n.º 19
0
 def getFile(self, filename, module_name=None):
     if module_name is None:
         module_name = 'l10n_it_fatturapa_out'
     path = get_module_resource(module_name, 'tests', 'data', filename)
     return self.getFilePath(path)
Ejemplo n.º 20
0
 def getFile(self, filename, module_name=None):
     if module_name is None:
         module_name = "l10n_it_fatturapa_out"
     path = get_module_resource(module_name, "tests", "data", filename)
     return self.getFilePath(path)
Ejemplo n.º 21
0
 def getAttachment(self, name, module_name=None):
     if module_name is None:
         module_name = "l10n_it_fatturapa_out"
     return self.getFilePath(
         get_module_resource(module_name, "tests", "data",
                             "attah_base.pdf"))
Ejemplo n.º 22
0
	def _default_image(self):
		image_path = get_module_resource('tests', 'static/src/img', 'apple.png')
    def test_camt_file_import(self):
        bank_journal = self.env['account.journal'].create({
            'name':
            'Bank 123456',
            'code':
            'BNK67',
            'type':
            'bank',
            'bank_acc_number':
            '123456',
            'currency_id':
            self.env.ref('base.USD').id,
        })

        partner_norbert = self.env['res.partner'].create({
            'name': 'Norbert Brant',
            'is_company': True,
        })
        bank_norbert = self.env['res.bank'].create({'name': 'test'})

        self.env['res.partner.bank'].create({
            'acc_number': 'BE93999574162167',
            'partner_id': partner_norbert.id,
            'bank_id': bank_norbert.id,
        })

        # Get CAMT file content
        camt_file_path = get_module_resource(
            'account_bank_statement_import_camt',
            'test_camt_file',
            'test_camt.xml',
        )
        camt_file = base64.b64encode(open(camt_file_path, 'rb').read())

        # Use an import wizard to process the file
        self.env['account.bank.statement.import']\
            .with_context(journal_id=bank_journal.id)\
            .create({'attachment_ids': [(0, 0, {'name': 'test file', 'datas': camt_file})]})\
            .import_file()

        # Check the imported bank statement
        imported_statement = self.env['account.bank.statement'].search([
            ('company_id', '=', self.env.company.id)
        ])
        self.assertRecordValues(imported_statement,
                                [{
                                    'name': '0574908765.2015-12-05',
                                    'balance_start': 8998.20,
                                    'balance_end_real': 2661.49,
                                }])
        self.assertRecordValues(imported_statement.line_ids.sorted('ref'), [
            {
                'ref': 'INNDNL2U20141231000142300002844',
                'partner_name': 'ASUSTeK',
                'amount': -7379.54,
                'partner_id': False,
            },
            {
                'ref': 'INNDNL2U20150105000217200000708',
                'partner_name': partner_norbert.name,
                'amount': 1636.88,
                'partner_id': partner_norbert.id,
            },
            {
                'ref': 'TESTBANK/NL/20151129/01206408',
                'partner_name': 'China Export',
                'amount': -564.05,
                'partner_id': False,
            },
        ])
Ejemplo n.º 24
0
    def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None):
        """generate the PDF"""

        # just try to find an xml id for the report
        env = api.Environment(cr, SUPERUSER_ID, {})
        found_xml_ids = env["ir.model.data"].search([["model", "=", "ir.actions.report.xml"], ["res_id", "=", report_xml.id]])
        xml_id = None
        if found_xml_ids:
            xml_id = "%s.%s" % (found_xml_ids.module, found_xml_ids.name)

        htmls = []
        if report_xml.report_type != 'webkit':
            return super(WebKitParser, self).create_single_pdf(cr, uid, ids, data, report_xml, context=context)

        parser_instance = self.parser(cr, uid, self.name2, context=context)

        self.env = env
        objs = self.getObjects(cr, uid, ids, context)
        parser_instance.set_context(objs, data, ids, report_xml.report_type)

        template = False

        if report_xml.report_file:
            path = get_module_resource(*report_xml.report_file.split('/'))
            if path and os.path.exists(path):
                template = file(path).read()
        if not template and report_xml.report_webkit_data:
            template = report_xml.report_webkit_data
        if not template:
            raise UserError(_('Webkit report template not found!'))
        header = report_xml.webkit_header.html
        footer = report_xml.webkit_header.footer_html
        if not header and report_xml.use_global_header:
            raise UserError(_('No header defined for this Webkit report!') + " " + _('Please set a header in company settings.'))
        if not report_xml.use_global_header:
            header = ''
            default_head = get_module_resource('report_webkit', 'default_header.html')
            with open(default_head, 'r') as f:
                header = f.read()
        css = report_xml.webkit_header.css
        if not css:
            css = ''

        translate_call = partial(self.translate_call, parser_instance)
        body_mako_tpl = mako_template(template)
        helper = WebKitHelper(cr, uid, report_xml.id, context)
        parser_instance.localcontext['helper'] = helper
        parser_instance.localcontext['css'] = css
        parser_instance.localcontext['_'] = translate_call

        # apply extender functions
        if xml_id in _extender_functions:
            for fct in _extender_functions[xml_id]:
                fct(env, cr, uid, parser_instance.localcontext, context)

        if report_xml.precise_mode:
            ctx = dict(parser_instance.localcontext)
            for obj in parser_instance.localcontext['objects']:
                ctx['objects'] = [obj]
                try:
                    html = body_mako_tpl.render(dict(ctx))
                    htmls.append(html)
                except Exception, e:
                    msg = u"%s" % e
                    _logger.info(msg, exc_info=True)
                    raise UserError(msg)
Ejemplo n.º 25
0
 def _default_image(self):
     image_path = get_module_resource('rw_headhunter', 'static/src/img',
                                      'default_image.png')
     return tools.image_resize_image_big(
         open(image_path, 'rb').read().encode('base64'))
Ejemplo n.º 26
0
    def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None):
        """generate the PDF"""

        # just try to find an xml id for the report
        env = api.Environment(cr, SUPERUSER_ID, {})
        found_xml_ids = env["ir.model.data"].search(
            [["model", "=", "ir.actions.report.xml"],
             ["res_id", "=", report_xml.id]])
        xml_id = None
        if found_xml_ids:
            xml_id = "%s.%s" % (found_xml_ids.module, found_xml_ids.name)

        htmls = []
        if report_xml.report_type != 'webkit':
            return super(WebKitParser, self).create_single_pdf(cr,
                                                               uid,
                                                               ids,
                                                               data,
                                                               report_xml,
                                                               context=context)

        parser_instance = self.parser(cr, uid, self.name2, context=context)

        self.env = env
        objs = self.getObjects(cr, uid, ids, context)
        parser_instance.set_context(objs, data, ids, report_xml.report_type)

        template = False

        if report_xml.report_file:
            path = get_module_resource(*report_xml.report_file.split('/'))
            if path and os.path.exists(path):
                template = file(path).read()
        if not template and report_xml.report_webkit_data:
            template = report_xml.report_webkit_data
        if not template:
            raise UserError(_('Webkit report template not found!'))
        header = report_xml.webkit_header.html
        footer = report_xml.webkit_header.footer_html
        if not header and report_xml.use_global_header:
            raise UserError(
                _('No header defined for this Webkit report!') + " " +
                _('Please set a header in company settings.'))
        if not report_xml.use_global_header:
            header = ''
            default_head = get_module_resource('report_webkit',
                                               'default_header.html')
            with open(default_head, 'r') as f:
                header = f.read()
        css = report_xml.webkit_header.css
        if not css:
            css = ''

        translate_call = partial(self.translate_call, parser_instance)
        body_mako_tpl = mako_template(template)
        helper = WebKitHelper(cr, uid, report_xml.id, context)
        parser_instance.localcontext['helper'] = helper
        parser_instance.localcontext['css'] = css
        parser_instance.localcontext['_'] = translate_call

        # apply extender functions
        if xml_id in _extender_functions:
            for fct in _extender_functions[xml_id]:
                fct(env, cr, uid, parser_instance.localcontext, context)

        if report_xml.precise_mode:
            ctx = dict(parser_instance.localcontext)
            for obj in parser_instance.localcontext['objects']:
                ctx['objects'] = [obj]
                try:
                    html = body_mako_tpl.render(dict(ctx))
                    htmls.append(html)
                except Exception, e:
                    msg = u"%s" % e
                    _logger.info(msg, exc_info=True)
                    raise UserError(msg)
Ejemplo n.º 27
0
 def _load(self, module, *args):
     convert_file(self.cr, 'muk_dms', get_module_resource(module,
                                                          *args), {},
                  'init', False, 'test', self.registry._assertion_report)
Ejemplo n.º 28
0
def _uninstall_rebrand_system(cr, registry):
    if version_info[5] != 'e':
        filename = get_module_resource('mail', 'data', 'ir_cron_data.xml')
        convert_file(cr, 'mail', filename, {}, 'init', False, 'data',
                     registry._assertion_report)
Ejemplo n.º 29
0
 def _read_file(self, *path_parts):
     path = module.get_module_resource(*path_parts)
     with open(path, 'rb') as f:
         return f.read()
Ejemplo n.º 30
0
 def _get_default_image(self, cr, uid, context=None):
     image_path = get_module_resource('mymodule', 'static/src/img',
                                      'default_image.png')
     return tools.image_resize_image_big(
         open(image_path, 'rb').read().encode('base64'))
Ejemplo n.º 31
0
 def _default_image(self):
     image_path = get_module_resource('base_bim_2', 'static/src/img',
                                      'default_image.png')
     return base64.b64encode(open(image_path, 'rb').read())
Ejemplo n.º 32
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'website',
                        get_module_resource(module, *args), {}, 'init',
                        False, 'test', self.registry._assertion_report)
Ejemplo n.º 33
0
 def _get_default_image(self, cr, uid, context=None):
     image_path = get_module_resource('hr', 'static/src/img', 'default_image.png')
     return tools.image_resize_image_big(open(image_path, 'rb').read().encode('base64'))
Ejemplo n.º 34
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'website',
                        get_module_resource(module, *args),
                        {}, 'init', False, 'test')
Ejemplo n.º 35
0
 def _default_image(self):
     image_path = get_module_resource('hr', 'static/src/img', 'default_image.png')
     return tools.image_resize_image_big(base64.b64encode(open(image_path, 'rb').read()))
Ejemplo n.º 36
0
 def _load(self, module, *args):
     tools.convert_file(
         self.cr, 'hr_payroll_account',
         get_module_resource(module, *args), {}, 'init', False, 'test', self.registry._assertion_report)
    def test_ofx_file_import(self):
        bank_journal = self.env['account.journal'].create({
            'name': 'Bank 123456',
            'code': 'BNK67',
            'type': 'bank',
            'bank_acc_number': '123456',
            'currency_id': self.env.ref('base.USD').id,
        })

        partner_norbert = self.env['res.partner'].create({
            'name': 'Norbert Brant',
            'is_company': True,
        })
        bank_norbert = self.env['res.bank'].create({'name': 'test'})
        partner_bank_norbert = self.env['res.partner.bank'].create({
            'acc_number': 'BE93999574162167',
            'partner_id': partner_norbert.id,
            'bank_id': bank_norbert.id,
        })

        # Get OFX file content
        ofx_file_path = get_module_resource('account_bank_statement_import_ofx', 'static/ofx', 'test_ofx.ofx')
        ofx_file = base64.b64encode(open(ofx_file_path, 'rb').read())

        # Use an import wizard to process the file
        self.env['account.bank.statement.import']\
            .with_context(journal_id=bank_journal.id)\
            .create({'attachment_ids': [(0, 0, {'name': 'test_ofx.ofx', 'datas': ofx_file})]})\
            .import_file()

        # Check the imported bank statement
        imported_statement = self.env['account.bank.statement'].search([('company_id', '=', self.env.company.id)])
        self.assertRecordValues(imported_statement, [{
            'reference': 'test_ofx.ofx',
            'balance_start': 2516.56,
            'balance_end_real': 2156.56,
        }])
        self.assertRecordValues(imported_statement.line_ids.sorted('payment_ref'), [
            {
                'payment_ref': 'Axelor Scuba',
                'amount': -100.0,
                'partner_id': False,
                'partner_bank_id': False,
            },
            {
                'payment_ref': 'China Export',
                'amount': -90.0,
                'partner_id': False,
                'partner_bank_id': False,
            },
            {
                'payment_ref': 'China Scuba',
                'amount': -90.0,
                'partner_id': False,
                'partner_bank_id': False,
            },
            {
                'payment_ref': partner_norbert.name,
                'amount': -80.0,
                'partner_id': partner_norbert.id,
                'partner_bank_id': partner_bank_norbert.id,
            },
        ])
Ejemplo n.º 38
0
    def test_02_admin_shop_custom_attribute_value_tour(self):
        # Make sure pricelist rule exist
        self.product_attribute_1 = self.env['product.attribute'].create({
            'name':
            'Legs',
            'sequence':
            10,
        })
        product_attribute_value_1 = self.env['product.attribute.value'].create(
            {
                'name': 'Steel',
                'attribute_id': self.product_attribute_1.id,
                'sequence': 1,
            })
        product_attribute_value_2 = self.env['product.attribute.value'].create(
            {
                'name': 'Aluminium',
                'attribute_id': self.product_attribute_1.id,
                'sequence': 2,
            })
        product_attribute_2 = self.env['product.attribute'].create({
            'name':
            'Color',
            'sequence':
            20,
        })
        product_attribute_value_3 = self.env['product.attribute.value'].create(
            {
                'name': 'White',
                'attribute_id': product_attribute_2.id,
                'sequence': 1,
            })
        product_attribute_value_4 = self.env['product.attribute.value'].create(
            {
                'name': 'Black',
                'attribute_id': product_attribute_2.id,
                'sequence': 2,
            })

        # Create product template
        self.product_product_4_product_template = self.env[
            'product.template'].create({
                'name': 'Customizable Desk (TEST)',
                'standard_price': 500.0,
                'list_price': 750.0,
            })

        # Generate variants
        self.env['product.template.attribute.line'].create([{
            'product_tmpl_id':
            self.product_product_4_product_template.id,
            'attribute_id':
            self.product_attribute_1.id,
            'value_ids': [(4, product_attribute_value_1.id),
                          (4, product_attribute_value_2.id)],
        }, {
            'product_tmpl_id':
            self.product_product_4_product_template.id,
            'attribute_id':
            product_attribute_2.id,
            'value_ids': [(4, product_attribute_value_3.id),
                          (4, product_attribute_value_4.id)],
        }])
        product_template = self.product_product_4_product_template

        # Add Custom Attribute
        product_attribute_value_7 = self.env['product.attribute.value'].create(
            {
                'name': 'Custom TEST',
                'attribute_id': self.product_attribute_1.id,
                'sequence': 3,
                'is_custom': True
            })
        self.product_product_4_product_template.attribute_line_ids[0].write(
            {'value_ids': [(4, product_attribute_value_7.id)]})

        img_path = get_module_resource('product', 'static', 'img',
                                       'product_product_11-image.png')
        img_content = base64.b64encode(open(img_path, "rb").read())
        self.product_product_11_product_template = self.env[
            'product.template'].create({
                'name': 'Conference Chair (TEST)',
                'website_sequence': 9999,  # laule
                'image_1920': img_content,
                'list_price': 16.50,
            })

        self.env['product.template.attribute.line'].create({
            'product_tmpl_id':
            self.product_product_11_product_template.id,
            'attribute_id':
            self.product_attribute_1.id,
            'value_ids': [(4, product_attribute_value_1.id),
                          (4, product_attribute_value_2.id)],
        })
        self.product_product_11_product_template.attribute_line_ids[
            0].product_template_value_ids[1].price_extra = 6.40

        # Setup a second optional product
        self.product_product_1_product_template = self.env[
            'product.template'].create({
                'name': 'Chair floor protection',
                'list_price': 12.0,
            })

        # fix runbot, sometimes one pricelist is chosen, sometimes the other...
        pricelists = self.env['website'].get_current_website(
        ).get_current_pricelist() | self.env.ref('product.list0')

        for pricelist in pricelists:
            if not pricelist.item_ids.filtered(
                    lambda i: i.product_tmpl_id == product_template and i.
                    price_discount == 20):
                self.env['product.pricelist.item'].create({
                    'base':
                    'list_price',
                    'applied_on':
                    '1_product',
                    'pricelist_id':
                    pricelist.id,
                    'product_tmpl_id':
                    product_template.id,
                    'price_discount':
                    20,
                    'min_quantity':
                    2,
                    'compute_price':
                    'formula',
                })

            pricelist.discount_policy = 'without_discount'

        self.start_tour("/", 'shop_custom_attribute_value', login="******")
Ejemplo n.º 39
0
    def setUp(self):
        super(TestUICommon, self).setUp()
        # Load pdf and img contents
        pdf_path = get_module_resource('website_slides', 'static', 'src', 'img', 'presentation.pdf')
        pdf_content = base64.b64encode(open(pdf_path, "rb").read())
        img_path = get_module_resource('website_slides', 'static', 'src', 'img', 'slide_demo_gardening_1.jpg')
        img_content = base64.b64encode(open(img_path, "rb").read())

        self.env['slide.channel'].create({
            'name': 'Basics of Gardening - Test',
            'user_id': self.env.ref('base.user_admin').id,
            'enroll': 'public',
            'channel_type': 'training',
            'allow_comment': True,
            'promote_strategy': 'most_voted',
            'is_published': True,
            'description': 'Learn the basics of gardening !',
            'create_date': Datetime.now() - relativedelta(days=8),
            'slide_ids': [
                (0, 0, {
                    'name': 'Gardening: The Know-How',
                    'sequence': 1,
                    'binary_content': pdf_content,
                    'slide_category': 'document',
                    'is_published': True,
                    'is_preview': True,
                }), (0, 0, {
                    'name': 'Home Gardening',
                    'sequence': 2,
                    'image_1920': img_content,
                    'slide_category': 'infographic',
                    'is_published': True,
                }), (0, 0, {
                    'name': 'Mighty Carrots',
                    'sequence': 3,
                    'image_1920': img_content,
                    'slide_category': 'infographic',
                    'is_published': True,
                }), (0, 0, {
                    'name': 'How to Grow and Harvest The Best Strawberries | Basics',
                    'sequence': 4,
                    'binary_content': pdf_content,
                    'slide_category': 'document',
                    'is_published': True,
                }), (0, 0, {
                    'name': 'Test your knowledge',
                    'sequence': 5,
                    'slide_category': 'quiz',
                    'is_published': True,
                    'question_ids': [
                        (0, 0, {
                            'question': 'What is a strawberry ?',
                            'answer_ids': [
                                (0, 0, {
                                    'text_value': 'A fruit',
                                    'is_correct': True,
                                    'sequence': 1,
                                }), (0, 0, {
                                    'text_value': 'A vegetable',
                                    'sequence': 2,
                                }), (0, 0, {
                                    'text_value': 'A table',
                                    'sequence': 3,
                                })
                            ]
                        }), (0, 0, {
                            'question': 'What is the best tool to dig a hole for your plants ?',
                            'answer_ids': [
                                (0, 0, {
                                    'text_value': 'A shovel',
                                    'is_correct': True,
                                    'sequence': 1,
                                }), (0, 0, {
                                    'text_value': 'A spoon',
                                    'sequence': 2,
                                })
                            ]
                        })
                    ]
                })
            ]
        })
Ejemplo n.º 40
0
 def get_image(self, img_name=False):
     if not img_name:
         return False
     image_path = get_module_resource('flsp_customer_badge',
                                      'static/description', img_name)
     return base64.b64encode(open(image_path, 'rb').read())
Ejemplo n.º 41
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'l10n_ro_account_period_close',
                        get_module_resource(module, *args), {}, 'init',
                        False, 'test', self.registry._assertion_report)
Ejemplo n.º 42
0
 def _load(cls, module, *args):
     convert_file(cls.cr, 'ag_dms', get_module_resource(module, *args),
         {}, 'init', False, 'test', cls.registry._assertion_report)
Ejemplo n.º 43
0
 def _default_image(self):
     if self.company_type == "person":
         image_path = get_module_resource('jobnow', 'static/src/img', 'default_image.png')
     else:
         image_path = get_module_resource('jobnow', 'static/src/img', 'company_image.png')
     return base64.b64encode(open(image_path, 'rb').read())
Ejemplo n.º 44
0
 def _load(self, module, *args):
     tools.convert_file(
         self.cr, 'stock_dropshipping', get_module_resource(module, *args), {}, 'init', False, 'test', self.registry._assertion_report)
Ejemplo n.º 45
0
from odoo.modules.module import get_module_resource
from lxml import etree

_logger = logging.getLogger(__name__)
_logger.setLevel(logging.DEBUG)

try:
    import pyxb.binding
except (ImportError) as err:
    _logger.debug(err)

from .binding import *  # noqa: F403

XSD_SCHEMA = 'Schema_del_file_xml_FatturaPA_versione_1.2.1.xsd'

_xsd_schema = get_module_resource('l10n_it_fatturapa', 'bindings', 'xsd',
                                  XSD_SCHEMA)
_root = etree.parse(_xsd_schema)

_CreateFromDocument = CreateFromDocument  # noqa: F405

date_types = {}
datetime_types = {}


def get_parent_element(e):
    for ancestor in e.iterancestors():
        if 'name' in ancestor.attrib:
            return ancestor


def get_type_query(e):
Ejemplo n.º 46
0
 def _load(self, module, *args):
     tools.convert_file(self.cr, 'report_intrastat',
                        get_module_resource(module, *args),
                        {}, 'init', False, 'test', self.registry._assertion_report)
Ejemplo n.º 47
0
 def _get_default_image(self, cr, uid, context=None):
     image_path = get_module_resource("hr", "static/src/img", "default_image.png")
     return tools.image_resize_image_big(open(image_path, "rb").read().encode("base64"))