跳至内容
菜单
此问题已终结
1 回复
3031 查看
最佳答案

Hi,

You can create a website form which takes all the product information which is to be created through website as inputs.All input values of the form will be available in the controller of the form action route.Then you can create a new record in the product model using create method by passing all the input values of the form


Eg:


< form action="/create_product" method="post">

   < input type="hidden" name="csrf_token" t-att-value="request.csrf_token()"/>

   < div class="clearfix">

       < button type="submit" class="btn btn-primary float-right mb32 ">

           Confirm

           < span class="fa fa-long-arrow-right"/>

       < /button>

   < /div>

   < div class="row o_portal_details">

       < div class="col-lg-8">

           < div class="row">

               < div t-attf-class="form-group col-xl-6">

                   < label class="col-form-label" for="name">Name

                   < input type="text" name="name" t-attf-class="form-control"/>

               < /div>

           < /div>

       < /div>

   < /div>

< /form> 





Controller method :


@route(['/create_product], type='http', auth='user', website=True)

def form_submit(self, **post):

   product = request.env[product.template].sudo().create({

       name: post['name'],

       'field_2': post['field2'],

       ………….

   })

Hope it helps

形象
丢弃
相关帖文 回复 查看 活动
3
11月 18
3284
0
3月 15
3784
0
8月 22
1369
0
6月 21
2488
4
12月 23
19509