Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
3005 Zobrazení

i want to add to add new field "arabic_name" to  signup page i add the field in res.partner
,add it to the sign up view , and override the def_prepare_signup_values  and add my new field 
but the field in the sign up deoen't stored or related to the field on res.partner 
what i do 

1-override  _prepare_signup_values function

class ExtendAuthSignupHome(AuthSignupHome):
​def _prepare_signup_values(self, qcontext):
​values = { key: qcontext.get(key) for key in ('login', 'name', 'password' , 'arabic_name') }
​if not values:
​raise UserError(_("The form was not properly filled in."))
​if values.get('password') != qcontext.get('confirm_password'):
​raise UserError(_("Passwords do not match; please retype them."))
​supported_lang_codes = [code for code, _ in request.env['res.lang'].get_installed()]
​lang = request.context.get('lang', '')
​if lang in supported_lang_codes:
​values['lang'] = lang
​return values

=========================
2-add field to res.partner
class MoreField(models.Model):
​_inherit = 'res.partner'
​arabic_name = fields.Char(string="Name In Arabic")

=====================
3-add field to the signup view
expr="//div[@class='form-group field-name']" position="after">

class="form-group field-name2">

​type="text" name="arabic_name" t-att-value="arabic_name" id="arabic_name" ​class="form-control form-control-sm" placeholder="e.g. أحمد على"
​required="required" t-att-readonly="'readonly' if only_passwords else None"
​t-att-autofocus="'autofocus' if login and not only_passwords else None" />


Avatar
Zrušit
Nejlepší odpověď

Hi,

Instead of overriding the def_prepare_signup_values and adding your new field  override def web_auth_signup and try this method.

@http.route('/web/signup', type='http', auth='public', website=True, sitemap=False) 
def web_auth_signup(self, *args, **kw): 
qcontext = self.get_auth_signup_qcontext() 
web_company = request.env.company 
res = super(AuthSignupHomePage, self).web_auth_signup() 
user = request.env['res.users'].sudo().search([("login", "=", qcontext.get("login"))])
user.sudo().write({
‘arabic_name’: kw.get(‘arabic_name’) 
})
return res

Regards

Avatar
Zrušit
Autor

it works thanks alot

Related Posts Odpovědi Zobrazení Aktivita
1
bře 15
9927
3
čvn 24
3068
0
dub 24
1825
1
bře 23
3461
1
lis 17
5405