Merge branch 'dev_odex25_ensan' of https://github.com/expsa/odex25-standard-modules into samir-aladawi-change-partner-account-type-logic

This commit is contained in:
Samir Ladoui 2025-09-18 11:28:29 +01:00
commit b27b032eff
12 changed files with 243 additions and 228 deletions

View File

@ -2,6 +2,8 @@
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from datetime import datetime
from odoo.exceptions import UserError, ValidationError
class EmpowermentRequest(models.Model):
@ -118,6 +120,12 @@ class EmpowermentRequest(models.Model):
string="Qualifications"
)
def unlink(self):
for order in self:
if order.state not in ['draft']:
raise UserError(_('You cannot delete this record State not Draft'))
return super(EmpowermentRequest, self).unlink()
@api.model
def create(self, vals):

View File

@ -201,8 +201,6 @@
<field name="service_link_id" readonly="1" />
</xpath>
</field>
</record>

View File

@ -530,17 +530,17 @@ msgstr "نوع البرنامج"
#. module: odex25_program_activity
#: model:ir.model.fields.selection,name:odex25_program_activity.selection__pa_program_level_type__route
#: model:ir.model.fields.selection,name:odex25_program_activity.selection__pa_program_level__type__route
msgid "Tracks"
msgstr "مسارات "
#. module: odex25_program_activity
#: model:ir.model.fields.selection,name:odex25_program_activity.selection__pa_program_level_type__activity
#: model:ir.model.fields.selection,name:odex25_program_activity.selection__pa_program_level__type__activity
msgid "Activities"
msgstr "أنشطة"
#. module: odex25_program_activity
#: model:ir.model.fields.selection,name:odex25_program_activity.selection__pa_program_level_type__medad
#: model:ir.model.fields.selection,name:odex25_program_activity.selection__pa_program_level__type__medad
msgid "Medad"
msgstr "مداد"

View File

@ -1,5 +1,7 @@
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError, ValidationError
class PaProgramLevel(models.Model):
@ -409,6 +411,12 @@ class PaProgramActivityRegistration(models.Model):
rejection_reason = fields.Text('سبب الارجاع') # To hold the last rejection note
def unlink(self):
for order in self:
if order.state not in ['draft']:
raise UserError(_('You cannot delete this record State not Draft'))
return super(PaProgramActivityRegistration, self).unlink()
@api.onchange('familye_id')
def _onchange_familye_id(self):
if self.familye_id:

View File

@ -389,7 +389,7 @@
<page string="بيانات المستفيد">
<field name="member_ids" widget="one2many_list"
readonly="0" edit="0" create="0">
readonly="1" edit="0" create="0">
<form string="Family Member">
<widget name="web_ribbon" title="Non Benefit Member" bg_color="bg-danger"
attrs="{'invisible': [('member_status', '!=', 'non_benefit')]}"/>
@ -553,7 +553,7 @@
</notebook>
</sheet>
</form>
<tree string="Family Members">
<tree string="Family Members" delete="0" create="0" edit="0">
<field name="name" force_save="1"/>
<!-- <field name="gender" required="1"/>-->
<field name="relationn"/>

View File

@ -10371,6 +10371,11 @@ msgstr "تم تحديد الموعد"
msgid "Schedule a visit"
msgstr "جاري الزيارة"
#. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__visit_location__state__pending
msgid "Pending"
msgstr "معلق"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_program_plane_line__score
msgid "Score"

View File

