コード例 #1
0
 def _onchange_journal_id(self):
     if self.journal_id:
         session = self.env['account.invoicing.session']
         session = session.search([('user_id', '=', self.env.user.id),
                                   ('state', '=', 'opened'),
                                   ('journal_id', '=', self.journal_id.id)])
         if session:
             self.invoicing_session_ids = session[0]
         else:
             self.invoicing_session_ids = session
             journal = self.journal_id
             if journal.require_invoicing_session and len(session) == 0:
                 journal_type = journal.type
                 if journal_type == 'purchase':
                     action = self.env.ref(
                         'account_invoicing_session.purchase_list_action')
                     raise exceptions.RedirectWarning(
                         _('At least one purchase session should be open for this user.'
                           ), action.id, _('Go to the sessions menu'))
                 if journal_type == 'sale':
                     action = self.env.ref(
                         'account_invoicing_session.sale_list_action')
                     raise exceptions.RedirectWarning(
                         _('At least one sale session should be open for this user.'
                           ), action.id, _('Go to the sessions menu'))
コード例 #2
0
ファイル: google_management.py プロジェクト: xhair/enterprise
 def create_an_experiment(self, data, website_id):
     gs_pool = self.env['google.service']
     website = self.env['website'].browse(website_id)[0]
     webPropertyId = website.google_analytics_key
     action_id = self.env['ir.model.data'].xmlid_to_res_id(
         'website_version.action_website_view')
     if not webPropertyId:
         raise exceptions.RedirectWarning(
             'Click on the website you want to make A/B testing and configure the Google Analytics Key and View ID',
             action_id, 'go to the websites menu')
     accountId = webPropertyId.split('-')[1]
     profileId = website.google_analytics_view_id
     if not profileId:
         raise exceptions.RedirectWarning(
             'Click on the website you want to make A/B testing and configure the Google Analytics Key and View ID',
             action_id, 'go to the websites menu')
     url = '/analytics/v3/management/accounts/%s/webproperties/%s/profiles/%s/experiments?access_token=%s' % (
         accountId, webPropertyId, profileId, self.get_token())
     headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
     data_json = json.dumps(data)
     try:
         x = gs_pool._do_request(url, data_json, headers, type='POST')
         result = x[1]['id']
     except Exception, e:
         _logger.info(
             _('An exception occured during the google analytics request: %s'
               ) % e)
         raise
コード例 #3
0
ファイル: res_users.py プロジェクト: yjiang-dev/odoo
    def create(self, vals_list):
        for values in vals_list:
            if not values.get('login', False):
                action = self.env.ref('base.action_res_users')
                msg = _(
                    "You cannot create a new user from here.\n To create new user please go to configuration panel."
                )
                raise exceptions.RedirectWarning(
                    msg, action.id, _('Go to the configuration panel'))

        users = super(Users, self).create(vals_list)

        # log a portal status change (manual tracking)
        log_portal_access = not self._context.get(
            'mail_create_nolog') and not self._context.get('mail_notrack')
        if log_portal_access:
            for user in users:
                if user.has_group('base.group_portal'):
                    body = user._get_portal_access_update_body(True)
                    user.partner_id.message_post(body=body,
                                                 message_type='notification',
                                                 subtype_xmlid='mail.mt_note')
        # Auto-subscribe to channels unless skip explicitly requested
        if not self.env.context.get('mail_channel_nosubscribe'):
            self.env['mail.channel'].search([
                ('group_ids', 'in', users.groups_id.ids)
            ])._subscribe_users_automatically()
        return users
コード例 #4
0
    def btn_insert_branches(self):
        b01 = self.env['bn.2dfire.branchs'].search_bycode(self.entityId)
        if not b01:
            appids = self.env['bn.2dfire.appid'].search([('code', '=', 'hq-it')
                                                         ]).id
            companyids = self.env.user.company_id.id

            branch_ids = self.env['bn.2dfire.branchs'].create({
                'code':
                self.entityId,
                'name':
                self.name,
                'appids':
                appids,
                'company_id':
                companyids
            })

            action = {
                'type': 'ir.actions.act_window',
                'view_mode': 'form',
                "views": [[False, "form"]],
                'res_model': 'bn.2dfire.branchs',
                'res_id': branch_ids.id,
                'target': 'new',
            }

            self.write({'isAdd': True})
            return action
        else:
            raise exceptions.RedirectWarning("该门店已经加入同步列表")
コード例 #5
0
    def create(self, values):
        if not values.get('login', False):
            action = self.env.ref('base.action_res_users')
            msg = _(
                "You cannot create a new user from here.\n To create new user please go to configuration panel."
            )
            raise exceptions.RedirectWarning(
                msg, action.id, _('Go to the configuration panel'))

        user = super(b2b_res_users, self).create(values)

        #############################################
        # 商户创建的账号要关联商户
        distributor = self.env.user.partner_id.parent_id or self.env.user.partner_id
        if not distributor:
            raise UserError(u'未找到您所属的经销商,请联系平台管理员')
        # if values.get('type', False) in ('shop', 'operator', 'warehouse'):
        if user.type in ('shop', 'operator', 'warehouse'):
            user.partner_id.parent_id = distributor
        #############################################

        # create a welcome message
        user._create_welcome_message()

        return user
