コード例 #1
0
    def new_database(self, **post):
        if not request.session.uid:
            return login_redirect()
        plan_id = int(post.get('plan_id'))

        res = self.create_new_database(plan_id)
        return request.redirect(res.get('url'))
コード例 #2
0
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        js_list = manifest_list('js', db=request.db, debug=debug)
        css_list = manifest_list('css', db=request.db, debug=debug)

        js = "\n".join('<script type="text/javascript" src="%s"></script>' % i
                       for i in js_list)
        #css = "\n".join('<link rel="stylesheet" href="%s">' % i for i in css_list)
        r = html_template % {
            'js':
            js,
            #   'css': css,
            'modules':
            simplejson.dumps(module_boot(request.db)),
            'init':
            """
                     var wc = new s.web.WebClient();
                     wc.show_application = function(){
                         wc.action_manager.do_action("pos.ui");
                     };
                     wc.appendTo($(document.body));
                     """
        }
        return r
コード例 #3
0
ファイル: main.py プロジェクト: Cywaithaka/point_of_sale
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        if not session.uid:
            return login_redirect()

        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context)
        if not pos_session_ids:
            return werkzeug.utils.redirect('/web#action=point_of_sale.action_pos_session_opening')
        PosSession.login(cr,uid,pos_session_ids,context=context)
        
        modules =  simplejson.dumps(module_boot(request.db))
        init =  """
                 var wc = new s.web.WebClient();
                 wc.show_application = function(){
                     wc.action_manager.do_action("pos.ui");
                 };
                 wc.setElement($(document.body));
                 wc.start();
                 """

        html = request.registry.get('ir.ui.view').render(cr, session.uid,'point_of_sale.index',{
            'modules': modules,
            'init': init,
        })

        return html
コード例 #4
0
ファイル: main.py プロジェクト: kingyond/odoo
    def post_create(self, forum, post_parent=None, post_type=None, **post):
        cr, uid, context = request.cr, request.uid, request.context
        if not request.session.uid:
            return login_redirect()

        post_tag_ids = []
        Tag = request.env['forum.tag']
        if post.get('post_tags', False) and post.get('post_tags').strip('[]'):
            tags = post.get('post_tags').strip('[]').replace('"', '').split(",")
            for tag in tags:
                tag_rec = Tag.search([('name', '=', tag)])
                if tag_rec:
                    post_tag_ids.append((4, tag_rec.id))
                else:
                    post_tag_ids.append((0, 0, {'name': tag, 'forum_id': forum.id}))

        new_question = request.env['forum.post'].create({
            'forum_id': forum.id,
            'name': post.get('post_name', ''),
            'content': post.get('content', False),
            'content_link': post.get('content_link', False),
            'parent_id': post_parent and post_parent.id or False,
            'tag_ids': post_tag_ids,
            'post_type': post_parent and post_parent.post_type or post_type,  # tde check in selection field
        })
        return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), post_parent and slug(post_parent) or new_question.id))
コード例 #5
0
 def blog_post_comment(self, blog_post_id=0, **kw):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     if kw.get('comment'):
         self._blog_post_message(blog_post_id, kw.get('comment'), **kw)
     blog_post = request.registry['blog.post'].browse(cr, uid, blog_post_id, context=context)
     return werkzeug.utils.redirect("/blog/%s/post/%s#comments" % (slug(blog_post.blog_id), slug(blog_post)))
コード例 #6
0
ファイル: main.py プロジェクト: pramodjamkar/odoo
 def blog_post_comment(self, blog_post_id=0, **kw):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     if kw.get('comment'):
         self._blog_post_message(blog_post_id, kw.get('comment'), **kw)
     blog_post = request.registry['blog.post'].browse(cr, uid, blog_post_id, context=context)
     return werkzeug.utils.redirect("/blog/%s/post/%s#comments" % (slug(blog_post.blog_id), slug(blog_post)))
