Skip to Content
Menu
This question has been flagged

I want to post the select abo value -> to my product.create method.

I have this in my xml:

<div class="form-group col-lg-6">
<label class="control-label" for="product.text">Informationstext:</label>
<input type="text" name="text" class="form-control" t-att-value="text"/>
</div>
<div t-attf-class="form-group col-lg-6">
<label class="control-label" for="abonnement">Abonnement:</label>
<select name="abonnement" class="form-control">
<option value="">Abo...</option>
<t t-foreach="abonnements" t-as="abo">
<option t-att-value="abo.name" domain="[('abo.is_abo', '=',True)]">
<t t-esc="abo.name" />
</option>
</t>
</select>
</div>


Now I can give with product.create the text to my field in product, but the select "abonnement" isn't working.

How can I give that value to my create function?

controller:

@http.route(['/my/inserat/new'], type='http', auth="user", website=True)
def inserat_creation(self, product=None, redirect=None, **post):
product = request.env['product.template'].browse([product])
try:
product.check_access_rights('read')
product.check_access_rule('read')
except AccessError:
return request.website.render("website.403")
values = {
'error': {},
'error_message': [],
}

if post:
         #the select from the xml should give here the selection to the field abonnement in product.template
product_id = product.create({'text': post.pop('text')})


product.sudo().write(post)
values.update(post)

request.website.sale_get_order(force_create=1)._cart_update(product_id=int(product_id), add_qty=1, set_qty=0)
return request.redirect("/shop/cart")

abonnements = request.env['product.template'].sudo().search([('is_abo','=',True)])

values.update({
'product': product,
'abonnements': abonnements,
# 'redirect': redirect,
})

return request.website.render("website_portal_sale.inserat_creation", {
'product': product.sudo(),
'abonnements': abonnements,
})


Thank you

Avatar
Discard
Related Posts Replies Views Activity
1
Apr 21
7429
0
Oct 17
3337
3
Oct 22
3930
0
Dec 16
2310
0
Jul 16
1884