예제 #1
0
파일: main.py 프로젝트: jaxkodex/odoo
    def view(self, order_id, pdf=None, token=None, message=False, **post):
        # use SUPERUSER_ID allow to access/view order for public user
        # only if he knows the private token
        order = request.registry.get('sale.order').browse(request.cr, token and SUPERUSER_ID or request.uid, order_id, request.context)
        now = time.strftime('%Y-%m-%d')
        dummy, action = request.registry.get('ir.model.data').get_object_reference(request.cr, request.uid, 'sale', 'action_quotations')
        if token:
            if token != order.access_token:
                return request.website.render('website.404')
            # Log only once a day
            if request.session.get('view_quote',False)!=now:
                request.session['view_quote'] = now
                body=_('Quotation viewed by customer')
                _message_post_helper(res_model='sale.order', res_id=order.id, message=body, token=token, token_field="access_token", message_type='notification')
        days = 0
        if order.validity_date:
            days = (datetime.datetime.strptime(order.validity_date, '%Y-%m-%d') - datetime.datetime.now()).days + 1
        if pdf:
            report_obj = request.registry['report']
            pdf = report_obj.get_pdf(request.cr, SUPERUSER_ID, [order_id], 'website_quote.report_quote', data=None, context=dict(request.context, set_viewport_size=True))
            pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
            return request.make_response(pdf, headers=pdfhttpheaders)
        user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid, context=request.context)
        tx_id = request.registry['payment.transaction'].search(request.cr, SUPERUSER_ID, [('reference', '=', order.name)], context=request.context)
        tx = request.registry['payment.transaction'].browse(request.cr, SUPERUSER_ID, tx_id, context=request.context) if tx_id else False
        values = {
            'quotation': order,
            'message': message and int(message) or False,
            'option': bool(filter(lambda x: not x.line_id, order.options)),
            'order_valid': (not order.validity_date) or (now <= order.validity_date),
            'days_valid': days,
            'action': action,
            'breadcrumb': user.partner_id == order.partner_id,
            'tx_id': tx_id,
            'tx_state': tx.state if tx else False,
            'tx_post_msg': tx.acquirer_id.post_msg if tx else False,
            'need_payment': not tx_id and order.state == 'manual',
            'token': token,
        }

        if order.require_payment or (not tx_id and order.state == 'manual'):
            payment_obj = request.registry.get('payment.acquirer')
            acquirer_ids = payment_obj.search(request.cr, SUPERUSER_ID, [('website_published', '=', True), ('company_id', '=', order.company_id.id)], context=request.context)
            values['acquirers'] = list(payment_obj.browse(request.cr, token and SUPERUSER_ID or request.uid, acquirer_ids, context=request.context))
            render_ctx = dict(request.context, submit_class='btn btn-primary', submit_txt=_('Pay & Confirm'))
            for acquirer in values['acquirers']:
                acquirer.button = payment_obj.render(
                    request.cr, SUPERUSER_ID, acquirer.id,
                    order.name,
                    order.amount_total,
                    order.pricelist_id.currency_id.id,
                    partner_id=order.partner_id.id,
                    tx_values={
                        'return_url': '/quote/%s/%s' % (order_id, token) if token else '/quote/%s' % order_id,
                        'type': 'form',
                        'alias_usage': _('If we store your payment information on our server, subscription payments will be made automatically.')
                    },
                    context=render_ctx)
        return request.website.render('website_quote.so_quotation', values)