コード例 #7
0
ファイル: main.py プロジェクト: CalvinJameson/odoo
 def forum_post(self, forum, post_type, **post):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     user = request.registry['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
     if not user.email or not tools.single_email_re.match(user.email):
         return werkzeug.utils.redirect("/forum/%s/user/%s/edit?email_required=1" % (slug(forum), uid))
     values = self._prepare_forum_values(forum=forum, searches={},  header={'ask_hide': True})
     return request.website.render("website_forum.%s" % post_type, values)
コード例 #8
0
 def post_new(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     request.registry['forum.post'].create(
         request.cr, request.uid, {
             'forum_id': forum.id,
             'parent_id': post.id,
             'content': kwargs.get('content'),
         }, context=request.context)
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
コード例 #9
0
ファイル: main.py プロジェクト: odoousers2014/odoo
 def post_comment(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     question = post.parent_id if post.parent_id else post
     if kwargs.get("comment") and post.forum_id.id == forum.id:
         # TDE FIXME: check that post_id is the question or one of its answers
         post.with_context(mail_create_nosubscribe=True).message_post(
             body=kwargs.get("comment"), type="comment", subtype="mt_comment"
         )
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
コード例 #10
0
ファイル: main.py プロジェクト: Alan1590/odoo-1
 def post_new(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     request.registry['forum.post'].create(
         request.cr, request.uid, {
             'forum_id': forum.id,
             'parent_id': post.id,
             'content': kwargs.get('content'),
         }, context=request.context)
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
コード例 #11
0
ファイル: main.py プロジェクト: nel-odoo/odoo
 def post_new(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     request.registry["forum.post"].create(
         request.cr,
         request.uid,
         {"forum_id": forum.id, "parent_id": post.id, "content": kwargs.get("content")},
         context=request.context,
     )
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
コード例 #12
0
ファイル: main.py プロジェクト: felixvillafranca/odoo
 def forum_post(self, forum, post_type=None, **post):
     if not request.session.uid:
         return login_redirect()
     user = request.env.user
     if post_type not in ['question', 'link', 'discussion']:  # fixme: make dynamic
         return werkzeug.utils.redirect('/forum/%s' % slug(forum))
     if not user.email or not tools.single_email_re.match(user.email):
         return werkzeug.utils.redirect("/forum/%s/user/%s/edit?email_required=1" % (slug(forum), request.session.uid))
     values = self._prepare_forum_values(forum=forum, searches={}, header={'ask_hide': True})
     return request.website.render("website_forum.new_%s" % post_type, values)
コード例 #13
0
ファイル: main.py プロジェクト: 0k/odoo
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        if not session.uid:
            return login_redirect()

        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context)
        PosSession.login(cr, uid, pos_session_ids, context=context)
        
        return request.render('point_of_sale.index')
コード例 #14
0
    def blog_post_comment(self, blog_post_id=0, **post):
        cr, uid, context = request.cr, request.uid, request.context
        if not request.session.uid:
            return login_redirect()
        if post.get('comment'):

            user = request.registry['res.users'].browse(cr, uid, uid, context=context)
            blog_post = request.registry['blog.post']
            blog_post.check_access_rights(cr, uid, 'read')
            self._blog_post_message(user, blog_post_id, **post)
        blog_post = request.registry['blog.post'].browse(cr, uid, int(blog_post_id), context=context)
        return werkzeug.utils.redirect("/blog/%s/post/%s#comments" % (slug(blog_post.blog_id), slug(blog_post)))
コード例 #15
0
ファイル: main.py プロジェクト: Bric91/odoo
 def post_comment(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     question = post.parent_id if post.parent_id else post
     cr, uid, context = request.cr, request.uid, request.context
     if kwargs.get('comment') and post.forum_id.id == forum.id:
         # TDE FIXME: check that post_id is the question or one of its answers
         request.registry['forum.post']._post_comment(
             cr, uid, post,
             body=kwargs.get('comment'),
             context=context)
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
コード例 #16
0
ファイル: main.py プロジェクト: RandikaAriyasena/odoo
 def product_comment(self, product_template_id, **post):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     if post.get('comment'):
         request.registry['product.template'].message_post(
             cr, uid, product_template_id,
             body=post.get('comment'),
             message_type='comment',
             subtype='mt_comment',
             context=dict(context, mail_create_nosubscribe=True))
     return werkzeug.utils.redirect('/shop/product/%s#comments' % product_template_id)
コード例 #17
0
ファイル: main.py プロジェクト: 0k/odoo
 def post_comment(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     question = post.parent_id if post.parent_id else post
     cr, uid, context = request.cr, request.uid, request.context
     if kwargs.get('comment') and post.forum_id.id == forum.id:
         # TDE FIXME: check that post_id is the question or one of its answers
         request.registry['forum.post'].message_post(
             cr, uid, post.id,
             body=kwargs.get('comment'),
             type='comment',
             subtype='mt_comment',
             context=dict(context, mail_create_nosubcribe=True))
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
コード例 #18
0
ファイル: main.py プロジェクト: 0k/odoo
 def post_new(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     user = request.registry['res.users'].browse(cr, SUPERUSER_ID, uid, context=context)
     if not user.email or not tools.single_email_re.match(user.email):
         return werkzeug.utils.redirect("/forum/%s/user/%s/edit?email_required=1" % (slug(forum), uid))
     request.registry['forum.post'].create(
         request.cr, request.uid, {
             'forum_id': forum.id,
             'parent_id': post.id,
             'content': kwargs.get('content'),
         }, context=request.context)
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(post)))
コード例 #19
0
ファイル: main.py プロジェクト: 7Gates/odoo
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        # if user not logged in, log him in
        if not session.uid:
            return login_redirect()

        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context)
        if not pos_session_ids:
            return werkzeug.utils.redirect('/web#action=point_of_sale.action_pos_session_opening')
        PosSession.login(cr, uid, pos_session_ids, context=context)
        
        return request.render('point_of_sale.index')
コード例 #20
0
 def post_comment(self, forum, post, **kwargs):
     if not request.session.uid:
         return login_redirect()
     question = post.parent_id if post.parent_id else post
     cr, uid, context = request.cr, request.uid, request.context
     if kwargs.get('comment') and post.forum_id.id == forum.id:
         # TDE FIXME: check that post_id is the question or one of its answers
         request.registry['forum.post'].message_post(
             cr, uid, post.id,
             body=kwargs.get('comment'),
             type='comment',
             subtype='mt_comment',
             context=dict(context, mail_create_nosubcribe=True))
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), slug(question)))
コード例 #21
0
ファイル: main.py プロジェクト: felixvillafranca/odoo
 def post_create(self, forum, post_parent=None, post_type=None, **post):
     if not request.session.uid:
         return login_redirect()
     post_tag_ids = forum._tag_to_write_vals(post.get('post_tags', ''))
     new_question = request.env['forum.post'].create({
         'forum_id': forum.id,
         'name': post.get('post_name', ''),
         'content': post.get('content', False),
         'content_link': post.get('content_link', False),
         'parent_id': post_parent and post_parent.id or False,
         'tag_ids': post_tag_ids,
         'post_type': post_parent and post_parent.post_type or post_type,  # tde check in selection field
     })
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), post_parent and slug(post_parent) or new_question.id))
コード例 #22
0
 def forum_post(self, forum, post_type, **post):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     user = request.registry['res.users'].browse(cr,
                                                 SUPERUSER_ID,
                                                 uid,
                                                 context=context)
     if not user.email or not tools.single_email_re.match(user.email):
         return werkzeug.utils.redirect(
             "/forum/%s/user/%s/edit?email_required=1" % (slug(forum), uid))
     values = self._prepare_forum_values(forum=forum,
                                         searches={},
                                         header={'ask_hide': True})
     return request.website.render("website_forum.%s" % post_type, values)