コード例 #6
0
 def _getAnalyticJournal(self):
     emp_obj = self.env['hr.employee']
     context = {}
     if context.get('employee_id'):
         emp_id = [context.get('employee_id')]
     else:
         emp_id = emp_obj.search(
             [('user_id', '=', context.get('user_id') or self._uid)],
             limit=1)
     if not emp_id:
         model, action_id = self.env['ir.model.data'].get_object_reference(
             'hr', 'open_view_employee_list_my')
         msg = _(
             "Employee is not created for this user. Please create one from configuration panel."
         )
         raise exceptions.RedirectWarning(
             msg, action_id, _('Go to the configuration panel'))
     emp = emp_obj.browse(emp_id[0])
     if emp.journal_id:
         return emp.journal_id.id
     else:
         raise exceptions.Warning(
             _('Warning!'),
             _('No analytic journal defined for \'%s\'.\nYou should assign an analytic journal on the employee form.'
               ) % (emp.name))
コード例 #7
0
    def create(self, values):
        if not values.get('login', False):
            action = self.env.ref('base.action_res_users')
            msg = _("You cannot create a new user from here.\n To create new user please go to configuration panel.")
            raise exceptions.RedirectWarning(msg, action.id, _('Go to the configuration panel'))

        user = super(Users, self).create(values)
        # Auto-subscribe to channels
        self.env['mail.channel'].search([('group_ids', 'in', user.groups_id.ids)])._subscribe_users()
        return user
コード例 #8
0
    def create(self, values):
        if not values.get('login', False):
            action = self.env.ref('base.action_res_users')
            msg = _(
                "You cannot create a new user from here.\n To create new user please go to configuration panel."
            )
            raise exceptions.RedirectWarning(
                msg, action.id, _('Go to the configuration panel'))

        return super(Users, self).create(values)
コード例 #9
0
ファイル: res_users.py プロジェクト: veivaa/odoo
    def create(self, vals_list):
        for values in vals_list:
            if not values.get('login', False):
                action = self.env.ref('base.action_res_users')
                msg = _(
                    "You cannot create a new user from here.\n To create new user please go to configuration panel."
                )
                raise exceptions.RedirectWarning(
                    msg, action.id, _('Go to the configuration panel'))

        users = super(Users, self).create(vals_list)
        # Auto-subscribe to channels unless skip explicitly requested
        if not self.env.context.get('mail_channel_nosubscribe'):
            self.env['mail.channel'].search([
                ('group_ids', 'in', users.groups_id.ids)
            ])._subscribe_users_automatically()
        return users
コード例 #10
0
 def sync_2dfire_interface_v20(self):
     MY_URL = self.env['bn.2dfire.url'].search([('code', '=', 'menulistv20')])
     stores = self.env['bn.2dfire.branchs'].get_vaild_branchs()
     tmp_data=[]
     for store in stores:
         appid = store['appids']
         para = {
             'para_my_url': MY_URL,
             'para_my_appid': appid,
             'para_my_store': store,
             'para_connection': self,
         }
         recordset = bn_2dfire_connect_api(para).Get_ResultAll_ProductMenu()
         if recordset is not None:
             if 'data' in recordset:
                 tmp_data.append(recordset['data']['data'])
     raise exceptions.RedirectWarning(json.dumps(tmp_data, sort_keys=True, indent=2,ensure_ascii=False))
     return True
コード例 #11
0
    def action_confirm(self):

        if self.partner_id.credit_limit != 0:
            if self.partner_id.credit + self.amount_total > self.partner_id.credit_limit:
                if self.payment_term_id.name != 'Immediate Payment':
                    if self.permitted_credit_limit is not True:
                        self.avisado = True
                        raise exceptions.RedirectWarning(
                            'Este cliente ha exedido el limite de credito. Su limite actual es: '
                            + str(self.partner_id.credit_limit) +
                            ', actualmente tiene una deuda de: ' +
                            str(self.partner_id.credit) +
                            ' y disponible tiene ' +
                            str(self.partner_id.credit_available) +
                            ', debe que autorizar el limite de credito excedido'
                        )

        res = super(CreditLimitAlertSaleOrder, self).action_confirm()

        return res
コード例 #12
0
 def _company_warning(self, translated_msg):
     """ Raise a error with custom message, asking user to configure company settings """
     raise exceptions.RedirectWarning(
         translated_msg,
         self.env.ref('base.action_res_company_form').id,
         _('Go to company configuration screen'))
コード例 #13
0
 def mixin_redirect_to(self, action_id, button_title, message):
     action = self.env.ref(action_id)
     raise exceptions.RedirectWarning(message, action.id, button_title)