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


Python openerp.SUPERUSER_ID属性代码示例

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


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

示例1: write

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def write(self, cr, uid, ids, vals, context=None):
        if isinstance(ids, (int, long)):
            ids = [ids]
        if vals.get('date_start') or vals.get('date_stop'):
            recompute_obj = self.pool.get('account.asset.recompute.trigger')
            fy_datas = self.read(cr, uid, ids, ['code', 'company_id'])
            for fy_data in fy_datas:
                recompute_vals = {
                    'reason': 'duration change of fiscalyear %s' % fy_data['code'],
                    'company_id': fy_data['company_id'][0],
                    'date_trigger': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
                    'state': 'open',
                }
                recompute_obj.create(cr, SUPERUSER_ID, recompute_vals, context=context)
        return super(account_fiscalyear, self).write(cr, uid, ids, vals, context=context)

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:19,代码来源:account.py

示例2: vat_search

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def vat_search(self, cr, ids, vat, context):
        # import pdb; pdb.set_trace()
        partner_vat = self.search(cr, SUPERUSER_ID, [('vat', '=', vat)], context=context)
        # partner_vat_dif = set(partner_vat).symmetric_difference(set(ids))
        if context.get('res_log_read', False):
            return True
        if partner_vat and ids not in partner_vat:
            partner = self.browse(cr, SUPERUSER_ID, partner_vat, context)[0]
            raise orm.except_orm(_('Error!'),
                _("Vat {vat} just exist on partner {partner} assigned to {user}!").format(vat=vat, partner=partner.name, user=partner.user_id.name or ''))
        partner_vat = self.search(cr, SUPERUSER_ID, [('vat', '=', vat), ('active', '=', False)], context=context)

        if partner_vat and ids not in partner_vat:
            partner = self.browse(cr, SUPERUSER_ID, partner_vat, context)[0]
            raise orm.except_orm(_('Error!'),
                _("Vat {vat} just exist non active partner {partner} assigned to {user}!").format(vat=vat, partner=partner.name, user=partner.user_id and partner.user_id.name or ''))
        return True 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:19,代码来源:base_vat_unique.py

示例3: _flex_working_hours

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def _flex_working_hours(self):
        flex_working_hours = 0.0
        leaves = 0.0
        if self._check_last_sign_out(self):
            att = self.env['hr.attendance'].sudo().search([('employee_id','=',self.employee_id.id),('name','>',self.name[:10] + ' 00:00:00'),('name','<',self.name[:10] + ' 23:59:59')],order='name')
            _logger.warn(att)
            job_intervals = self.pool.get('resource.calendar').get_working_intervals_of_day(self.env.cr,SUPERUSER_ID, self.employee_id.sudo().contract_id.working_hours.id, start_dt=fields.Datetime.from_string(self.name).replace(hour=0,minute=0))
            _logger.warn(job_intervals)
            if len(job_intervals) > 0:
                if self.flextime > 0.0: #if got positive flex time, worked flex = worked on schedule + flex time
                    self.flex_working_hours = self.get_working_hours + self.flextime / 60.0
                elif self.flextime < 0.0: #if got negative flex time, worked flex = planned hours + flex time
                    self.flex_working_hours = self.working_hours_on_day + self.flextime / 60.0
                elif self.flextime == 0.0: #if got 0 flex time
                    if fields.Datetime.from_string(att[0].name) < job_intervals[0][0] or fields.Datetime.from_string(att[-1].name) > job_intervals[-1][-1]: #if extra worked time is out of schedule, so fill up missed hours in schedule
                        self.flex_working_hours = self.working_hours_on_day
                    elif fields.Datetime.from_string(att[0].name) >= job_intervals[0][0] or fields.Datetime.from_string(att[-1].name) <= job_intervals[-1][-1]: #if not, take worked hours in schedule
                        self.flex_working_hours = self.get_working_hours 
开发者ID:vertelab,项目名称:odoo-payroll,代码行数:20,代码来源:hr_payroll.py

示例4: check_credentials

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def check_credentials(self, cr, uid, token):
        """token can be a password if the user has used the normal form...
        but we are more interested in the case when they are tokens
        and the interesting code is inside the except clause
        """
        token_osv = self.pool.get('auth_saml.token')
        try:
            super(res_users, self).check_credentials(cr, uid, token)

        except openerp.exceptions.AccessDenied:
            # since normal auth did not succeed we now try to find if the user
            # has an active token attached to his uid
            res = token_osv.search(
                cr, SUPERUSER_ID,
                [
                    ('user_id', '=', uid),
                    ('saml_access_token', '=', token),
                ]
            )

            # if the user is not found we re-raise the AccessDenied
            if not res:
                # TODO: maybe raise a defined exception instead of the last
                # exception that occurred in our execution frame
                raise 