コード例 #23
0
ファイル: main.py プロジェクト: CamiloRamirez90/RosArduino
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        if not session.uid:
            return login_redirect()

        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr,
                                            uid,
                                            [('state', '=', 'opened'),
                                             ('user_id', '=', session.uid)],
                                            context=context)
        PosSession.login(cr, uid, pos_session_ids, context=context)

        return request.render('point_of_sale.index')
コード例 #24
0
    def a(self, binary, tipo, **k):

        cr, uid, context, session = request.cr, request.uid, request.context, request.session
        print str(
            k
        ) + "---------------------------------------------------------------------------------------------------------------------\
        ---------------------------------------------------------------------------------------------------------------"

        if not session.uid:
            return login_redirect()

        #modelo_registro = request.registry['rbs.documento.mercantil.'+k['tipo']]
        #registro_ids = registro.search(cr, uid, [('id','=',)], context=context)
        #registro = modelo_registro.browse(cr,uid,[1,],context = context)
        #data = registro.filedata
        #tiffstack = Image.open(BytesIO(base64.b64decode(data)))
        #tiffstack.load()

        #tiffstack.show()
        '''buffer = cStringIO.StringIO()
        
        tiffstack.seek(0)
        for l in range(tiffstack.n_frames):
            
            #tiffstack.show()
        
            tiffstack.save(buffer, format="JPEG")
            img_str = base64.b64encode(buffer.getvalue())
            init +="document.getElementById('img').setAttribute( 'src', 'data:image/png;base64,"+img_str+"' );\n"
        '''

        #PosSession = request.registry['pos.session']
        #pos_session_ids = PosSession.search(cr, uid, [('state','=','opened'),('user_id','=',session.uid)], context=context)
        #if not pos_session_ids:
        #    return werkzeug.utils.redirect('/web#action=web_tiff_widget.action_pos_session_opening')
        #PosSession.login(cr,uid,pos_session_ids,context=context)

        modules = simplejson.dumps(module_boot(request.db))
        print modules
        init = "var tiff = TifWIdget('" + tipo + "'," + binary + ");"

        html = request.registry.get('ir.ui.view').render(
            cr, session.uid, 'web_tiff_widget.TiffEditWidget', {
                'init': init,
                'modules': modules,
            })

        return html
コード例 #25
0
ファイル: main.py プロジェクト: DarkGreising/odoo
 def post_create(self, forum, post_parent=None, post_type=None, **post):
     if not request.session.uid:
         return login_redirect()
     if post_type == 'question' and not post.get('post_name', '').strip():
         return request.website.render('website.http_error', {'status_code': _('Bad Request'), 'status_message': _('Title should not be empty.')})
     post_tag_ids = forum._tag_to_write_vals(post.get('post_tags', ''))
     new_question = request.env['forum.post'].create({
         'forum_id': forum.id,
         'name': post.get('post_name', ''),
         'content': post.get('content', False),
         'content_link': post.get('content_link', False),
         'parent_id': post_parent and post_parent.id or False,
         'tag_ids': post_tag_ids,
         'post_type': post_parent and post_parent.post_type or post_type,  # tde check in selection field
     })
     return werkzeug.utils.redirect("/forum/%s/question/%s" % (slug(forum), post_parent and slug(post_parent) or new_question.id))
コード例 #26
0
    def a(self, debug=True, **k):

        if not request.session.uid:
            return login_redirect()

        values = {
            'modules': simplejson.dumps(module_boot(request.db)),
            'init': """
                     var wc = new s.web.WebClient();
                     wc.show_application = function(){
                         wc.action_manager.do_action("pos.ui");
                     };
                     wc.appendTo($(document.body));
                     """
        }
        return request.render('point_of_sale_debug.web', values)
コード例 #27
0
 def product_comment(self, product_template_id, **post):                                          
     if not request.session.uid:            
         request.session.update({'comments':post.get('comment')})
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context        
     if post.get('comment') or request.session.has_key('comments') and request.session.comments!=None:            
         request.registry['product.template'].message_post(
             cr, uid, product_template_id,
             body=post.get('comment') or request.session.comments,
             type='comment',
             subtype='mt_comment',
             context=dict(context, mail_create_nosubscribe=True))
         if request.session.has_key('comments') and request.session.comments!=None:
             request.session.update({'comments':None})
             return werkzeug.utils.redirect('/shop/product/' +str(product_template_id)+ "#comments")        
     return werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
コード例 #28
0
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        r = html_template % {
            'modules': simplejson.dumps(module_boot(request.db)),
            'init': """
                     var wc = new s.web.WebClient();
                     wc.show_application = function(){
                         wc.action_manager.do_action("pos.ui");
                     };
                     wc.appendTo($(document.body));
                     """
        }
        return r
コード例 #29
0
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        r = html_template % {
            'modules': simplejson.dumps(module_boot(request.db)),
            'init': """
                     var wc = new s.web.WebClient();
                     wc.show_application = function(){
                         wc.action_manager.do_action("pos.ui");
                     };
                     wc.appendTo($(document.body));
                     """
        }
        return r
コード例 #30
0
ファイル: main.py プロジェクト: odoousers2014/odoo
 def post_create(self, forum, post_parent=None, post_type=None, **post):
     if not request.session.uid:
         return login_redirect()
     post_tag_ids = forum._tag_to_write_vals(post.get("post_tags", ""))
     new_question = request.env["forum.post"].create(
         {
             "forum_id": forum.id,
             "name": post.get("post_name", ""),
             "content": post.get("content", False),
             "content_link": post.get("content_link", False),
             "parent_id": post_parent and post_parent.id or False,
             "tag_ids": post_tag_ids,
             "post_type": post_parent and post_parent.post_type or post_type,  # tde check in selection field
         }
     )
     return werkzeug.utils.redirect(
         "/forum/%s/question/%s" % (slug(forum), post_parent and slug(post_parent) or new_question.id)
     )
