• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python access.get_active_user函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中netforce.access.get_active_user函数的典型用法代码示例。如果您正苦于以下问题:Python get_active_user函数的具体用法?Python get_active_user怎么用?Python get_active_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: send_email

 def send_email(self, ids, context={}):
     uid = access.get_active_user()
     try:
         access.set_active_user(1)
         obj = self.browse(ids[0])
         # XXX "=" should be changed to "=ilike" later
         res = get_model("base.user").search((["email", "=ilike", obj.email.strip()]))
         if not res:
             raise Exception("User with given email doesn't exist in database")
         request = context["request"]
         msg = "Somebody requested change of your Netforce password.\n\n"
         msg += "If you didn't do it, please ignore this message.\n\n"
         msg += "Otherwise if you want to reset your password click on the link below:\n\n"
         msg += "http://%s/ui#name=change_passwd&key=%s\n\n\n" % (request.host, obj.key)
         msg += "Regards,\n"
         msg += "Netforce Team"
         vals = {
             "type": "out",
             "from_addr": "[email protected]",
             "to_addrs": obj.email,
             "subject": "Netforce reset password request",
             "body": msg,
             "state": "to_send",
         }
         get_model("email.message").create(vals)
         return {
             "next": {
                 "name": "forgot_passwd_done"
             }
         }
     finally:
         access.set_active_user(uid)
开发者ID:Sorawit123,项目名称:netforce,代码行数:32,代码来源:forgot_passwd.py


