[ADD]Create Portal User From res.partner Kafeel
This commit is contained in:
parent
4d9ef96e53
commit
f01884f175
|
|
@ -43,7 +43,7 @@
|
|||
'views/payment_details_lines_views.xml',
|
||||
'wizards/account_payment_register.xml',
|
||||
'views/res_partner_bank.xml',
|
||||
|
||||
'views/res_users_inherit.xml',
|
||||
|
||||
'views/takaful_push_notification_view.xml',
|
||||
'views/takaful_grant_benefit_view.xml',
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ class ResPartner(models.Model):
|
|||
readonly=True
|
||||
)
|
||||
|
||||
kafel_id = fields.Many2one('res.users')
|
||||
|
||||
_sql_constraints = [
|
||||
('id_number_uniq', 'unique (id_number)', 'The ID Number Already Exist!'),
|
||||
|
|
@ -258,8 +259,22 @@ class ResPartner(models.Model):
|
|||
if context.get('parent_model') == 'takaful.sponsorship' and context.get('parent_id'):
|
||||
parent_record = self.env[context['parent_model']].browse(context['parent_id'])
|
||||
parent_record.sponsor_id = res.id
|
||||
if not res.user_id and res.type == 'person':
|
||||
res.sudo().create_user()
|
||||
|
||||
|
||||
if 'is_sponsor_portal' in values or 'is_donor' in values:
|
||||
if values['is_sponsor_portal'] == True or values['is_donor'] == True :
|
||||
if res.mobile != False:
|
||||
kafeel = self.env['res.users'].with_user(2).create({
|
||||
'name' : values['name'],
|
||||
'branch_custom_id':values['branch_custom_id'],
|
||||
'sel_groups_1_9_10' : 9,
|
||||
'partner_id' : res.id,
|
||||
'login' : values['mobile'],
|
||||
'otp_mobile_phone' : values['mobile'],
|
||||
'otp_enabled' : True,
|
||||
})
|
||||
res.kafel_id = kafeel
|
||||
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
|
|
@ -429,4 +444,4 @@ class ResPartnerBank(models.Model):
|
|||
else:
|
||||
name = f"{bank.acc_number}"
|
||||
result.append((bank.id, name))
|
||||
return result
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -1137,6 +1137,8 @@ class TakafulSponsorship(models.Model):
|
|||
# Create the record
|
||||
res = super(TakafulSponsorship, self).create(vals)
|
||||
|
||||
|
||||
|
||||
return res
|
||||
|
||||
def write(self, vals):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
<odoo>
|
||||
|
||||
<record id="res_users_inherit_EXP" model="ir.ui.view">
|
||||
<field name="name">res_users_inherit_EXP</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="branch.view_users_form_inherit_branch"/>
|
||||
<field name="arch" type="xml">
|
||||
|
||||
<xpath expr="//group[2]" position="after">
|
||||
<!-- Add your fields or attributes here -->
|
||||
|
||||
<group>
|
||||
<field name="branch_custom_id"/>
|
||||
</group>
|
||||
|
||||
</xpath>
|
||||
|
||||
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
|
@ -89,7 +89,9 @@
|
|||
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
|
||||
</div>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<field name="kafel_id" readonly="1"/>
|
||||
</group>
|
||||
<group name="group_top">
|
||||
<group name="group_main" colspan="2">
|
||||
<field name="mobile" string="رقم الجوال" widget="phone" placeholder="05xxxxxxxx" attrs="{'required': [('parent_id', '=', False)]}"/>
|
||||
|
|
@ -257,4 +259,4 @@
|
|||
<field name="code">records.on_activate_sponsor_multi()</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
</odoo>
|
||||
|
|
|
|||
Loading…
Reference in New Issue