How to pass database name, login id, password, customer phone number, customer name as a parameter via URL to search a customer in odoo at [Sales] module under [Customers] function?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Below example gives u an idea.
In main.py
from odoo import models, fields, api
from werkzeug import url_encode
class SimpleControllerModel(models.Model):
_name ="simple.controller"
name = fields.Char(string="name")
age = fields.Integer(string="age")
designation = fields.Selection([('sw','software'),('salesman','Salesman')])
@api.multi
def webpage(self):
values = dict(self._context.get('params', {}))
print dict(self._context.get('params',{}))
values.update({
'model': self._name,
'id': self.id
# HERE PASS THE VALUES U NEED. ID is passed along with the context.
})
return{
'type': 'ir.actions.act_url',
'target': 'self',
'url': '/details/employee/%s/%s' % (self.name,self.id)
# 'url': '/details/employee/%s/%s' % (self.id,url_encode(values))
}
Then Define Controller: Like below
from odoo import http
from odoo.http import request
class SimpleController(http.Controller):
# @http.route(["/details/employee"],type='http',auth="user",methods=['GET'],website=True)
@http.route(['/details/employee/<model("simple.controller"):name>',
'/details/employee/<model("simple.controller"):name>/<model("simple.controller"):id>',
'/details/employee/<string:id>',
'/details/employee'],
type='http',auth="public",methods=['GET'],website=True)
def view(self,name,**kwargs):
print "controllerview"
if kwargs.get('model', False) == 'simple.controller':
action_xml_id = 'simple_controller.action_simple_controller'
action_id = request.env.ref(action_xml_id).id
kwargs.update({
'action': action_id,
})
values = dict(kwargs)
return request.render('simple_controller.simple_controller_templateid', values)
In template.xml.. Define below code
<odoo>
<template id="simple_controller.simple_controller_templateid" name="simple_controller">
<t t-call="website.layout">
<div class="pull-left css_editable_mode_hidden">
<ul class="list-inline">
<li>
<a class="btn btn-danger"
t-att-href="'/web#return_label=Website&model=%s&id=%s&action=%s&view_type=form' % (model, id, action)">
<span class="fa fa-long-arrow-left" />
Back
<span t-esc="test" />
</a>
</li>
</ul>
</div>
</t>
</template>
</odoo>
<a t-attfr-href="/web#id={{ record.your_field.value }}&cids=1&menu_id=584&action=620&model=daycare.child&view_type=form">Mark Attendancea>
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 4 24
|
1712 | ||
|
4
thg 11 23
|
5703 | ||
|
0
thg 10 23
|
1446 | ||
|
0
thg 12 22
|
2394 | ||
|
0
thg 6 22
|
1963 |