@ -63,6 +63,8 @@ class GrantBenefitProfile(models.Model):
('benefit', 'Benefit'),
('non_benefit', 'Non Benefit'),
], string='Mother Status', compute="check_mother_status", store=True, default=False)
mother_salary_certificate = fields.Many2many('ir.attachment', 'mother_member_salary_cert_rel', 'mother_grant_benefit_id', 'attachment_id',
string="Salary Certificate")
phone2 = fields.Char(string="Phone2")
relative_phone = fields.Char(string="Relative Phone")
relative_relation = fields.Char(string="Relative Relation")
@ -542,6 +544,9 @@ class GrantBenefitProfile(models.Model):
('benefit', 'Benefit'),
('non_benefit', 'Non Benefit'),
], string='Replacement Mother Status', compute="check_replacement_mother_status", store=True, default=False)
replacement_mother_salary_certificate = fields.Many2many('ir.attachment', 'replacement_mother_member_salary_cert_rel',
'replacement_mother_grant_benefit_id', 'attachment_id',
string="Salary Certificate")
# Education_data for replacement mother
replacement_education_status_ids = fields.One2many('education.status', 'replacement_grant_benefit_id')
replacement_education_status = fields.Selection(
@ -1038,7 +1043,7 @@ class GrantBenefitProfile(models.Model):
# Check for uniqueness against `member_id_number` in child records and across database records
for member in self.member_ids:
if member.member_id_number and member.member_id_number in unique_ids:
if member.member_id_number and member.member_id_number in unique_ids and member.id not in [self.mother_family_member_id.id,self.replacement_mother_family_member_id.id]:
raise ValidationError(_("The ID number %s in the Family Members list must be unique across the record.")%member.member_id_number)
# Check for duplicate IDs across records in the database
for id_number in unique_ids:
@ -1064,7 +1069,7 @@ class GrantBenefitProfile(models.Model):
if conflict:
raise ValidationError(_("The ID number %s already exists in family with code %s.") %
(id_number, conflict.code))
duplicate_record_member = self.env['family.member'].search([('member_id_number', '=', id_number)], limit=1)
duplicate_record_member = self.env['family.member'].search([('member_id_number', '=', id_number),('id', 'not in', [self.mother_family_member_id.id, self.replacement_mother_family_member_id.id])], limit=1)
if duplicate_record_member :
raise ValidationError(_("The ID number {} already exists in family with code {}. Please enter a unique ID number.").format(id_number, duplicate_record_member.code))
@ -1127,19 +1132,19 @@ class GrantBenefitProfile(models.Model):
rec.mother_status = False
if rec.mother_location_conf and rec.mother_marital_conf:
if not rec.mother_location_conf.is_benefit or not rec.mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
rec.write({'mother_status':'non_benefit'})
rec.mother_status = 'non_benefit'
elif rec.mother_marital_conf.is_benefit :
if rec.is_mother_work and rec.mother_country_id.code == 'SA' or (
rec.mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
if mini_income_for_mother < rec.mother_income <= max_income_for_mother:
rec.write({'mother_status': 'non_benefit'})
rec.mother_status = 'non_benefit'
elif rec.mother_income <= mini_income_for_mother:
rec.write({'mother_status': 'benefit'})
rec.mother_status = 'benefit'
elif rec.mother_income > max_income_for_mother:
rec.write({'mother_status': 'benefit'})
rec.mother_status = 'benefit'
elif not rec.is_mother_work and rec.mother_country_id.code == 'SA' or (
rec.mother_country_id.code != 'SA' and rec.father_country_id.code == 'SA'):
rec.write({'mother_status': 'benefit'})
rec.mother_status = 'benefit'
@api.depends('replacement_mother_marital_conf', 'replacement_mother_income', 'replacement_mother_location_conf', 'replacement_mother_country_id', 'state')
@ -1148,7 +1153,9 @@ class GrantBenefitProfile(models.Model):
mini_income_for_mother = validation_setting.mini_income_for_mother
max_income_for_mother = validation_setting.max_income_for_mother
for rec in self:
rec.replacement_mother_status = False
rec.replacement_mother_status = 'non_benefit'
if not rec.add_replacement_mother:
continue
if not rec.replacement_mother_location_conf.is_benefit or not rec.replacement_mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
rec.replacement_mother_status = 'non_benefit'
elif rec.replacement_mother_marital_conf.is_benefit:
@ -1201,22 +1208,11 @@ class GrantBenefitProfile(models.Model):
if 'salary_ids' in fields:
res['salary_ids'] = income_attachments_data
return res
def write(self, vals):
# mother_education_status = vals.get("education_status", False) or self.education_status
# if mother_education_status == "educated" and "mother_education_status_ids" not in vals and not len(self.mother_education_status_ids):
# raise ValidationError(
# _("You should at least insert one current/previous mother education status!")
# )
# replacement_education_status = vals.get("replacement_education_status", False) or self.replacement_education_status
# if replacement_education_status == "educated" and "replacement_education_status_ids" not in vals and not len(self.replacement_education_status_ids):
# raise ValidationError(
# _("You should at least insert one current/previous mother education status!")
# )
res = super(GrantBenefitProfile, self).write(vals)
if "name" in vals and self.user_id:
self.user_id.sudo().write({"name": vals.get("name")})
# res = super(GrantBenefitProfile, self).write(vals)
if any(field in vals for field in ["name", "first_name", "second_name", "middle_name", "family_name",
"father_name", "father_second_name", "father_third_name",
"father_family_name"]):
@ -1226,6 +1222,32 @@ class GrantBenefitProfile(models.Model):
record.sudo().user_id.write({"name": record.partner_id.name})
if not self.env.context.get('force_website', False) and not self.env.context.get('bypass_attachments_requirement', False):
self._validate_required_attachments()
# Handle mother update/create
mother_fields = [
'mother_name', 'mother_second_name', 'mother_third_name', 'mother_family_name', 'mother_id_number',
'mother_birth_date', 'mother_marital_conf', 'mother_location_conf', 'is_mother_work',
'mother_income', 'mother_age','education_status','mother_diseases_attachment_ids',
'mother_education_status_ids','mother_disabilities_attachment_ids'
]
if any(field in vals for field in mother_fields):
for rec in self:
rec.add_or_replace_mother_as_member()
# Handle replacement mother update/create
replacement_fields = [
'replacement_mother_name', 'replacement_mother_second_name', 'replacement_mother_third_name',
'replacement_mother_family_name','replacement_mother_id_number',
'replacement_mother_birth_date', 'replacement_mother_marital_conf',
'replacement_mother_location_conf','replacement_mother_relation',
'replacement_is_mother_work', 'replacement_mother_income', 'replacement_education_status',
'replacement_mother_age','replacement_mother_disabilities_attachment_ids',
'replacement_education_status_ids', 'replacement_mother_diseases_attachment_ids'
]
if any(field in vals for field in replacement_fields):
for rec in self:
if rec.add_replacement_mother:
rec.add_or_replace_replacement_mother_as_member()
return res
@api.model
@ -1243,9 +1265,10 @@ class GrantBenefitProfile(models.Model):
res.code = self.env['ir.sequence'].sudo().next_by_code('benefit.sequence') or _('New')
# Add mother
if res.mother_id_number:
res.add_mother_as_member()
res.add_or_replace_mother_as_member()
# Add replacement mother
if res.add_replacement_mother and res.replacement_mother_id_number:
res.add_replacement_mother_as_member()
res.add_or_replace_replacement_mother_as_member()
return res
def unlink(self):
@ -1310,20 +1333,7 @@ class GrantBenefitProfile(models.Model):
#
# if rec.member_income == 0.0:
# raise ValidationError(_("يرجى اكمال ادخال او الموافقة على القيم المرتبطة ببيانات الدخل والمرتب والالتزامات لتحديد فئة الاسرة بشكل صحيح"))
rec.validate_attachments()
mother_exist = self.env["family.member"].search([('member_id_number', '=', rec.mother_id_number),('relationn.relation_type','=','mother')], limit=1)
replacement_mother_exist = self.env["family.member"].search([('member_id_number', '=', rec.replacement_mother_id_number),('relationn.relation_type','=','replacement_mother')], limit=1)
if not mother_exist:
rec.add_mother_as_member()
if mother_exist:
rec.replace_mother_as_member(mother_exist.id)
if rec.add_replacement_mother:
if not replacement_mother_exist:
rec.add_replacement_mother_as_member()
if replacement_mother_exist:
rec.replace_replacement_mother_as_member(replacement_mother_exist.id)
self.state = 'waiting_approve'
def action_first_accepted(self):
@ -1853,111 +1863,11 @@ class GrantBenefitProfile(models.Model):
else:
name = name
return name
def add_mother_as_member(self):
for rec in self:
mother_name = rec.get_mother_name()
val = {
'name': mother_name,
'mother_first_name': rec.mother_name,
'mother_second_name': rec.mother_second_name,
'mother_third_name': rec.mother_third_name,
'mother_family_name': rec.mother_family_name,
'member_id_number': rec.mother_id_number,
'is_mother':True,
'birth_date': rec.mother_birth_date,
'gender': 'female',
'relationn': self.env['relation.settings'].search([('relation_type','=','mother')]).id,
'mother_marital_conf': rec.mother_marital_conf.id,
'mother_location_conf': rec.mother_location_conf.id,
'age': rec.mother_age,
'is_work': rec.is_mother_work,
'member_income': rec.mother_income,
'education_status': rec.education_status,
'member_education_status_ids': [(5, 0)] + [(4, mother_education_id.id) for mother_education_id in rec.mother_education_status_ids],
'case_study': rec.case_study,
'education_entity': rec.education_entity,
'last_education_entity': rec.last_education_entity,
'entities': rec.entities.id,
'last_entities': rec.last_entities.id,
'education_levels': rec.education_levels.id,
'last_education_levels': rec.last_education_levels.id,
'specialization_ids': rec.specialization_ids.id,
'last_specialization_ids': rec.last_specialization_ids.id,
'classroom': rec.classroom.id,
'last_classroom': rec.last_classroom.id,
'degree': rec.degree.id,
'last_degree': rec.last_degree.id,
'percentage': rec.percentage,
'last_percentage': rec.last_percentage,
'weak_study': rec.weak_study.ids,
'member_status': rec.mother_status,
'education_start_date':rec.education_start_date,
'education_end_date':rec.education_end_date,
'educational_certificate':rec.educational_certificate,
'last_education_start_date': rec.last_education_start_date,
'last_education_end_date': rec.last_education_end_date,
'last_educational_certificate': rec.last_educational_certificate,
'benefit_id': rec.id,
}
mother_family_member_id = self.env['family.member'].create(val)
rec.write({'mother_family_member_id': mother_family_member_id.id})
for r in rec.mother_diseases_attachment_ids:
r.write({'member_id': mother_family_member_id.id})
for r in rec.mother_disabilities_attachment_ids:
r.write({'member_id': mother_family_member_id.id})
def add_replacement_mother_as_member(self):
for rec in self:
mother_name = rec.get_replacement_mother_name()
val = {
'name': mother_name,
'mother_first_name': rec.replacement_mother_name,
'mother_second_name': rec.replacement_mother_second_name,
'mother_third_name': rec.replacement_mother_third_name,
'mother_family_name': rec.replacement_mother_family_name,
'member_id_number': rec.replacement_mother_id_number,
'is_mother':True,
'birth_date': rec.replacement_mother_birth_date,
'gender': 'female',
'relationn': rec.replacement_mother_relation.id,
'mother_marital_conf': rec.replacement_mother_marital_conf.id,
'mother_location_conf': rec.replacement_mother_location_conf.id,
'age': rec.replacement_mother_age,
'is_work': rec.replacement_is_mother_work,
'member_income': rec.replacement_mother_income,
'education_status': rec.replacement_education_status,
'case_study': rec.replacement_case_study,
'education_entity': rec.replacement_education_entity,
'member_education_status_ids': [(5, 0)] + [(4, replacement_education_id.id) for replacement_education_id in rec.replacement_education_status_ids],
'last_education_entity': rec.replacement_last_education_entity,
'entities': rec.replacement_entities.id,
'last_entities': rec.replacement_last_entities.id,
'education_levels': rec.replacement_education_levels.id,
'last_education_levels': rec.replacement_last_education_levels.id,
'specialization_ids': rec.replacement_specialization_ids.id,
'last_specialization_ids': rec.replacement_last_specialization_ids.id,
'classroom': rec.replacement_classroom.id,
'last_classroom': rec.replacement_last_classroom.id,
'degree': rec.replacement_degree.id,
'last_degree': rec.replacement_last_degree.id,
'percentage': rec.replacement_percentage,
'weak_study': rec.replacement_weak_study.ids,
'member_status': rec.replacement_mother_status,
'education_start_date': rec.replacement_education_start_date,
'education_end_date': rec.replacement_education_end_date,
'educational_certificate': rec.replacement_educational_certificate,
'last_education_start_date': rec.replacement_last_education_start_date,
'last_education_end_date': rec.replacement_last_education_end_date,
'last_educational_certificate': rec.replacement_last_educational_certificate,
}
replacement_mother_family_member_id = self.env['family.member'].create(val)
rec.write({'replacement_mother_family_member_id': replacement_mother_family_member_id.id})
for r in rec.replacement_mother_diseases_attachment_ids:
r.write({'member_id': replacement_mother_family_member_id.id})
for r in rec.replacement_mother_disabilities_attachment_ids:
r.write({'member_id': replacement_mother_family_member_id.id})
def add_or_replace_mother_as_member(self):
FamilyMember = self.env['family.member']
Relation = self.env['relation.settings'].search([('relation_type', '=', 'mother')], limit=1)
def replace_mother_as_member(self, id):
for rec in self:
mother_name = rec.get_mother_name()
val = {
@ -1970,47 +1880,31 @@ class GrantBenefitProfile(models.Model):
'is_mother': True,
'birth_date': rec.mother_birth_date,
'gender': 'female',
'relationn': self.env['relation.settings'].search([('relation_type','=','mother')]).id,
'relationn': Relation.id,
'mother_marital_conf': rec.mother_marital_conf.id,
'mother_location_conf': rec.mother_location_conf.id,
'age': rec.mother_age,
'is_work': rec.is_mother_work,
'member_income': rec.mother_income,
'education_status': rec.education_status,
'member_education_status_ids': [(5, 0)] + [(4, mother_education_id.id) for mother_education_id in rec.mother_education_status_ids],
'case_study': rec.case_study,
'education_entity': rec.education_entity,
'last_education_entity': rec.last_education_entity,
'entities': rec.entities.id,
'last_entities': rec.last_entities.id,
'education_levels': rec.education_levels.id,
'last_education_levels': rec.last_education_levels.id,
'specialization_ids': rec.specialization_ids.id,
'last_specialization_ids': rec.last_specialization_ids.id,
'classroom': rec.classroom.id,
'last_classroom': rec.last_classroom.id,
'degree': rec.degree.id,
'last_degree': rec.last_degree.id,
'percentage': rec.percentage,
'last_percentage': rec.last_percentage,
'weak_study': rec.weak_study.ids,
'member_status': rec.mother_status,
'education_start_date': rec.education_start_date,
'education_end_date': rec.education_end_date,
'educational_certificate': rec.educational_certificate,
'last_education_start_date': rec.last_education_start_date,
'last_education_end_date': rec.last_education_end_date,
'last_educational_certificate': rec.last_educational_certificate,
#'member_status': rec.mother_status,
'member_education_status_ids': [(5, 0)] + [(4, edu.id) for edu in rec.mother_education_status_ids],
'salary_certificate': [(6, 0, rec.mother_salary_certificate.ids)],
}
mother_family_member_id = rec.mother_family_member_id
if mother_family_member_id:
mother_family_member_id.write(val)
for r in rec.mother_diseases_attachment_ids:
r.write({'member_id': mother_family_member_id.id})
for r in rec.mother_disabilities_attachment_ids:
r.write({'member_id': mother_family_member_id.id})
def replace_replacement_mother_as_member(self, id):
mother_family_member = rec.mother_family_member_id
if mother_family_member:
mother_family_member.write(val)
else:
val['benefit_id'] = rec.id
mother_family_member = FamilyMember.create(val)
rec.write({'mother_family_member_id': mother_family_member.id})
rec.mother_diseases_attachment_ids.write({'member_id': mother_family_member.id})
rec.mother_disabilities_attachment_ids.write({'member_id': mother_family_member.id})
def add_or_replace_replacement_mother_as_member(self):
FamilyMember = self.env['family.member']
for rec in self:
mother_name = rec.get_replacement_mother_name()
val = {
@ -2020,7 +1914,7 @@ class GrantBenefitProfile(models.Model):
'mother_third_name': rec.replacement_mother_third_name,
'mother_family_name': rec.replacement_mother_family_name,
'member_id_number': rec.replacement_mother_id_number,
'is_mother': True,
'is_mother': False,
'birth_date': rec.replacement_mother_birth_date,
'gender': 'female',
'relationn': rec.replacement_mother_relation.id,
@ -2030,38 +1924,21 @@ class GrantBenefitProfile(models.Model):
'is_work': rec.replacement_is_mother_work,
'member_income': rec.replacement_mother_income,
'education_status': rec.replacement_education_status,
'member_education_status_ids': [(5, 0)] + [(4, replacement_education_id.id) for replacement_education_id in rec.replacement_education_status_ids],
'case_study': rec.replacement_case_study,
'education_entity': rec.replacement_education_entity,
'last_education_entity': rec.replacement_last_education_entity,
'entities': rec.replacement_entities.id,
'last_entities': rec.replacement_last_entities.id,
'education_levels': rec.replacement_education_levels.id,
'last_education_levels': rec.replacement_last_education_levels.id,
'specialization_ids': rec.replacement_specialization_ids.id,
'last_specialization_ids': rec.replacement_last_specialization_ids.id,
'classroom': rec.replacement_classroom.id,
'last_classroom': rec.replacement_last_classroom.id,
'degree': rec.replacement_degree.id,
'last_degree': rec.replacement_last_degree.id,
'percentage': rec.replacement_percentage,
'last_percentage': rec.replacement_last_percentage,
'weak_study': rec.replacement_weak_study.ids,
'member_status': rec.replacement_mother_status,
'education_start_date': rec.replacement_education_start_date,
'education_end_date': rec.replacement_education_end_date,
'educational_certificate': rec.replacement_educational_certificate,
'last_education_start_date': rec.replacement_last_education_start_date,
'last_education_end_date': rec.replacement_last_education_end_date,
'last_educational_certificate': rec.replacement_last_educational_certificate,
#'member_status': rec.replacement_mother_status,
'member_education_status_ids': [(5, 0)] + [(4, edu.id) for edu in rec.replacement_education_status_ids],
'salary_certificate': [(6, 0, rec.replacement_mother_salary_certificate.ids)],
}
replacement_mother_family_member_id = rec.replacement_mother_family_member_id
if replacement_mother_family_member_id:
replacement_mother_family_member_id.write(val)
for r in rec.replacement_mother_diseases_attachment_ids:
r.write({'member_id': replacement_mother_family_member_id.id})
for r in rec.replacement_mother_disabilities_attachment_ids:
r.write({'member_id': replacement_mother_family_member_id.id})
if rec.replacement_mother_family_member_id:
rec.replacement_mother_family_member_id.write(val)
replacement_member = rec.replacement_mother_family_member_id
else:
val['benefit_id'] = rec.id
replacement_member = FamilyMember.create(val)
rec.write({'replacement_mother_family_member_id': replacement_member.id})
rec.replacement_mother_diseases_attachment_ids.write({'member_id': replacement_member.id})
rec.replacement_mother_disabilities_attachment_ids.write({'member_id': replacement_member.id})
def get_members_count(self):
for ben in self:

View File

@ -659,11 +659,12 @@ class ResDistricts(models.Model):
class VisitsSettings(models.Model):
_name = 'visits.types'
name = fields.Char(string="Name")
name = fields.Char(string="Name",required=True)
creation_method = fields.Selection(
[('manual', 'Manual'),('automatic', 'Automatic')],
string="Creation Method",
default='manual',
required=True,
help="Whether the visit is entered manually or created automatically"
)
recurrence_interval = fields.Integer(

View File

@ -76,7 +76,7 @@ class EducationStatus(models.Model):
)
def _compute_education_status(self):
for record in self:
record.field = record.mother_grant_benefit_id.education_status or\
record.education_status = record.mother_grant_benefit_id.education_status or\
record.replacement_grant_benefit_id.replacement_education_status or\
record.family_member_id.education_status

View File

@ -36,7 +36,10 @@ class Visit(models.Model):
], string='Visit Objective')
visit_types = fields.Many2one(
'visits.types',
string='Visits Types')
string='Visits Types',
ondelete="restrict"
)
evaluation = fields.Selection(
[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6')],
string='Evaluation')
@ -44,6 +47,7 @@ class Visit(models.Model):
('draft', 'Draft'),
('contact', 'Contact'),
('schedule_a_visit', 'Schedule a visit'),
('pending', 'Pending'),
('done', 'Done'),
('close', 'Close'),
('cancel', 'Cancel'),
@ -59,6 +63,43 @@ class Visit(models.Model):
response_count = fields.Integer(compute="_compute_response_count", store=True, string="Responses Count", copy=False)
survey_url = fields.Char(string="Survey URL")
# added by eslam
# def action_postpone(self):
# """Open wizard to postpone"""
# return {
# 'name': _('Postpone Visit'),
# 'type': 'ir.actions.act_window',
# 'res_model': 'visit.postpone.wizard',
# 'view_mode': 'form',
# 'target': 'new',
# 'context': {'default_visit_id': self.id},
# }
#
# def action_reschedule(self):
# for rec in self:
# rec.state = "contact"
#
# def action_create_new_visit(self):
# for rec in self:
# new_visit = self.create({
# 'creation_type': rec.creation_type,
# 'visit_types': rec.visit_types.id,
# 'benefit_id': rec.benefit_id.id,
# 'researcher_ids': [(6, 0, rec.researcher_ids.ids)],
# 'visit_date': fields.Datetime.now(),
# 'state': 'draft',
# })
# return {
# 'type': 'ir.actions.act_window',
# 'res_model': 'visit.location',
# 'view_mode': 'form',
# 'res_id': new_visit.id,
# }
# added by eslam
@api.depends('response_id')
def _compute_response_count(self):
for rec in self:
@ -352,3 +393,24 @@ class MemberEducationStatus(models.Model):
_name = 'member.education.status'
name = fields.Char()
class VisitPostponeWizard(models.TransientModel):
_name = "visit.postpone.wizard"
_description = "Postpone Visit Wizard"
visit_id = fields.Many2one("visit.location", string="Visit", required=True, readonly=True)
reason = fields.Text(string="Reason", required=True)
notes = fields.Text(string="Notes")
def action_confirm_postpone(self):
"""Confirm postpone and set state to pending"""
for wizard in self:
if not wizard.reason:
raise ValidationError(_("You must provide a reason to postpone."))
visit = wizard.visit_id
visit.write({
"state": "pending",
"reason": wizard.reason,
"message": wizard.notes,
})
return {"type": "ir.actions.act_window_close"}

View File

@ -428,14 +428,14 @@
<group>
<label for="mother_name" string="Mother Name"/>
<div class="o_row">
<field name="mother_name" nolabel="1" placeholder="First Name"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_second_name" nolabel="1" placeholder="Second Name"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_third_name" nolabel="1" placeholder="Third Name"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_family_name" nolabel="1" placeholder="Family Name"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_name" nolabel="1" placeholder="First Name" required="1"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_second_name" nolabel="1" placeholder="Second Name" required="1"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_third_name" nolabel="1" placeholder="Third Name" required="1"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_family_name" nolabel="1" placeholder="Family Name" required="1"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
</div>
</group>
<group/>
@ -511,11 +511,14 @@
readonly="1"/>
<field name="is_mother_work"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_salary_certificate"
widget="many2many_attachment_preview"
attrs="{'invisible':[('is_mother_work','=',False)]}"/>
<field name="mother_has_disabilities" invisible="1"/>
<field name="mother_income" widget="monetary"
options="{'currency_field': 'currency_id', 'field_digits': False}"
digits="[16,0]"
attrs="{'required':[('is_mother_work','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
attrs="{'invisible':[('is_mother_work','=',False)],'required':[('is_mother_work','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="education_status"/>
<!-- <field name="is_mother_benefit"/>-->
</group>
@ -664,10 +667,13 @@
readonly="1"/>
<field name="replacement_is_mother_work"
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="replacement_mother_salary_certificate"
widget="many2many_attachment_preview"
attrs="{'invisible':[('replacement_is_mother_work','=',False)]}"/>
<field name="replacement_mother_has_disabilities"
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="replacement_mother_income"
attrs="{'required':[('replacement_is_mother_work','=',True),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
attrs="{'invisible':[('replacement_is_mother_work','=',False)],'required':[('replacement_is_mother_work','=',True),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="replacement_education_status"/>
<!-- <field name="is_mother_benefit"/>-->
</group>

View File

@ -84,6 +84,22 @@
states="draft"/>
<button name="action_schedule_a_visit" string="Schedule a visit" type="object"
class="oe_highlight" states="contact"/>
<!-- added by eslam-->
<!-- <button name="action_incomplete"-->
<!-- string="عدم الاكتمال"-->
<!-- type="object"-->
<!-- class="btn btn-danger"-->
<!-- attrs="{'invisible': [('state', 'not in', ['contact','schedule_a_visit'])]}"/>-->
<!-- <button name="action_postpone"-->
<!-- string="تأجيل"-->
<!-- type="object"-->
<!-- class="btn btn-warning"-->
<!-- attrs="{'invisible': [('state', 'not in', ['contact','schedule_a_visit'])]}"/>-->
<!-- added by eslam-->
<button name="action_done" string="Done" type="object" class="oe_highlight"
states="schedule_a_visit"/>
<button name="action_skip_otp"
@ -97,7 +113,7 @@
attrs="{'invisible':[('state', '!=', 'done')]}"
type="object" string="Resend Survey Link" class="oe_highlight"/>
<button name="geo_localize" string="Map" type="object" class="oe_highlight"
attrs="{'invisible':[('benefit_id', '=', False)]}"/>
attrs="{'invisible':['|',('benefit_id', '=', False),('state', '=', 'done')]}"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,contact,schedule_a_visit,cancel,done,close"/>
</header>
@ -118,10 +134,13 @@
</div>
<group>
<group>
<field name="visit_types" domain="[('creation_method','=','manual')]"
attrs="{'readonly':[('state', 'in', ['close','cancel'])]}" required="1"/>
<field name="benefit_id" attrs="{'readonly':[('state', 'in', ['close','cancel'])]}"
required="1"/>
<!-- <field name="visit_types" domain="[('creation_method','=','manual')]"-->
<!-- attrs="{'readonly':[('state', 'in', ['close','cancel'])]}" required="1"/>-->
<!-- <field name="benefit_id" attrs="{'readonly':[('state', 'in', ['close','cancel'])]}"-->
<!-- required="1"/>-->
<field name="visit_types" required="1"/>
<field name="benefit_id" required="1"/>
<field name="sms_phone"/>
<field name="researcher_team" required="1"/>
<field name="researcher_ids" invisible="1" widget="many2many_tags"
@ -211,5 +230,36 @@
</field>
</record>
<!-- added by eslam-->
<!-- <record id="view_visit_postpone_wizard" model="ir.ui.view">-->
<!-- <field name="name">visit.postpone.wizard.form</field>-->
<!-- <field name="model">visit.postpone.wizard</field>-->
<!-- <field name="arch" type="xml">-->
<!-- <form string="Postpone Visit">-->
<!-- <group>-->
<!-- <field name="visit_id" readonly="1"/>-->
<!-- <field name="reason"/>-->
<!-- <field name="notes"/>-->
<!-- </group>-->
<!-- <footer>-->
<!-- <button name="action_confirm_postpone"-->
<!-- string="Confirm"-->
<!-- type="object"-->
<!-- class="btn btn-primary"/>-->
<!-- <button string="Cancel" class="btn btn-secondary" special="cancel"/>-->
<!-- </footer>-->
<!-- </form>-->
<!-- </field>-->
<!-- </record>-->
<!-- <record id="action_visit_postpone_wizard" model="ir.actions.act_window">-->
<!-- <field name="name">Postpone Visit</field>-->
<!-- <field name="res_model">visit.postpone.wizard</field>-->
<!-- <field name="view_mode">form</field>-->
<!-- <field name="target">new</field>-->
<!-- </record>-->
<!-- added by eslam-->
</data>
</odoo>