# -*- coding: utf-8 -*- from odoo import http from odoo.http import request class PartnerForm(http.Controller): # mention class name @http.route(['/campaign/view'], type='http', auth="user", website=True) # mention a url for redirection. # define the type of controllers which in this case is ‘http’. # mention the authentication to be either public or user. def campaign_view(self, **post): # create method # this will load the form webpage name = 'ss gamal eh' name =' '.join(name.split()).replace(' ','%20') # name = name.replace(' ', '%20') # name = name.replace(' ', '%20') print(name) campaigns = request.env['campaign.campaign'].search([('state','=','بإنتظار الإعتماد'),('create_uid','=',request.session.uid)]) return request.render("ensan_campaign.campaigns", {'campaigns':campaigns}) @http.route(['/campaign/view2'], type='http', auth="user", website=True) # mention a url for redirection. # define the type of controllers which in this case is ‘http’. # mention the authentication to be either public or user. def campaign_view2(self, **post): # create method # this will load the form webpage campaigns = request.env['campaign.campaign'].search([('state', '=', 'نشطة'),('create_uid','=',request.session.uid)]) return request.render("ensan_campaign.campaigns2", {'campaigns': campaigns}) @http.route(['/campaign/view3'], type='http', auth="user", website=True) # mention a url for redirection. # define the type of controllers which in this case is ‘http’. # mention the authentication to be either public or user. def campaign_view3(self, **post): # create method # this will load the form webpage campaigns = request.env['campaign.campaign'].search([('state', '=', 'غير نشطة'),('create_uid','=',request.session.uid)]) return request.render("ensan_campaign.campaigns3", {'campaigns': campaigns}) @http.route(['/campaign/form'], type='http', auth="user", website=True) # mention a url for redirection. # define the type of controllers which in this case is ‘http’. # mention the authentication to be either public or user. def partner_form(self, **post): # create method # this will load the form webpage product_categories = request.env['product.public.category'].sudo().search([]) return request.render("ensan_campaign.tmp_campaign_form", {'selection_options':['رعاية الأيتام'],'categories':product_categories}) @http.route(['/campaign/form/submit'], type='http', auth="user", website=True) # next controllers with url for submitting data from the form# def customer_form_submit(self, **post): campaign = request.env['campaign.campaign'].sudo().create({ 'campaign_name': post.get('اسم الحمله'), 'donation_amount': post.get('المبلغ المستهدف'), 'remaining_amount': post.get('المبلغ المستهدف'), 'category_id': post.get('مجال التبرع'), 'user_id':request.session.uid, # 'phone': post.get('phone') }) vals = { 'campaign': campaign, } # inherited the model to pass the values to the model from the form# return request.render("ensan_campaign.tmp_campaign_form_success", vals) # finally send a request to render the thank you page#