Passa al contenuto
Menu
La domanda è stata contrassegnata
1 Rispondi
2249 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
lug 25
1286
2
lug 25
2985
1
mag 25
927
0
gen 25
1383
2
nov 24
2156