Skip to Content
Menu
This question has been flagged
1 Reply
1746 Views

Hello everyone


I am setting up my own webshop. This shop doesn't need to have any shipping methods, however clients need to come and pick up the packages. I wanted an option for clients to select their own delivery date(time). I have been able to add a field where they can select this date(time), but this however doesn't get linked up to the model, where I also created the same field.


This is what I'm editing into the view 

         <input id="x_pickup_date" type="date" name="Pickup date" class="form-control o_website_form_input o_website_form_date"/>


This shows the field properly, but how do I make this field be saved in sale.order?

Thanks for any help
J
Avatar
Discard
Best Answer

You need to add the field to the model by overriding it..something like this:

from odoo import models, fields, api 
class WebsiteSaleOrderExtraInfo (models.Model):
    _name = 'sale.order'
    _inherit = ['sale.order']
    
    x_pickup_date  = fields.Date (string = 'Pickup Date', required = True)    

Within your view you will also need to allow the field to be whitelisted in the Web (this caught me out for a long time)

<! - Allow field to be whitelisted in web forms -> 
        <function model = "ir.model.fields" name = "formbuilder_whitelist">
            <value> sale.order </value>
            <value eval = "[
                ' x_pickup_date '
            ]" / >
        </function>

 

Avatar
Discard
Related Posts Replies Views Activity
2
Nov 24
476
0
Oct 24
105
1
Jul 24
410
1
Mar 24
923
1
Feb 24
340