开发者ID:xcgd,项目名称:auth_saml,代码行数:27,代码来源:res_users.py

示例5: get_auth_request

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def get_auth_request(self, req, relaystate):
        """state is the JSONified state object and we need to pass
        it inside our request as the RelayState argument
        """
        state = simplejson.loads(relaystate)

        dbname = state['d']
        provider_id = state['p']
        context = state.get('c', {})

        registry = RegistryManager.get(dbname)
        provider_osv = registry.get('auth.saml.provider')

        auth_request = None

        try:
            with registry.cursor() as cr:
                auth_request = provider_osv._get_auth_request(
                    cr, SUPERUSER_ID, provider_id, state, context=context
                )

        except Exception, e:
            _logger.exception("SAML2: %s" % str(e)) 
开发者ID:xcgd,项目名称:auth_saml,代码行数:25,代码来源:main.py

示例6: list_providers

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def list_providers(self, req, dbname):
        l = []
        try:
            registry = RegistryManager.get(dbname)
            with registry.cursor() as cr:
                providers = registry.get('auth.saml.provider')
                if providers:
                    l = providers.read(
                        cr, SUPERUSER_ID, providers.search(
                            cr, SUPERUSER_ID, [('enabled', '=', True)]
                        ),
                        [
                            "id",
                            "name",
                            "enabled",
                            "css_class",
                            "body",
                            "sequence",
                        ],
                    )
                else:
                    l = []

        except Exception, e:
            _logger.exception("SAML2: %s" % str(e)) 
开发者ID:xcgd,项目名称:auth_saml,代码行数:27,代码来源:main.py

示例7: get_last_post_for_model

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def get_last_post_for_model(cr, uid, ids, model_pool):
    """
    Given a set of ids and a model pool, return a dict of each object ids with
    their latest message date as a value.
    To be called in post-migration scripts

    :param cr: database cursor
    :param uid: user id, assumed to be openerp.SUPERUSER_ID
    :param ids: ids of the model in question to retrieve ids
    :param model_pool: orm model pool, assumed to be from pool.get()
    :return: a dict with ids as keys and with dates as values
    """
    if type(ids) is not list:
        ids = [ids]
    res = {}
    for obj in model_pool.browse(cr, uid, ids):
        message_ids = obj.message_ids
        if message_ids:
            res[obj.id] = sorted(
                message_ids, key=lambda x: x.date, reverse=True)[0].date
        else:
            res[obj.id] = False
    return res 
开发者ID:OCA,项目名称:openupgradelib,代码行数:25,代码来源:openupgrade_80.py

示例8: update_product

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def update_product(self, cr, uid, ids, context):
        supplierinfo_obj = self.pool['product.supplierinfo']
        user = self.pool['res.users'].browse(cr, uid, uid, context)
        to_currency = user.company_id.currency_id.id
        for order in self.browse(cr, uid, ids, context):
            for line in order.order_line:
                if line.product_id:
                    vals = {
                        # 'last_purchase_date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                        'last_purchase_date': order.date_order or time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                        'last_supplier_id': line.partner_id.id,
                        'last_purchase_order_id': order.id,
                    }

                    self.pool['product.product'].write(cr, SUPERUSER_ID, line.product_id.id, vals, context)
                    supplierinfo_ids = supplierinfo_obj.search(cr, uid, [('product_id', '=', line.product_id.id), ('name', '=', line.partner_id.id)], context=context)
                    if not supplierinfo_ids:
                        supplierinfo_ids = supplierinfo_obj.search(cr, uid, [('product_id', '=', line.product_id.id)], context=context)
                        sequence = 10
                        if supplierinfo_ids:
                            sequence = supplierinfo_obj.browse(cr, uid, supplierinfo_ids[-1], context).sequence + 10

                        price_unit = self._get_product_unit_price(cr, uid, ids, to_currency, line, context)

                        pricelist_vals = {
                            'min_quantity': 1,
                            'name': order.name,
                            'price': price_unit,
                        }

                        supplierinfo_obj.create(cr, uid, {
                            'name': line.partner_id.id,
                            'product_name': line.name,
                            'product_id': line.product_id.id,
                            'min_qty': 1,
                            'product_code': line.product_id.default_code,
                            'pricelist_ids': [(0, 0, pricelist_vals)],
                            'sequence': sequence
                        }, context)
        return True 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:42,代码来源:purchase_order.py

示例9: update_product

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def update_product(self, cr, uid, ids, context):
        for order in self.browse(cr, uid, ids, context):
            for line in order.order_line:
                if line.product_id:
                    vals = {
                        # 'last_sale_date': time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                        'state': 'sellable',
                        'last_sale_date': order.date_order or time.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
                        'last_customer_id': line.order_partner_id.id,
                        'last_sale_order_id': order.id
                    }
                    self.pool['product.product'].write(cr, SUPERUSER_ID, line.product_id.id, vals, context)
        return True 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:15,代码来源:sale_order.py

