@@ -41,29 +41,28 @@ class sale_quote(http.Controller):
|
||||
order_pool = request.registry.get('sale.order')
|
||||
user_pool = request.registry.get('res.users')
|
||||
partner = order_pool.browse(request.cr, SUPERUSER_ID, order_id, context=request.context).partner_id.id
|
||||
return user_pool.search(request.cr, SUPERUSER_ID, [('partner_id', '=', partner)])[0]
|
||||
if partner:
|
||||
user = user_pool.search(request.cr, SUPERUSER_ID, [('partner_id', '=', partner)])[0]
|
||||
return user
|
||||
|
||||
@website.route(['/quote/<token>', '/quote/<int:order_id>'], type='http', auth="public")
|
||||
def view(self, token=None, order_id=None, **post):
|
||||
@website.route(["/quote/<model('sale.order'):order>/<token>"], type='http', auth="public")
|
||||
def view(self, order=None, token=None,**post):
|
||||
assert token == order.access_token, 'No token found'
|
||||
values = {}
|
||||
order_pool = request.registry.get('sale.order')
|
||||
if token:
|
||||
order_id = self._get_quote(token)[0]
|
||||
quotation = order_pool.browse(request.cr, SUPERUSER_ID, order_id)
|
||||
values.update({
|
||||
'quotation': quotation,
|
||||
'quotation': order,
|
||||
})
|
||||
return request.website.render('website_sale_quote.so_quotation', values)
|
||||
|
||||
@website.route(['/quote/<int:order_id>/accept'], type='http', auth="public")
|
||||
def accept(self, order_id=None, **post):
|
||||
request.registry.get('sale.order').write(request.cr, SUPERUSER_ID, [order_id], {'state': 'manual'})
|
||||
return request.redirect("/quote/%s" % self._get_token(order_id))
|
||||
return request.redirect("/quote/%s/%s" % (order_id, self._get_token(order_id)))
|
||||
|
||||
@website.route(['/quote/<int:order_id>/decline'], type='http', auth="public")
|
||||
def decline(self, order_id=None, **post):
|
||||
request.registry.get('sale.order').write(request.cr, SUPERUSER_ID, [order_id], {'state': 'cancel'})
|
||||
return request.redirect("/quote/%s" % self._get_token(order_id))
|
||||
return request.redirect("/quote/%s/%s" % (order_id, self._get_token(order_id)))
|
||||
|
||||
@website.route(['/quote/<int:order_id>/post'], type='http', auth="public")
|
||||
def post(self, order_id=None, **post):
|
||||
@@ -76,7 +75,7 @@ class sale_quote(http.Controller):
|
||||
subtype='mt_comment',
|
||||
)
|
||||
request.session.body = False
|
||||
return request.redirect("/quote/%s" % self._get_token(order_id))
|
||||
return request.redirect("/quote/%s/%s" % (order_id, self._get_token(order_id)))
|
||||
|
||||
@website.route(['/quote/update_line'], type='json', auth="public")
|
||||
def update(self, line_id=None, remove=False, unlink=False, order_id=None, **post):
|
||||
|
||||
@@ -87,22 +87,27 @@ class sale_order(osv.osv):
|
||||
'website_description': fields.html('Description'),
|
||||
}
|
||||
|
||||
def _get_token(self, cr, uid, ids, context=None):
|
||||
def _get_token(self, cr, uid, oder_id, context=None):
|
||||
"""
|
||||
Generate token for sale order on action_quotation_send , send it to customer.
|
||||
"""
|
||||
db_uuid = self.pool.get('ir.config_parameter').get_param(cr, uid, 'database.uuid')
|
||||
return hashlib.sha256('%s-%s-%s' % (time.time(), db_uuid, ids[0])).hexdigest()
|
||||
return hashlib.sha256('%s-%s-%s' % (time.time(), db_uuid, oder_id)).hexdigest()
|
||||
|
||||
def _get_signup_url(self, cr, uid, order_id=False, token=False, context=None):
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context)
|
||||
url = "%s/quote/%s/%s" % (base_url, order_id, token)
|
||||
return url
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
new_id = super(sale_order, self).create(cr, uid, vals, context=context)
|
||||
self.write(cr, uid, [new_id], {'quote_url': self._get_signup_url(cr, uid, new_id, False, context)})
|
||||
token = self._get_token(cr, uid, new_id, context)
|
||||
url = self._get_signup_url(cr, uid, new_id, token, context)
|
||||
self.write(cr, uid, [new_id], {'access_token': token,'quote_url': url})
|
||||
return new_id
|
||||
|
||||
def action_quotation_send(self, cr, uid, ids, context=None):
|
||||
token = self._get_token(cr, uid, ids, context)
|
||||
self._create_portal_user(cr, uid, ids, context=context)
|
||||
self.write(cr, uid, ids, {'access_token': token, 'quote_url': self._get_signup_url(cr, uid, False, token, context)})
|
||||
res = super(sale_order, self).action_quotation_send(cr, uid, ids, context=context)
|
||||
return res
|
||||
|
||||
@@ -122,11 +127,6 @@ class sale_order(osv.osv):
|
||||
'in_portal': True}))
|
||||
return user_wizard_pool.action_apply(cr, uid, user, context=context)
|
||||
|
||||
def _get_signup_url(self, cr, uid, order_id=False, token=False, context=None):
|
||||
base_url = self.pool.get('ir.config_parameter').get_param(cr, uid, 'web.base.url', default='http://localhost:8069', context=context)
|
||||
url = "%s/quote/%s" % (base_url, token and token or order_id)
|
||||
return url
|
||||
|
||||
def _get_sale_order_line(self, cr, uid, template_id, context=None):
|
||||
"""create order line from selected quote template line."""
|
||||
lines = []
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="btn" t-if="quotation.state != 'cancel'" id="cancelQuotation">
|
||||
<a type="submit" t-if="quotation.state != 'cancel'" t-href="/quote/#{ quotation.id }/decline">
|
||||
<span class="fa-stack">
|
||||
<i class="fa fa-circle fa-stack-2x" style="color:#d9534f;"></i>
|
||||
<i class="fa fa-times fa-stack-1x fa-inverse"></i>
|
||||
|
||||
Reference in New Issue
Block a user