Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
14746 Lượt xem

I have  a field priority = fields.Selection(

    [('10', '10'), ('20', '20'), ('30', '30'), ('40', '40'), ('50', '50'), ('60', '60'), ('70', '70'),
('80', '80'), ('90', '90'), ('100', '100')], string='Priority (%)', default='10')
I want to display this field in my website Form
@http.route(['/wishlist_create_website'], type="http", auth="public", methods=['GET'], website=True)
def register_admission1(self, **kw):
product_id = request.env['product.product'].sudo().search([])
     #How to fetch priority field value from backend?
    kw.update({'products': product_id,})
return request.render('my.my_control', kw)

Ảnh đại diện
Huỷ bỏ

At which model did you define priority?

Tác giả

hi...

class Myorder():

_name='my.wisho'

Câu trả lời hay nhất

Suppose if you defined in simple.controller Just like belo example:


class SimpleController(http.Controller):

    @http.route(["/details/employee/<model('simple.controller'):part>/"],

                type='http', auth="user", methods=['GET'], website=True, cors="*")

    def view(self,part,**kwargs):

        action_id = request.env.ref('simple_controller.action_simple_controller').id

         return_kwargs = dict(kwargs)

        kwargs.update({'action':action_id,'model':'simple.controller','accept': '/details/employee/accept/%s/?%s' % (part.id,                        url_encode(return_kwargs)),  'deny': '/details/employee/deny/%s/?%s' % (part.id, url_encode(return_kwargs))})

        value = dict(kwargs)

        priority_get = request.env['simple.controller'].sudo().browse(int(kwargs.get('id')))

        print   priority_get.priority 

        return request.render('simple_controller.simple_controller_templateid', value, part.uuid)


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất



Use <select> to show the Selection field in website form. 

<form action="/wishlist_create_website/" method="post" ................>
    .........
        <select>
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="30">30</option>
            <option value="40">40/option>

                 .......
        </select>         
    .........
</form>







Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 23
3042
3
thg 7 20
12751
0
thg 4 20
4165
0
thg 3 15
4279
1
thg 5 25
2936