콘텐츠로 건너뛰기
메뉴
신고된 질문입니다
1 회신
2278 화면

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
아바타
취소
베스트 답변

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>

 

아바타
취소
관련 게시물 답글 화면 활동
2
7월 25
1301
2
7월 25
3006
1
5월 25
948
0
1월 25
1402
2
11월 24
2182