This question has been flagged

hi all,

i have inheritted model 'res.users', added 3 fields. for zone_id (Many2one) i wants to inherit /addons/auth_signup/controllers/main.py and implement my code, i want guidance as it is difficult for me as beginner and as per its odoo's very important controller. my model file and code for the controller file are below, please have your expert opinion and guidance where it needed. the Manu2one zone_id is empty when run Signup:  form http://localhost:8069/web/signup

model:

class ResUsersExt(models.Model):
    _inherit = 'res.users'
    contact_no = fields.Char(string='Contact No.')
    address = fields.Text(string='Your Address', required=True, default='00')
    zone_id = fields.Many2one('tests.zones', string="Your Zone", required=True, default="1")

controller:

from odoo.addons.auth_signup.controllers.main import AuthSignupHome
class AuthSignupHome(AuthSignupHome):
    @http.route('/web/signup', type='http', auth='public', website=True, sitemap=False)
    def zone_fill (self, **kw):
       zone_rec = request.env['tests.zones'].sudo().search([])
       return http.request.render('auth_signup.signup', {'zone_rec':zone_rec})

my xml template code for zone_id:

                <div class="form-group">
                    <label for="zone_id" class="control-label">Zone</label>
                    <select name="zone_id" class="form-control link-style">
                        <t t-foreach="zone_rec" t-as="zone">
                            <option t-esc="zone.name" t-att-value="zone.id"/>
                        </t>
                    </select>
                </div>

regards

Avatar
Discard
Best Answer

Hi,

You can inheriting the controllers in Odoo, have a look at this existing thread: https://www.odoo.com/forum/help-1/how-to-inherit-controller-in-odoo-12-148217

Sample Code From Above Link:

from odoo import http
from odoo.addons.sale.controllers.onboarding import OnboardingController # Import the class


class CustomOnboardingController(OnboardingController): # Inherit in your custom class

@http.route('/sales/sale_quotation_onboarding_panel', auth='user', type='json')
def sale_quotation_onboarding(self):
res = super(CustomOnboardingController, self).sale_quotation_onboarding()
# Your code goes here
return res


As you are looking to add new fields to the signup form you can refer the free apps in the odoo apps store, which brings/add the new field to signup form, you can have a look at the coding done for those modules.

Modules:

  1. Additional Fields Signup Form

  2. Sign-up Form with Extra Fields


To Inherit any controller in Odoo, see:

  1. How To Inherit Existing Controller in Odoo

  2. Q Context In Odoo


Thanks

Avatar
Discard
Author

@Niyas Raphy, i tried to follow the video you have posted in my previous question but still failed to have it. in the links of Extra/Additional fields in Signup Form there is no sampel/example of Many2one field as my ZONE_ID field which should populate with data to SELECT by user on SIGNUP.