I want to add expense module lines in website form.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
Create a website template to display the form:
odoo
data
template id="my_model_website_template" name="My Model Website Template" inherit_id="website.layout"
xpath expr="//main" position="inside"
div class="container"
form id="my_model_form" class="s_website_form" method="post" action="/my_model/submit"
t t-call="my_model_website_form_view" /
button type="submit">Submit /form
/div
/xpath
/template
/data
Create a controller to handle the form submission:
from odoo import http
from odoo.http import request
class MyModelController(http.Controller):
@http.route('/my_model/submit', type='http', auth="public", website=True, methods=['POST'])
def submit_form(self, **post):
model = request.env['my.model']
values = {
'name': post.get('name'),
'lines': [(0, 0, {'name': line}) for line in post.getlist('lines')],
}
model.create(values)
return request.redirect('/')
Include the website template in the website layout:
odoo>
template id="website_layout" inherit_id="website.layout"
xpath expr="//main" position="inside"
t t-call="my_model_website_template" /
/xpath
/template
/odoo
One way to do this is by creating a table in the website then calling a custom method defined in your model via rpc query. In the custom function, you should search for the one2many lines and return it. Then back in Js side you iterate the result returned by the query and fill up the table.
Hi,
You need to create a controller and pass the values to the rendered template.
In the template, you can loop it using for-each.
Eg:
<t t-foreach="//passed value" t-as="value">
<t t-esc="value"/>
</t>
Regards
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
sep. 22
|
162 | ||
|
4
mrt. 24
|
5101 | ||
|
1
mrt. 24
|
1676 | ||
Website form default country
Opgelost
|
|
1
sep. 22
|
3794 | |
|
2
jul. 22
|
2349 |