コード例 #31
0
ファイル: main.py プロジェクト: meswapnilwagh/odoo-adr
 def product_comment(self, product_template_id, **post):
     if not request.session.uid:
         return login_redirect()
     cr, uid, context = request.cr, request.uid, request.context
     if post.get('comment'):
         mid = request.registry['product.template'].message_post(
             cr, uid, product_template_id,
             body=post.get('comment'),
             type='comment',
             subtype='mt_comment',
             context=dict(context, mail_create_nosubscribe=True))
     if post.get('rating'):
         data = {
             'rating': int(post.get('rating')),
         }
         request.registry['mail.message'].write(cr, uid, [mid], data,
                                                context)
     r = werkzeug.utils.redirect(request.httprequest.referrer + "#comments")
     return r
コード例 #32
0
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        # if user not logged in, log him in
        if not session.uid:
            return login_redirect()

        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr,
                                            uid,
                                            [('state', '=', 'opened'),
                                             ('user_id', '=', session.uid)],
                                            context=context)
        if not pos_session_ids:
            return werkzeug.utils.redirect(
                '/web#action=point_of_sale.action_pos_session_opening')
        PosSession.login(cr, uid, pos_session_ids, context=context)

        return request.render('point_of_sale.index')
コード例 #33
0
ファイル: main.py プロジェクト: kahihia/earlyphant-odoo-8
    def blog_post_comment(self, blog_post_id=0, **post):
        cr, uid, context = request.cr, request.uid, request.context
        if not request.session.uid:
            return login_redirect()
        if post.get('comment'):

            user = request.registry['res.users'].browse(cr,
                                                        uid,
                                                        uid,
                                                        context=context)
            blog_post = request.registry['blog.post']
            blog_post.check_access_rights(cr, uid, 'read')
            self._blog_post_message(user, blog_post_id, **post)
        blog_post = request.registry['blog.post'].browse(cr,
                                                         uid,
                                                         int(blog_post_id),
                                                         context=context)
        return werkzeug.utils.redirect(
            "/blog/%s/post/%s#comments" %
            (slug(blog_post.blog_id), slug(blog_post)))
コード例 #34
0
ファイル: main.py プロジェクト: 3dfxmadscientist/odoo
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        modules =  simplejson.dumps(module_boot(request.db))
        init =  """
                 var wc = new s.web.WebClient();
                 wc.show_application = function(){
                     wc.action_manager.do_action("pos.ui");
                 };
                 wc.setElement($(document.body));
                 wc.start();
                 """

        html = request.registry.get('ir.ui.view').render(request.cr, request.session.uid,'point_of_sale.index',{
            'modules': modules,
            'init': init,
        })

        return html
