当前位置: 首页>>代码示例>>Python>>正文


Python ConnectorSession.from_env方法代码示例

本文整理汇总了Python中openerp.addons.connector.session.ConnectorSession.from_env方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectorSession.from_env方法的具体用法?Python ConnectorSession.from_env怎么用?Python ConnectorSession.from_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openerp.addons.connector.session.ConnectorSession的用法示例。


在下文中一共展示了ConnectorSession.from_env方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_from_env

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def test_from_env(self):
     """ ConnectorSession.from_env(env) """
     session = ConnectorSession.from_env(self.env)
     self.assertEqual(session.cr, self.env.cr)
     self.assertEqual(session.uid, self.env.uid)
     self.assertEqual(session.context, self.env.context)
     self.assertEqual(session.pool, self.env.registry)
开发者ID:borni-dhifi,项目名称:odoo-magento-modules,代码行数:9,代码来源:test_session.py

示例2: button_import

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
    def button_import(self):
        """
        Analyze the imports in order to create the letter's lines
        """
        if not self.manual_import:
            # when letters are in a folder on NAS redefine method
            for letters_import in self:
                letters_import.state = 'pending'
                if self.env.context.get('async_mode', True):
                    session = ConnectorSession.from_env(self.env)
                    ilh.import_letters_job.delay(
                        session, self._name, letters_import.id)
                else:
                    letters_import._run_analyze()
            return True
        else:
            # when letters selected by user, save them on NAS and call
            # super method
            for letters_import in self:
                if letters_import.data and self.env.context.get(
                        'async_mode', True):
                    for attachment in letters_import.data:
                        self._save_imported_letter(attachment)

            return super(ImportLettersHistory, self).button_import()
开发者ID:philippe89,项目名称:compassion-switzerland,代码行数:27,代码来源:import_letters_history.py

示例3: process_reconciliations

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def process_reconciliations(self, mv_line_dicts):
     """ Launch reconciliation in a job. """
     if self.env.context.get('async_mode', True):
         session = ConnectorSession.from_env(self.env)
         process_reconciliations_job.delay(
             session, self._name, mv_line_dicts)
     else:
         self._process_reconciliations(mv_line_dicts)
开发者ID:MickSandoz,项目名称:compassion-accounting,代码行数:10,代码来源:bank_statement_line.py

示例4: import_sale_orders

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def import_sale_orders(self):
     session = ConnectorSession.from_env(self.env)
     for backend in self:
         sale_order_import_batch.delay(
             session,
             'cdiscount.sale.order',
             backend.id,
             priority=1)  # executed as soon as possible
     return True
开发者ID:EBII,项目名称:connector-cdiscount,代码行数:11,代码来源:cdiscount_model.py

示例5: process_messages

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def process_messages(self):
     new_messages = self.filtered(lambda m: m.state in ('new', 'failure'))
     new_messages.write({'state': 'pending', 'failure_reason': False})
     if self.env.context.get('async_mode', True):
         session = ConnectorSession.from_env(self.env)
         process_messages_job.delay(session, self._name, self.ids)
     else:
         self._process_messages()
     return True
开发者ID:rz-comp,项目名称:compassion-modules,代码行数:11,代码来源:gmc_message.py

示例6: _reset_open_invoices

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def _reset_open_invoices(self):
     """ Launch the task in asynchrnous job by default. """
     if self.env.context.get('async_mode', True):
         session = ConnectorSession.from_env(self.env)
         reset_open_invoices_job.delay(
             session, self._name, self.ids)
     else:
         self._reset_open_invoices_job()
     return True
开发者ID:rz-comp,项目名称:compassion-modules,代码行数:11,代码来源:contracts.py

示例7: clean_invoices

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def clean_invoices(self):
     """ By default, launch asynchronous job to perform the task.
         Context value async_mode set to False can force to perform
         the task immediately.
     """
     if self.env.context.get('async_mode', True):
         session = ConnectorSession.from_env(self.env)
         clean_generate_job.delay(session, self._name, self.ids)
     else:
         self._clean_generate_invoices()
     return True
开发者ID:MickSandoz,项目名称:compassion-accounting,代码行数:13,代码来源:contract_group.py

示例8: clean_invoices

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def clean_invoices(self, since_date=None, to_date=None, keep_lines=None):
     """ By default, launch asynchronous job to perform the task.
         Context value async_mode set to False can force to perform
         the task immediately.
     """
     if self.env.context.get('async_mode', True):
         session = ConnectorSession.from_env(self.env)
         clean_invoices_job.delay(
             session, self._name, self.ids, since_date, to_date,
             keep_lines)
     else:
         self._clean_invoices(since_date, to_date, keep_lines)
开发者ID:philippe89,项目名称:compassion-accounting,代码行数:14,代码来源:recurring_contract.py

