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
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
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>
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Apr 24
|
1171 | ||
|
4
Nov 23
|
5105 | ||
|
0
Oct 23
|
857 | ||
|
0
Dec 22
|
1888 | ||
|
0
Jun 22
|
1963 |