예제 #2
0
파일: main.py 프로젝트: Hasib786/odoo
    def view(self, order_id, pdf=None, token=None, message=False, **post):
        # use SUPERUSER_ID allow to access/view order for public user
        # only if he knows the private token
        order = request.registry.get('sale.order').browse(request.cr, token and SUPERUSER_ID or request.uid, order_id, request.context)
        now = time.strftime('%Y-%m-%d')
        dummy, action = request.registry.get('ir.model.data').get_object_reference(request.cr, request.uid, 'sale', 'action_quotations')
        if token:
            if token != order.access_token:
                return request.website.render('website.404')
            # Log only once a day
            if request.session.get('view_quote',False)!=now:
                request.session['view_quote'] = now
                body=_('Quotation viewed by customer')
                _message_post_helper(res_model='sale.order', res_id=order.id, message=body, token=token, token_field="access_token", message_type='notification')
        days = 0
        if order.validity_date:
            days = (datetime.datetime.strptime(order.validity_date, '%Y-%m-%d') - datetime.datetime.now()).days + 1
        if pdf:
            report_obj = request.registry['report']
            pdf = report_obj.get_pdf(request.cr, SUPERUSER_ID, [order_id], 'website_quote.report_quote', data=None, context=dict(request.context, set_viewport_size=True))
            pdfhttpheaders = [('Content-Type', 'application/pdf'), ('Content-Length', len(pdf))]
            return request.make_response(pdf, headers=pdfhttpheaders)
        user = request.registry['res.users'].browse(request.cr, SUPERUSER_ID, request.uid, context=request.context)
        tx_id = request.registry['payment.transaction'].search(request.cr, SUPERUSER_ID, [('reference', '=', order.name)], context=request.context)
        tx = request.registry['payment.transaction'].browse(request.cr, SUPERUSER_ID, tx_id, context=request.context) if tx_id else False
        values = {
            'quotation': order,
            'message': message and int(message) or False,
            'option': bool(filter(lambda x: not x.line_id, order.options)),
            'order_valid': (not order.validity_date) or (now <= order.validity_date),
            'days_valid': days,
            'action': action,
            'breadcrumb': user.partner_id == order.partner_id,
            'tx_id': tx_id,
            'tx_state': tx.state if tx else False,
            'tx_post_msg': tx.acquirer_id.post_msg if tx else False,
            'need_payment': order.invoice_status == 'to invoice' and (not tx or tx.state in ['draft', 'cancel', 'error']),
            'token': token,
        }

        if order.require_payment or values['need_payment']:
            payment_obj = request.registry.get('payment.acquirer')
            acquirer_ids = payment_obj.search(request.cr, SUPERUSER_ID, [('website_published', '=', True), ('company_id', '=', order.company_id.id)], context=request.context)
            values['acquirers'] = list(payment_obj.browse(request.cr, token and SUPERUSER_ID or request.uid, acquirer_ids, context=request.context))
            render_ctx = dict(request.context, submit_class='btn btn-primary', submit_txt=_('Pay & Confirm'))
            for acquirer in values['acquirers']:
                acquirer.button = payment_obj.render(
                    request.cr, SUPERUSER_ID, acquirer.id,
                    order.name,
                    order.amount_total,
                    order.pricelist_id.currency_id.id,
                    values={
                        'return_url': '/quote/%s/%s' % (order_id, token) if token else '/quote/%s' % order_id,
                        'type': 'form',
                        'alias_usage': _('If we store your payment information on our server, subscription payments will be made automatically.'),
                        'partner_id': order.partner_id.id,
                    },
                    context=render_ctx)
        return request.website.render('website_quote.so_quotation', values)
예제 #3
0
파일: main.py 프로젝트: NamaadIran/odoo
 def decline(self, order_id, token, **post):
     order_obj = request.registry.get('sale.order')
     order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
     if token != order.access_token:
         return request.website.render('website.404')
     request.registry.get('sale.order').action_cancel(request.cr, SUPERUSER_ID, [order_id])
     message = post.get('decline_message')
     if message:
         _message_post_helper(message=message, res_id=order_id, res_model='sale.order', **{'token': token, 'token_field': 'access_token'} if token else {})
     return werkzeug.utils.redirect("/quote/%s/%s?message=2" % (order_id, token))
예제 #4
0
파일: main.py 프로젝트: jaxkodex/odoo
 def decline(self, order_id, token, **post):
     order_obj = request.registry.get('sale.order')
     order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
     if token != order.access_token:
         return request.website.render('website.404')
     request.registry.get('sale.order').action_cancel(request.cr, SUPERUSER_ID, [order_id])
     message = post.get('decline_message')
     if message:
         _message_post_helper(message=message, res_id=order_id, res_model='sale.order', **{'token': token, 'token_field': 'access_token'} if token else {})
     return werkzeug.utils.redirect("/quote/%s/%s?message=2" % (order_id, token))
예제 #5
0
파일: main.py 프로젝트: NamaadIran/odoo
 def accept(self, order_id, token=None, signer=None, sign=None, **post):
     order_obj = request.registry.get('sale.order')
     order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
     if token != order.access_token:
         return request.website.render('website.404')
     if order.require_payment:
         return request.website.render('website.404')
     attachments=sign and [('signature.png', sign.decode('base64'))] or []
     order_obj.action_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context)
     message = _('Order signed by %s') % (signer,)
     _message_post_helper(message=message, res_id=order_id, res_model='sale.order', attachments=attachments, **({'token': token, 'token_field': 'access_token'} if token else {}))
     return True
예제 #6
0
파일: main.py 프로젝트: jaxkodex/odoo
 def accept(self, order_id, token=None, signer=None, sign=None, **post):
     order_obj = request.registry.get('sale.order')
     order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
     if token != order.access_token:
         return request.website.render('website.404')
     if order.require_payment:
         return request.website.render('website.404')
     attachments=sign and [('signature.png', sign.decode('base64'))] or []
     order_obj.action_button_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context)
     message = _('Order signed by %s') % (signer,)
     _message_post_helper(message=message, res_id=order_id, res_model='sale.order', attachments=attachments, **({'token': token, 'token_field': 'access_token'} if token else {}))
     return True