示例9: button_import

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def button_import(self):
     """
     Analyze the attachment in order to create the letter's lines
     """
     for letters_import in self:
         if letters_import.data:
             letters_import.state = 'pending'
             if self.env.context.get('async_mode', True):
                 session = ConnectorSession.from_env(self.env)
                 import_letters_job.delay(
                     session, self._name, letters_import.id)
             else:
                 letters_import._run_analyze()
     return True
开发者ID:MickSandoz,项目名称:compassion-modules,代码行数:16,代码来源:import_letters_history.py

示例10: setUp

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
    def setUp(self):
        super(TestImportMagentoConcurrentSync, self).setUp()
        self.registry2 = RegistryManager.get(get_db_name())
        self.cr2 = self.registry2.cursor()
        self.env2 = api.Environment(self.cr2, self.env.uid, {})
        backend2 = mock.Mock(name='Backend Record')
        backend2._name = 'magento.backend'
        backend2.id = self.backend_id
        self.backend2 = backend2
        self.connector_session2 = ConnectorSession.from_env(self.env2)

        @self.addCleanup
        def reset_cr2():
            # rollback and close the cursor, and reset the environments
            self.env2.reset()
            self.cr2.rollback()
            self.cr2.close()
开发者ID:alangwansui,项目名称:odoo_magento_connector,代码行数:19,代码来源:test_synchronization.py

示例11: process_commkit_notifications

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
    def process_commkit_notifications(self, commkit_updates, headers, eta=None):
        """ Create jobs which will process all incoming CommKit Notification
        messages. """
        session = ConnectorSession.from_env(self.env)
        action_id = self.env.ref("onramp_compassion.update_commkit").id
        for update_data in commkit_updates:
            # Create a GMC message to keep track of the updates
            gmc_message = self.env["gmc.message.pool"].create(
                {
                    "action_id": action_id,
                    "content": json.dumps(update_data),
                    "headers": json.dumps(dict(headers.items())),
                }
            )
            job_uuid = update_commkit_job.delay(session, self._name, update_data, gmc_message.id, eta=eta)
            gmc_message.request_id = job_uuid

        return True
开发者ID:rz-comp,项目名称:compassion-modules,代码行数:20,代码来源:sponsorship_correspondence.py

示例12: handler_web_children_hold

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
    def handler_web_children_hold(self):

        headers = request.httprequest.headers
        self._validate_headers(headers)

        # load children via a research on childpool
        child_research = request.env['compassion.childpool.search'].sudo()
        research = child_research.create({'take': 5})
        research.rich_mix()

        # create a hold for all children found
        session = ConnectorSession.from_env(request.env)
        hold_children_job.delay(session, research.id)

        data = ""
        # return principal children info
        for child in research.global_child_ids:
            data += child.name + ' ' + child.birthdate + '<br>'

        headers = Headers()
        response = Response(data, content_type='text/html', headers=headers)

        return response
开发者ID:ecino,项目名称:compassion-modules,代码行数:25,代码来源:web_children_hold.py

示例13: generate_invoices

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def generate_invoices(self, invoicer=None):
     """ By default, launch asynchronous job to perform the task.
         Context value async_mode set to False can force to perform
         the task immediately.
     """
     if invoicer is None:
         invoicer = self.env['recurring.invoicer'].create(
             {'source': self._name})
     if self.env.context.get('async_mode', True):
         session = ConnectorSession.from_env(self.env)
         generate_invoices_job.delay(
             session, self._name, self.ids, invoicer.id)
     else:
         # Prevent two generations at the same time
         jobs = self.env['queue.job'].search([
             ('channel', '=', 'root.recurring_invoicer'),
             ('state', '=', 'started')])
         if jobs:
             raise exceptions.Warning(
                 _("Generation already running"),
                 _("A generation has already started in background. "
                   "Please wait for it to finish."))
         self._generate_invoices(invoicer)
     return invoicer
开发者ID:MickSandoz,项目名称:compassion-accounting,代码行数:26,代码来源:contract_group.py

示例14: _postpone_deletion

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def _postpone_deletion(self):
     postpone = datetime.now() + timedelta(seconds=10)
     session = ConnectorSession.from_env(self.env)
     unlink_children_job.delay(session, self._name, self.ids, eta=postpone)
开发者ID:ecino,项目名称:compassion-modules,代码行数:6,代码来源:child_compassion.py

示例15: generate_invoices

# 需要导入模块: from openerp.addons.connector.session import ConnectorSession [as 别名]
# 或者: from openerp.addons.connector.session.ConnectorSession import from_env [as 别名]
 def generate_invoices(self, invoicer=None):
     session = ConnectorSession.from_env(self.env)
     if invoicer is None:
         invoicer = self.env["recurring.invoicer"].create({"source": self._name})
     job_uuid = generate_invoices_job.delay(session, self._name, self.ids, invoicer.id)
     return invoicer
开发者ID:rz-comp,项目名称:compassion-accounting,代码行数:8,代码来源:contract_group.py


注:本文中的openerp.addons.connector.session.ConnectorSession.from_env方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。