コード例 #35
0
    def a(self, debug=False, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session

        if not session.uid:
            return login_redirect()

        PosSession = request.registry['pos.session']
        pos_session_ids = PosSession.search(cr,
                                            uid,
                                            [('state', '=', 'opened'),
                                             ('user_id', '=', session.uid)],
                                            context=context)
        if not pos_session_ids:
            return werkzeug.utils.redirect(
                '/web#action=point_of_sale.action_pos_session_opening')
        PosSession.login(cr, uid, pos_session_ids, context=context)

        modules = simplejson.dumps(module_boot(request.db))
        html = request.registry.get('ir.ui.view').render(
            cr, session.uid, 'point_of_sale.index', {'modules': modules})

        return html
コード例 #36
0
ファイル: main.py プロジェクト: Endika/openerp-addons
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        js_list = manifest_list('js',db=request.db, debug=debug)
        css_list =   manifest_list('css',db=request.db, debug=debug)
        
        js = "\n".join('<script type="text/javascript" src="%s"></script>' % i for i in js_list)
        #css = "\n".join('<link rel="stylesheet" href="%s">' % i for i in css_list)
        r = html_template % {
            'js': js,
         #   'css': css,
            'modules': simplejson.dumps(module_boot(request.db)),
            'init': """
                     var wc = new s.web.WebClient();
                     wc.show_application = function(){
                         wc.action_manager.do_action("pos.ui");
                     };
                     wc.appendTo($(document.body));
                     """
        }
        return r
コード例 #37
0
ファイル: main.py プロジェクト: ovnicraft/openerp-restaurant
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        js_list = manifest_list('js',db=request.db, debug=debug)
        js =  "\n".join('<script type="text/javascript" src="%s"></script>' % i for i in js_list)
        modules =  simplejson.dumps(module_boot(request.db))
        init =  """
                 var wc = new s.web.WebClient();
                 wc.show_application = function(){
                     wc.action_manager.do_action("pos.ui");
                 };
                 wc.appendTo($(document.body));
                 """

        html = request.registry.get('ir.ui.view').render(request.cr, request.session.uid,'point_of_sale.index',{
            'js': js,
            'modules': modules,
            'init': init,
            })

        return html
コード例 #38
0
    def a_s(self, **k):
        cr, uid, context, session = request.cr, request.uid, request.context, request.session
        print str(
            k
        ) + "---------------------------------------------------------------------------------------------------------------------\
        ---------------------------------------------------------------------------------------------------------------"

        if not session.uid:
            return login_redirect()

        modules = simplejson.dumps(module_boot(request.db))
        print modules
        #init ="var tiff = TifWIdget('"+tipo+"',"+binary+");"

        html = request.registry.get('ir.ui.view').render(
            cr,
            session.uid,
            'web_tiff_widget.TiffSeparator',
            {
                #   'init': init,
                'modules': modules,
            })

        return html
コード例 #39
0
ファイル: main.py プロジェクト: 0k/odoo
 def question_ask(self, forum, **post):
     if not request.session.uid:
         return login_redirect()
     values = self._prepare_forum_values(forum=forum, searches={},  header={'ask_hide': True})
     return request.website.render("website_forum.ask_question", values)
コード例 #40
0
ファイル: main.py プロジェクト: iresen-aap/addons
    def offers_apply(self,
                     offer=None,
                     next_stage=None,
                     submission=None,
                     is_new=None,
                     **post):

        #If no user connected, force connection
        #TODO: Redirect to submission page if offer variable is in session
        if not request.session.uid:
            request.session.update({'offer': offer.id})
            return login_redirect()

        #Get the candidate, if no candidate create one
        sudo_env = request.env(user=SUPERUSER_ID)
        env = request.env()
        candidate = env.user

        #Get the submission, if no submission call creation template
        if not submission:
            if request.session.get('submission'):
                submission = candidate.submissions.filtered(
                    lambda s: s.id == int(request.session.get('submission')))
            if not submission or is_new == 'new':
                submission = env['project.submission'].create({
                    'name':
                    '/',
                    'offer':
                    offer.id,
                    'candidate':
                    candidate.id,
                })
        error = {}
        request.session.update({'submission': submission.id})
        #Save the current stage
        current_stage = post.get('current_stage') and int(
            post.get('current_stage'))
        try:
            if bool(post) and post.get('submit') != 'cancel':
                if post.get('unlink-doc'):
                    #TODO: call with adequate access right. Sudo might e dangerous if the id passed is wrong
                    sudo_env['ir.attachment'].browse(
                        int(post.get('unlink-doc'))).unlink()
                if post.get('unlink-task'):
                    submission.tasks.filtered(lambda t: t.id == int(
                        post.get('unlink-task'))).unlink()
                if post.get('unlink-partner'):
                    submission.costs.filtered(lambda c: c.partner.id == int(
                        post.get('unlink-partner'))).unlink()
                    submission.write(
                        {'partners': [(3, int(post.get('unlink-partner')))]})
                    partner = sudo_env['res.partner'].browse(
                        int(post.get('unlink-partner')))
                    if not partner.submissions:
                        partner.unlink()
                if post.get('unlink-budgetline'):
                    env['project.submission.budgetline'].browse(
                        int(post.get('unlink-budgetline'))).unlink()
                #Stage 1: Project general informations
                if current_stage == 1:
                    value = {
                        'name':
                        post.get('name'),
                        'acronyme':
                        post.get('acronyme'),
                        'duration':
                        post.get('duration'),
                        'field_ids': [(6, 0, [
                            int(x)
                            for x in request.httprequest.form.getlist('fields')
                        ])],
                        'keywords':
                        post.get('keywords'),
                        'description':
                        post.get('description'),
                        'n_related_publications':
                        post.get('n_related_publications'),
                        'trl':
                        post.get('trl'),
                        'n_ing_doc':
                        post.get('n_ing_doc'),
                        'n_master_pfe':
                        post.get('n_master_pfe'),
                    }
                    submission.write(value)
                #Stage 2: Candidate general informations
                elif current_stage == 2:
                    value = {
                        'name': post.get('name'),
                        'function': post.get('function'),
                        'phone': post.get('phone'),
                        'mobile': post.get('mobile'),
                        'email': post.get('email'),
                    }
                    candidate.write(value)
                    if post.get('organisme'):
                        if candidate.parent_id:
                            candidate.parent_id.write(
                                {'name': post.get('organisme')})
                        else:
                            organisme = sudo_env['res.partner'].create(
                                {'name': post.get('organisme')})
                            candidate.write({'parent_id': organisme.id})
                    else:
                        if candidate.parent_id:
                            part = candidate.parent_id
                            candidate.parent_id = False
                            """try:
                                part.unlink()
                            except Exception:
                                pass"""
                    if post.get('inventor'):
                        inventor_value = {
                            'name': post.get('inventor'),
                            'phone': post.get('inventor_phone'),
                            'mobile': post.get('inventor_mobile'),
                            'email': post.get('inventor_email'),
                        }
                        if submission.inventor:
                            submission.inventor.write(inventor_value)
                        else:
                            inventor = sudo_env['res.partner'].create(
                                inventor_value)
                            submission.write({'inventor': inventor.id})
                    else:
                        if submission.inventor:
                            part = submission.inventor
                            submission.inventor = False
                            """try:
                                part.unlink()
                            except Exception:
                                pass"""
                    if post.get('ufile'):
                        for file in request.httprequest.files.getlist('ufile'):
                            attachment_value = {
                                'name': file.filename,
                                'res_name': value['name'],
                                'res_model': 'res.users',
                                'res_id': candidate.id,
                                'datas': base64.encodestring(file.read()),
                                'datas_fname': file.filename,
                            }
                            env['ir.attachment'].create(attachment_value)
                        candidate._get_attached_docs()

                #Stage 3: Project partners informations
                elif (current_stage == 3 or current_stage == 4
                      ) and post.get('to-save') == "1" and post.get('name'):
                    #partner_organisme = env['res.partner'].create({'name': post.get('organisme')})
                    category_id = False
                    if post.get('category_id'):
                        category_id = env['res.partner.category'].search([
                            ('name', '=', post.get('category_id'))
                        ])
                        if not category_id:
                            category_id = env['res.partner.category'].create(
                                {'name': post.get('category_id')})
                    partner_value = {
                        'name':
                        post.get('name') and post.get('name'),
                        'country_id':
                        post.get('partner_country')
                        and post.get('partner_country'),
                        'is_company':
                        True,
                        'city':
                        post.get('city') and post.get('city'),
                        'zip':
                        post.get('zip') and post.get('zip'),
                        'street':
                        post.get('street') and post.get('street'),
                        'street2':
                        post.get('street2') and post.get('street2'),
                        'email':
                        post.get('email') and post.get('email'),
                        'phone':
                        post.get('phone') and post.get('phone'),
                        'fax':
                        post.get('fax') and post.get('fax'),
                        'website':
                        post.get('website') and post.get('website'),
                        'cnss':
                        post.get('cnss') and post.get('cnss'),
                        'ca':
                        post.get('ca') and post.get('ca'),
                        'capital':
                        post.get('capital') and post.get('capital'),
                        'partner_references':
                        post.get('partner_references')
                        and post.get('partner_references'),
                        'rc':
                        post.get('rc') and post.get('rc'),
                        'category_id':
                        category_id and [(6, 0, [category_id.id])],
                        'title':
                        post.get('title') and post.get('title'),
                        'date':
                        post.get('date') != '' and post.get('date'),
                        'effectif_doc':
                        post.get('effectif_doc') and post.get('effectif_doc'),
                        'effectif':
                        post.get('effectif') and post.get('effectif'),
                        'effectif_chercheur':
                        post.get('effectif_chercheur')
                        and post.get('effectif_chercheur'),
                        'entite_recherche':
                        post.get('entite_recherche')
                        and post.get('entite_recherche'),
                        #'parent_id': partner_organisme.id,
                        'category':
                        'scientifique' if current_stage == 3 else 'industriel',
                        'submissions': [(4, submission.id)]
                    }
                    if post.get('partner_id') is not None:
                        partner = sudo_env['res.partner'].browse(
                            int(post.get('partner_id')))
                        partner.write(partner_value)
                    else:
                        partner = sudo_env['res.partner'].create(partner_value)
                    contact_value = {
                        'name':
                        post.get('contact_name'),
                        'function':
                        post.get('contact_function'),
                        'phone':
                        post.get('contact_phone'),
                        'email':
                        post.get('contact_email'),
                        'parent_id':
                        partner.id,
                        'category':
                        'scientifique' if current_stage == 3 else 'industriel'
                    }
                    if partner.child_ids.ids:
                        partner.child_ids[0].write(contact_value)
                    else:
                        sudo_env['res.partner'].create(contact_value)
                    if post.get('ufile'):
                        for file in request.httprequest.files.getlist('ufile'):
                            attachment_value = {
                                'name': file.filename,
                                'res_name': partner.name,
                                'res_model': 'res.partner',
                                'res_id': partner.id,
                                'datas': base64.encodestring(file.read()),
                                'datas_fname': file.filename,
                            }
                            sudo_env['ir.attachment'].create(attachment_value)
                #Stage 4: Additional info
                elif current_stage == 5:
                    value = {
                        'etat_art':
                        post.get('etat_art'),
                        'objective':
                        post.get('objective'),
                        'objectives':
                        post.get('objectives'),
                        'fallout':
                        post.get('fallout'),
                        'perspective':
                        post.get('perspective'),
                        'produits_services_process':
                        post.get('produits_services_process'),
                        'analyse_macro':
                        post.get('analyse_macro'),
                        'analyse_marche':
                        post.get('analyse_marche'),
                        'cible':
                        post.get('cible'),
                        'analyse_competitive':
                        post.get('analyse_competitive'),
                        'proposition_valeur':
                        post.get('proposition_valeur'),
                        'business_model':
                        post.get('business_model'),
                        'invest_retour':
                        post.get('invest_retour'),
                        'plan':
                        post.get('plan'),
                    }
                    submission.write(value)
                    if post.get('ufile'):
                        for file in request.httprequest.files.getlist('ufile'):
                            attachment_value = {
                                'name': file.filename,
                                'res_name': submission.name,
                                'res_model': 'project.submission',
                                'res_id': submission.id,
                                'datas': base64.encodestring(file.read()),
                                'datas_fname': file.filename,
                            }
                            env['ir.attachment'].create(attachment_value)
                        submission._get_attached_docs()
                #Stage 5: Tasks
                elif current_stage == 6 and post.get(
                        'to-save') == "1" and post.get('name') and post.get(
                            'type'):
                    value = {
                        'name':
                        post.get('name'),
                        'type':
                        post.get('type'),
                        'semester':
                        post.get('semester'),
                        'objectives':
                        post.get('objectives'),
                        'description':
                        post.get('description'),
                        'partner':
                        post.get('partner'),
                        'submission':
                        submission.id,
                        'partners': [(6, 0, [
                            int(x) for x in request.httprequest.form.getlist(
                                'partners')
                        ])],
                    }
                    if post.get('task_id') is not None:
                        task = env['project.submission.task'].browse(
                            int(post.get('task_id')))
                        task.write(value)
                    else:
                        env['project.submission.task'].create(value)
                #Stage 6: Project budget informations
                elif current_stage == 7:
                    for line in submission.budget_lines:
                        vals = {
                            'montant_propre':
                            post.get(str(line.id) + 'montant_propre') and
                            float(post.get(str(line.id) + 'montant_propre')),
                            'montant_subventionne':
                            post.get(str(line.id) + 'montant_subventionne')
                            and float(
                                post.get(
                                    str(line.id) + 'montant_subventionne'))
                        }
                        line.write(vals)
                    for line in submission.personnels:
                        vals = {
                            'time':
                            post.get(str(line.id) + 'time')
                            and int(post.get(str(line.id) + 'time')),
                            'number':
                            post.get(str(line.id) + 'number')
                            and float(post.get(str(line.id) + 'number')),
                            'montant_propre':
                            post.get(
                                str(line.id) + 'montant_propre_personnel')
                            and float(
                                post.get(
                                    str(line.id) +
                                    'montant_propre_personnel')),
                            'montant_demande':
                            post.get(
                                str(line.id) + 'montant_demande_personnel')
                            and float(
                                post.get(
                                    str(line.id) +
                                    'montant_demande_personnel'))
                        }
                        line.write(vals)
                    for line in submission.costs:
                        vals = {
                            'montant':
                            post.get(str(line.id) + 'montant_cout')
                            and float(post.get(str(line.id) + 'montant_cout'))
                        }
                        line.write(vals)

                elif current_stage == 8:

                    if post.get('ufile'):
                        attachment_value = {
                            'name':
                            str(time.time()) + '_' + post['ufile'].filename,
                            'res_name':
                            submission.name,
                            'res_model':
                            'project.submission',
                            'res_id':
                            submission.id,
                            'datas':
                            base64.encodestring(post['ufile'].read()),
                            'datas_fname':
                            post['ufile'].filename,
                            'parent_id':
                            sudo_env['document.directory'].search([
                                ('name', '=', 'Conventions')
                            ]) and sudo_env['document.directory'].search(
                                [('name', '=', 'Conventions')]).ids[0]
                        }
                        sudo_env['ir.attachment'].create(attachment_value)
                    if post.get('submit') == 'confirm':
                        submission.state = 'submitted'
        except ValidationError, e:
            next_stage = current_stage
            if post.get('partner_id'):
                post.update({'edit-partner': post.get('partner_id')})
            if post.get('task_id'):
                post.update({'edit-task': post.get('task_id')})
            if post.get('budgetline_id'):
                post.update({'edit-budgetline': post.get('budgetline_id')})
            env.cr.rollback()
            env.invalidate_all()
            error.update({'main': e.value})
コード例 #41
0
    def offers_apply(self, offer=None, next_stage=None, **post):

        #If no user connected, force connection
        #TODO: Redirect to submission page if offer variable is in session
        if not request.session.uid:
            request.session['offer'] = offer.id
            return login_redirect()

        #Get error data
        error = {}
        if 'website_project_submission_error' in request.session:
            error = request.session.pop('website_project_submission_error')

        #Get the candidate, if no candidate create one
        env = request.env(user=SUPERUSER_ID)
        user = env['res.users'].browse(request.session.uid)
        candidate = env['project.candidate'].search([('user', '=', user.id)])
        if candidate.id == False:
            candidate = env['project.candidate'].create({'user': user.id})

        #Get the submission, if no submission call creation template
        submission = env['project.submission'].search([
            ('offer', '=', offer.id), ('candidate', '=', candidate.id)
        ])
        if not submission:
            submission = env['project.submission'].create({
                'name':
                '/',
                'offer':
                offer.id,
                'candidate':
                candidate.id,
            })

        #Save the current stage
        current_stage = post.get('current_stage') and int(
            post.get('current_stage'))
        try:
            if bool(post) and post.get('submit') != 'cancel':
                if post.get('unlink-doc'):
                    env['ir.attachment'].browse(int(
                        post.get('unlink-doc'))).unlink()
                if post.get('unlink-task'):
                    env['project.submission.task'].browse(
                        int(post.get('unlink-task'))).unlink()
                if post.get('unlink-partner'):
                    submission.write(
                        {'partners': [(3, int(post.get('unlink-partner')))]})
                    partner = env['res.partner'].browse(
                        int(post.get('unlink-partner')))
                    if not partner.submissions:
                        partner.unlink()
                if post.get('unlink-budgetline'):
                    env['project.submission.budgetline'].browse(
                        int(post.get('unlink-budgetline'))).unlink()
                #Stage 1: Project general informations
                if current_stage == 1:
                    new_tags = []
                    tags = request.httprequest.form.getlist('tags')
                    for tag in tags:
                        if tag.isdigit():
                            new_tags.append(int(tag))
                        else:
                            existing_tag = env[
                                'project.submission.tag'].search([('name', '=',
                                                                   tag)])
                            if existing_tag:
                                new_tags.append(existing_tag.ids[0])
                            else:
                                new_tags.append(
                                    env['project.submission.tag'].create({
                                        'name':
                                        tag
                                    }).id)
                    value = {
                        'name':
                        post.get('name'),
                        'acronyme':
                        post.get('acronyme'),
                        'duration':
                        post.get('duration'),
                        'field_ids': [(6, 0, [
                            int(x)
                            for x in request.httprequest.form.getlist('fields')
                        ])],
                        'tags': [(6, 0, new_tags)],
                        'description':
                        post.get('description'),
                    }
                    submission.write(value)

                #Stage 2: Candidate general informations
                elif current_stage == 2:
                    value = {
                        'name': post.get('name'),
                        'function': post.get('function'),
                        'phone': post.get('phone'),
                        'mobile': post.get('mobile'),
                        'email': post.get('email'),
                    }
                    candidate.write(value)
                    if candidate.parent_id:
                        candidate.parent_id.write(
                            {'name': post.get('organisme')})
                    else:
                        organisme = env['res.partner'].create(
                            {'name': post.get('organisme')})
                        candidate.write({'parent_id': organisme.id})
                    if post.get('ufile'):
                        attachment_value = {
                            'name': post['ufile'].filename,
                            'res_name': value['name'],
                            'res_model': 'project.candidate',
                            'res_id': candidate.id,
                            'datas': base64.encodestring(post['ufile'].read()),
                            'datas_fname': post['ufile'].filename,
                        }
                        env['ir.attachment'].create(attachment_value)
                        candidate._get_attached_docs()

                #Stage 3: Project partners informations
                elif current_stage == 3 and post.get(
                        'to-save') == "1" and post.get('name') and post.get(
                            'category'):
                    partner_organisme = env['res.partner'].create(
                        {'name': post.get('organisme')})
                    partner_value = {
                        'name': post.get('name'),
                        'function': post.get('function'),
                        'phone': post.get('phone'),
                        'mobile': post.get('mobile'),
                        'fax': post.get('fax'),
                        'email': post.get('email'),
                        'parent_id': partner_organisme.id,
                        'category': post.get('category'),
                        'submissions': [(4, submission.id)]
                    }
                    if post.get('partner_id') is not None:
                        partner = env['res.partner'].browse(
                            int(post.get('partner_id')))
                        partner.write(partner_value)
                    else:
                        partner = env['res.partner'].create(partner_value)
                #Stage 4: Additional info
                elif current_stage == 4:
                    value = {
                        'etat_art': post.get('etat_art'),
                        'objective': post.get('objective'),
                        'objectives': post.get('objectives'),
                        'fallout': post.get('fallout'),
                        'perspective': post.get('perspective'),
                    }
                    submission.write(value)
                    if post.get('ufile'):
                        attachment_value = {
                            'name': post['ufile'].filename,
                            'res_name': submission.name,
                            'res_model': 'project.submission',
                            'res_id': submission.id,
                            'datas': base64.encodestring(post['ufile'].read()),
                            'datas_fname': post['ufile'].filename,
                        }
                        env['ir.attachment'].create(attachment_value)
                        submission._get_attached_docs()
                #Stage 5: Tasks
                elif current_stage == 5 and post.get(
                        'to-save') == "1" and post.get('name') and post.get(
                            'type'):
                    value = {
                        'name': post.get('name'),
                        'type': post.get('type'),
                        'semester': post.get('semester'),
                        'objectives': post.get('objectives'),
                        'description': post.get('description'),
                        'partner': post.get('partner'),
                    }
                    if post.get('task_id') is not None:
                        task = env['project.submission.task'].browse(
                            int(post.get('task_id')))
                        task.write(value)
                    else:
                        env['project.submission.task'].create(value)
                #Stage 6: Project budget informations
                elif current_stage == 6 and post.get(
                        'to-save') == "1" and post.get('name') and post.get(
                            'type'):
                    value = {
                        'type':
                        post.get('type'),
                        'name':
                        post.get('name'),
                        'montant_subventionne':
                        float(post.get('montant_subventionne')),
                        'percent_subventionne':
                        float(post.get('percent_subventionne')),
                        'budget':
                        post.get('budget'),
                        'montant_propre':
                        float(post.get('budget')) -
                        float(post.get('montant_propre')),
                        'submission':
                        submission.id,
                    }
                    if post.get('budgetline_id') is not None:
                        budgetline = env[
                            'project.submission.budgetline'].browse(
                                int(post.get('budgetline_id')))
                        budgetline.write(partner_value)
                    else:
                        env['project.submission.budgetline'].create(value)
        except ValidationError:
            next_stage = current_stage
            pass

        if next_stage == None:
            if bool(post) and post.get('submit') == 'next':
                next_stage = current_stage + 1
            elif bool(post) and post.get('submit') == 'prev':
                next_stage = current_stage - 1
            elif bool(post) and current_stage:
                next_stage = current_stage
            else:
                next_stage = 1

        #prepare next_stage vals
        vals = {
            'submission': submission,
            'error': error,
            'current_stage': next_stage,
        }
        if next_stage == 1:
            fields = env['project.offer.field'].search([])
            tags = env['project.submission.tag'].search([])
            duration_steps = range(offer.min_time, offer.max_time + 1)
            vals.update({
                'error': error,
                'duration_steps': duration_steps,
                'fields': fields,
                'all_tags': tags,
            })
        if next_stage == 2:
            vals.update({
                'error': error,
            })
        elif next_stage == 3:
            if post.get('edit-partner'):
                partner = env['res.partner'].browse(
                    int(post.get('edit-partner')))
                vals.update({'partner': partner})
            if post.get('add-partner'):
                vals.update({'new': True})
            else:
                vals.update({'new': False})
            categories = [('scientifique', 'Scientifique'),
                          ('industriel', 'Industriel')]
            duration_steps = range(1, offer.max_time + 1)
            vals.update({
                'duration_steps': duration_steps,
                'categories': categories,
                'error': error,
            })
        elif next_stage == 4:
            vals.update({
                'error': error,
            })
        elif next_stage == 5:
            types = env['project.submission.task.type'].search([])
            if post.get('edit-task'):
                task = env['project.submission.task'].browse(
                    int(post.get('edit-task')))
                vals.update({'task': task})
            if post.get('add-task'):
                vals.update({'new': True})
            else:
                vals.update({'new': False})
            vals.update({
                'types': types,
                'error': error,
            })
        elif next_stage == 6:
            types = env['project.budgetline.type'].search([])
            if post.get('edit-budgetline'):
                budgetline = env['project.submission.budgetline'].browse(
                    int(post.get('edit-budgetline')))
                vals.update({'budgetline': budgetline})
            if post.get('add-budgetline'):
                vals.update({'new': True})
            else:
                vals.update({'new': False})
            vals.update({
                'types': types,
                'error': error,
            })
        return request.render('website_project_submission.apply', vals)
コード例 #42
0
ファイル: main.py プロジェクト: Alan1590/odoo-1
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        return request.render('point_of_sale.index')
コード例 #43
0
ファイル: main.py プロジェクト: 3dfxSoftwareinc/odoo
    def a(self, debug=False, **k):

        if not request.session.uid:
            return login_redirect()

        return request.render('point_of_sale.index')
コード例 #44
0
ファイル: main.py プロジェクト: difra/odoo-saas-tools
    def new_database(self, **post):
        if not request.session.uid:
            return login_redirect()
        plan_id = int(post.get('plan_id'))

        return self.create_demo_database(plan_id)