예제 #7
0
파일: main.py 프로젝트: nirusduddin/odoo
 def decline(self, order_id, token, **post):
     order_obj = request.registry.get("sale.order")
     order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
     if token != order.access_token:
         return request.website.render("website.404")
     request.registry.get("sale.order").action_cancel(request.cr, SUPERUSER_ID, [order_id])
     message = post.get("decline_message")
     if message:
         _message_post_helper(
             message=message,
             res_id=order_id,
             res_model="sale.order",
             **{"token": token, "token_field": "access_token"} if token else {}
         )
     return werkzeug.utils.redirect("/quote/%s/%s?message=2" % (order_id, token))
예제 #8
0
파일: main.py 프로젝트: nirusduddin/odoo
 def accept(self, order_id, token=None, signer=None, sign=None, **post):
     order_obj = request.registry.get("sale.order")
     order = order_obj.browse(request.cr, SUPERUSER_ID, order_id)
     if token != order.access_token:
         return request.website.render("website.404")
     if order.require_payment:
         return request.website.render("website.404")
     attachments = sign and [("signature.png", sign.decode("base64"))] or []
     order_obj.action_button_confirm(request.cr, SUPERUSER_ID, [order_id], context=request.context)
     message = _("Order signed by %s") % (signer,)
     _message_post_helper(
         message=message,
         res_id=order_id,
         res_model="sale.order",
         attachments=attachments,
         **({"token": token, "token_field": "access_token"} if token else {})
     )
     return True
예제 #9
0
파일: main.py 프로젝트: nirusduddin/odoo
    def view(self, order_id, pdf=None, token=None, message=False, **post):
        # use SUPERUSER_ID allow to access/view order for public user
        # only if he knows the private token
        order = request.registry.get("sale.order").browse(
            request.cr, token and SUPERUSER_ID or request.uid, order_id, request.context
        )
        now = time.strftime("%Y-%m-%d")
        dummy, action = request.registry.get("ir.model.data").get_object_reference(
            request.cr, request.uid, "sale", "action_quotations"
        )
        if token:
            if token != order.access_token:
                return request.website.render("website.404")
            # Log only once a day
            if request.session.get("view_quote", False) != now:
                request.session["view_quote"] = now
                body = _("Quotation viewed by customer")
                _message_post_helper(
                    res_model="sale.order",
                    res_id=order.id,
                    message=body,
                    token=token,
                    token_field="access_token",
                    message_type="notification",
                )
        days = 0
        if order.validity_date:
            days = (datetime.datetime.strptime(order.validity_date, "%Y-%m-%d") - datetime.datetime.now()).days + 1
        if pdf:
            report_obj = request.registry["report"]
            pdf = report_obj.get_pdf(
                request.cr, SUPERUSER_ID, [order_id], "website_quote.report_quote", data=None, context=request.context
            )
            pdfhttpheaders = [("Content-Type", "application/pdf"), ("Content-Length", len(pdf))]
            return request.make_response(pdf, headers=pdfhttpheaders)
        user = request.registry["res.users"].browse(request.cr, SUPERUSER_ID, request.uid, context=request.context)
        tx_id = request.registry["payment.transaction"].search(
            request.cr, SUPERUSER_ID, [("reference", "=", order.name)], context=request.context
        )
        tx = (
            request.registry["payment.transaction"].browse(request.cr, SUPERUSER_ID, tx_id, context=request.context)
            if tx_id
            else False
        )
        values = {
            "quotation": order,
            "message": message and int(message) or False,
            "option": bool(filter(lambda x: not x.line_id, order.options)),
            "order_valid": (not order.validity_date) or (now <= order.validity_date),
            "days_valid": days,
            "action": action,
            "breadcrumb": user.partner_id == order.partner_id,
            "tx_id": tx_id,
            "tx_state": tx.state if tx else False,
            "tx_post_msg": tx.acquirer_id.post_msg if tx else False,
            "need_payment": not tx_id and order.state == "manual",
            "token": token,
        }

        if order.require_payment or (not tx_id and order.state == "manual"):
            payment_obj = request.registry.get("payment.acquirer")
            acquirer_ids = payment_obj.search(
                request.cr,
                SUPERUSER_ID,
                [("website_published", "=", True), ("company_id", "=", order.company_id.id)],
                context=request.context,
            )
            values["acquirers"] = list(
                payment_obj.browse(
                    request.cr, token and SUPERUSER_ID or request.uid, acquirer_ids, context=request.context
                )
            )
            render_ctx = dict(request.context, submit_class="btn btn-primary", submit_txt=_("Pay & Confirm"))
            for acquirer in values["acquirers"]:
                acquirer.button = payment_obj.render(
                    request.cr,
                    SUPERUSER_ID,
                    acquirer.id,
                    order.name,
                    order.amount_total,
                    order.pricelist_id.currency_id.id,
                    partner_id=order.partner_id.id,
                    tx_values={
                        "return_url": "/quote/%s/%s" % (order_id, token) if token else "/quote/%s" % order_id,
                        "type": "form",
                        "alias_usage": _(
                            "If we store your payment information on our server, subscription payments will be made automatically."
                        ),
                    },
                    context=render_ctx,
                )
        return request.website.render("website_quote.so_quotation", values)