示例10: name_get

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def name_get(self, cr, uid, ids, context=None):
        if not len(ids):
            return []
        res = []
        for record in self.browse(cr, SUPERUSER_ID, ids, context=context):
            if record.project_id:
                name = record.project_id.name[:30] + ' : ' + record.name
            else:
                name = record.name
            # if len(name) > 65:
            #     name = name[:65] + '...'
            res.append((record.id, name))
        return res 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:15,代码来源:inherited_project_task.py

示例11: onchange_ddt_number

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def onchange_ddt_number(self, cr, uid, ids, ddt_number, context=None):
        ddt_number_already_exist = False
        if ddt_number:
            if self.pool['stock.picking'].search(cr, SUPERUSER_ID, [('ddt_number', '=', ddt_number)], context=context):
                ddt_number_already_exist = True
        return {'value': {'ddt_number_already_exist': ddt_number_already_exist}}

# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:10,代码来源:assign_ddt.py

示例12: create

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def create(self, cr, uid, vals, context=None):
        recompute_obj = self.pool.get('account.asset.recompute.trigger')
        recompute_vals = {
            'reason': 'creation of fiscalyear %s' % vals.get('code'),
            'company_id': vals.get('company_id') or self.pool.get('res.users').browse(cr, uid, uid, context).company_id.id,
            'date_trigger': time.strftime(tools.DEFAULT_SERVER_DATETIME_FORMAT),
            'state': 'open',
        }
        recompute_obj.create(cr, SUPERUSER_ID, recompute_vals, context=context)
        return super(account_fiscalyear, self).create(cr, uid, vals, context=context) 
开发者ID:iw3hxn,项目名称:LibrERP,代码行数:12,代码来源:account.py

示例13: OdooEnvironment

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def OdooEnvironment(database, rollback=False, **kwargs):
    with Environment.manage():
        registry = odoo.registry(database)
        try:
            with registry.cursor() as cr:
                uid = odoo.SUPERUSER_ID
                try:
                    ctx = Environment(cr, uid, {})["res.users"].context_get()
                except Exception as e:
                    ctx = {"lang": "en_US"}
                    # this happens, for instance, when there are new
                    # fields declared on res_partner which are not yet
                    # in the database (before -u)
                    _logger.warning(
                        "Could not obtain a user context, continuing "
                        "anyway with a default context. Error was: %s",
                        e,
                    )
                env = Environment(cr, uid, ctx)
                cr.rollback()
                yield env
                if rollback:
                    cr.rollback()
                else:
                    cr.commit()
        finally:
            if odoo.tools.parse_version(
                odoo.release.version
            ) < odoo.tools.parse_version("10.0"):
                odoo.modules.registry.RegistryManager.delete(database)
            else:
                odoo.modules.registry.Registry.delete(database)
            odoo.sql_db.close_db(database) 
开发者ID:acsone,项目名称:click-odoo,代码行数:35,代码来源:env.py

示例14: _working_hours_on_day

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def _working_hours_on_day(self): # working hours on the contract
        if self.employee_id.sudo().contract_id and self._check_last_sign_out(self):
            self.working_hours_on_day = self.pool.get('resource.calendar').working_hours_on_day(self.env.cr, SUPERUSER_ID,
                self.employee_id.sudo().contract_id.working_hours, fields.Datetime.from_string(self.name))
        else:
            self.working_hours_on_day = 0.0 
开发者ID:vertelab,项目名称:odoo-payroll,代码行数:8,代码来源:hr_payroll.py

示例15: _get_working_hours

# 需要导入模块: import openerp [as 别名]
# 或者: from openerp import SUPERUSER_ID [as 别名]
def _get_working_hours(self): # worked hours in schedule
        if self.employee_id.sudo().contract_id and self._check_last_sign_out(self):
            att = self.env['hr.attendance'].search([('employee_id','=',self.employee_id.id),('name','>',self.name[:10] + ' 00:00:00'),('name','<',self.name[:10] + ' 23:59:59')],order='name')
            for (start,end) in zip(att,att[1:])[::2]:
                self.get_working_hours += self.pool.get('resource.calendar').get_working_hours(
                    self.env.cr, SUPERUSER_ID, self.employee_id.sudo().contract_id.working_hours.id,
                    fields.Datetime.from_string(start.name),
                    fields.Datetime.from_string(end.name))
        else:
            self.get_working_hours = 0.0 
开发者ID:vertelab,项目名称:odoo-payroll,代码行数:12,代码来源:hr_payroll.py


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