示例2: approve

 def approve(self, ids, context={}):
     if not check_permission_other("production_safe_in"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {"next": {"name": "barcode_safe_in", "active_id": obj.id}, "flash": "DC to safe approved successfully"}
开发者ID:jzoldyck,项目名称:netforce,代码行数:7,代码来源:barcode_safe_in.py


示例3: create

 def create(self, vals, **kw):
     uid = access.get_active_user()
     try:
         access.set_active_user(1)
         return super().create(vals, **kw)
     finally:
         access.set_active_user(uid)
开发者ID:Sorawit123,项目名称:netforce,代码行数:7,代码来源:forgot_passwd.py


示例4: default_get

 def default_get(self, field_names=None, context=None, **kw):
     user_id = get_active_user()
     set_active_user(1)
     user = get_model("base.user").browse(user_id)
     vals = {"name": user.name, "password": user.password, "email": user.email, "mobile": user.mobile}
     set_active_user(user_id)
     return vals
开发者ID:jzoldyck,项目名称:netforce,代码行数:7,代码来源:user_pref.py


示例5: create

 def create(self,vals,*args,**kw):
     new_id=super().create(vals,*args,**kw)
     obj=self.browse(new_id)
     user_id=access.get_active_user()
     user=get_model("base.user").browse(user_id)
     if obj.related_id._model=="issue":
         issue=obj.related_id
         project=issue.project_id
         contact=issue.contact_id
         emails=issue.get_email_addresses()
         subject="New message by %s for issue %s"%(user.name,issue.number)
         if obj.subject:
             subject+=": %s"%obj.subject
         if emails:
             vals={
                 "from_addr": "[email protected]", # XXX
                 "to_addrs": ",".join(emails),
                 "subject": subject,
                 "body": obj.body,
                 "state": "to_send",
                 "name_id": "contact,%s"%contact.id,
                 "related_id": "issue,%s"%issue.id,
             }
             get_model("email.message").create(vals)
     return new_id
开发者ID:Sorawit123,项目名称:netforce,代码行数:25,代码来源:message.py


示例6: _get_number

 def _get_number(self, context={}):
     user_id = get_active_user()
     set_active_user(1)
     seq_id = get_model("sequence").find_sequence(type="leave_request")
     if not seq_id:
         return None
     while 1:
         num = get_model("sequence").get_next_number(seq_id)
         user_id = get_active_user()
         set_active_user(1)
         res = self.search([["number", "=", num]])
         set_active_user(user_id)
         if not res:
             return num
         get_model("sequence").increment_number(seq_id)
     set_active_user(user_id)
开发者ID:Sorawit123,项目名称:netforce,代码行数:16,代码来源:hr_leave.py


示例7: get

 def get(self):
     db = get_connection()
     try:
         cart_id = int(self.get_argument("cart_id"))
         print("cart_id", cart_id)
         cart = get_model("ecom.cart").browse(cart_id)
         set_active_company(1)
         user_id = get_active_user()
         website = self.context["website"]
         ctx = self.context
         ctx["cart"] = cart
         if not cart.is_paid and website.payment_slip_template_id and (cart.pay_method_id.id == website.bank_method_id.id):
             tmpl_name = website.payment_slip_template_id.name
             url = "/report?type=report_jasper&model=ecom.cart&convert=pdf&ids=[%d]&template=%s" % (
                 cart.id, tmpl_name)
             ctx["payment_slip_report_url"] = url
         content = render("ecom_order_confirmed", ctx)
         ctx["content"] = content
         html = render("cms_layout", ctx)
         self.write(html)
         db.commit()
     except:
         import traceback
         traceback.print_exc()
         db.rollback()
开发者ID:Sorawit123,项目名称:netforce,代码行数:25,代码来源:ecom_order_confirmed.py


示例8: get_open_dummy

 def get_open_dummy(self, ids, context={}):
     vals = {}
     user_id = get_active_user()
     for obj in self.browse(ids):
         if user_id == obj.to_id.id:
             obj.write({"state": "opened"})
         vals[obj.id] = True
     return vals
开发者ID:Sorawit123,项目名称:netforce,代码行数:8,代码来源:message.py


示例9: get_default

 def get_default(self, model, field, context={}):
     user_id = get_active_user()
     res = self.search([["user_id", "=", user_id], ["model", "=", model], ["field", "=", field]])
     if not res:
         return None
     obj_id = res[0]
     obj = self.browse(obj_id)
     return obj.value
开发者ID:Sorawit123,项目名称:netforce,代码行数:8,代码来源:field_default.py


示例10: pending

 def pending(self, ids, context={}):
     user_id = get_active_user()
     for obj in self.browse(ids):
         for move in obj.lines:
             move.write({"state": "pending", "date": obj.date})
             if obj.related_id and not move.related_id:
                 move.write({"related_id":"%s,%d"%(obj.related_id._model,obj.related_id.id)})
         obj.write({"state": "pending", "pending_by_id": user_id})
开发者ID:oncedayly,项目名称:netforce,代码行数:8,代码来源:stock_picking.py


示例11: delete

 def delete(self, ids, **kw):
     prod_ids = []
     for obj in self.browse(ids):
         prod_ids.append(obj.product_id.id)
     super().delete(ids, **kw)
     user_id = get_active_user()
     set_active_user(1)
     get_model("product").write(prod_ids, {"update_balance": True})
     set_active_user(user_id)
开发者ID:bank-netforce,项目名称:netforce,代码行数:9,代码来源:stock_move.py


示例12: save_changes

 def save_changes(self, ids, context={}):
     obj = self.browse(ids)[0]
     check_password(obj.password)
     vals = {"name": obj.name, "password": obj.password, "email": obj.email, "mobile": obj.mobile}
     user_id = get_active_user()
     set_active_user(1)
     get_model("base.user").write([user_id], vals)
     obj.write({"password": ""})
     set_active_user(user_id)
     return {"next": "_close"}
开发者ID:jzoldyck,项目名称:netforce,代码行数:10,代码来源:user_pref.py


示例13: approve

 def approve(self, ids, context={}):
     if not check_permission_other("sale_approve_done"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {
         "next": {"name": "sale", "mode": "form", "active_id": obj.id},
         "flash": "Sales order approved successfully",
     }
开发者ID:jzoldyck,项目名称:netforce,代码行数:10,代码来源:sale_return.py


示例14: reject

 def reject(self, ids, context={}):
     user_id = get_active_user()
     user = get_model("base.user").browse(user_id)
     obj = self.browse(ids)[0]
     obj.write({"state": "canceled"})
     vals = {
         "related_id": "room.reserve,%s" % obj.id,
         "body": "Rejected by %s" % user.name,
     }
     get_model("message").create(vals)
开发者ID:Sorawit123,项目名称:netforce,代码行数:10,代码来源:room_reserve.py


示例15: migrate

 def migrate(self):
     user_id=get_active_user()
     set_active_user(1)
     for leave in get_model("hr.leave").search_browse([]):
         if leave.time_from and leave.time_to:
             leave.write({
                 'start_date': '%s %s:00'%(leave.start_date[0:10],leave.time_from.replace(".",":")),
                 'end_date': '%s %s:00'%(leave.end_date[0:10],leave.time_to.replace(".",":")),
             })
     set_active_user(user_id)
开发者ID:Sorawit123,项目名称:netforce,代码行数:10,代码来源:improve_leave.py


示例16: migrate

 def migrate(self):
     user_id = get_active_user()
     set_active_user(1)
     for payslip in get_model("hr.payslip").search_browse([]):
         if not payslip.state:
             payslip.write({"state": "draft"})
     for payrun in get_model("hr.payrun").search_browse([]):
         if not payrun.state:
             payrun.write({"state": "draft"})
     set_active_user(user_id)
开发者ID:jzoldyck,项目名称:netforce,代码行数:10,代码来源:improve_payroll.py


示例17: set_default

 def set_default(self, model, field, value, context={}):
     self.clear_default(model, field)
     user_id = get_active_user()
     vals = {
         "user_id": user_id,
         "model": model,
         "field": field,
         "value": value,
     }
     self.create(vals)
开发者ID:Sorawit123,项目名称:netforce,代码行数:10,代码来源:field_default.py


示例18: _get_number

 def _get_number(self, context={}):
     while 1:
         num = get_model("sequence").get_number(type="job")
         if not num:
             return None
         user_id = get_active_user()
         set_active_user(1)
         res = self.search([["number", "=", num]])
         set_active_user(user_id)
         if not res:
             return num
         get_model("sequence").increment(type="job")
开发者ID:Sorawit123,项目名称:netforce,代码行数:12,代码来源:job.py


示例19: allow_record

 def allow_record(self, context={}):
     user_id=get_active_user()
     user=get_model("base.user").browse(user_id)
     limit=user.limit_inspect or 0
     res=self.search_browse([['user_id','=',user_id]])
     if res:
         obj=res[0]
         count=obj.record_count+1
         if count > limit:
             return False, limit, count
     count=self.increase()
     return True, limit, count
开发者ID:watcharapon,项目名称:netforce_inspect,代码行数:12,代码来源:limit_inspect.py


示例20: approve

 def approve(self, ids, context={}):
     if not check_permission_other("stock_transfer"):
         raise Exception("Permission denied")
     obj = self.browse(ids)[0]
     user_id = get_active_user()
     obj.write({"approved_by_id": user_id})
     return {
         "next": {
             "name": "barcode_transfer",
             "active_id": obj.id,
         },
         "flash": "Stock transfer approved successfully",
     }
开发者ID:Sorawit123,项目名称:netforce,代码行数:13,代码来源:barcode_transfer.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python access.set_active_user函数代码示例发布时间:2022-05-27
下一篇:
Python access.get_active_company函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap