Merge pull request #4279 from expsa/younes_dev_odex25_ensan
[IMP] Added action method to open attachments linked to family file
This commit is contained in:
commit
8d93abecb6
|
|
@ -14715,4 +14715,14 @@ msgstr "بانتظار مدير الفرع"
|
|||
#. module: odex_benefit
|
||||
#: model:res.groups,name:odex_benefit.group_benefit_show_draft_record
|
||||
msgid "Show Draft Records"
|
||||
msgstr "إظهار الملفات المسودة"
|
||||
msgstr "إظهار الملفات المسودة"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__doc_count
|
||||
msgid "Number of documents attached"
|
||||
msgstr ""
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
|
||||
msgid "Documents"
|
||||
msgstr "المستندات"
|
||||
|
|
@ -580,6 +580,7 @@ class GrantBenefitProfile(models.Model):
|
|||
seasonal_service_id = fields.Many2one('seasonal.service', string="Seasonal Service")
|
||||
is_from_portal = fields.Boolean(string='is Created from Portal?', default=False, readonly=True)
|
||||
applicant_name = fields.Char(readonly=True)
|
||||
doc_count = fields.Integer(compute='_compute_attached_docs_count', string="Number of documents attached")
|
||||
|
||||
_sql_constraints = [
|
||||
('unique_code', "unique (code) WHERE state NOT IN ('draft', 'new')", 'This code already exists')
|
||||
|
|
@ -685,6 +686,53 @@ class GrantBenefitProfile(models.Model):
|
|||
else:
|
||||
record.required_attach = 'true'
|
||||
|
||||
def get_attached_domain(self):
|
||||
visit_location = self.env['visit.location'].search([('benefit_id', '=', self.id)]).ids
|
||||
service_requests = self.env['service.request'].search([('benefit_type', '=', 'family'),('family_id', '=', self.id)]).ids
|
||||
family_complaints = self.env['family.complaints'].search([('family_id', '=', self.id)]).ids
|
||||
hobby_ids = self.member_ids.mapped('hobbies_ids').ids
|
||||
member_education_status_ids = self.member_ids.mapped('member_education_status_ids').ids
|
||||
diseases_ids = self.member_ids.mapped('diseases_ids').ids
|
||||
disabilities_ids = self.member_ids.mapped('disabilities_ids').ids
|
||||
return ['|', '|', '|','|','|','|','|','|','|','|','|','|','|',
|
||||
'&', ('res_model', '=', 'grant.benefit'),
|
||||
('res_id', 'in', self.ids),
|
||||
('benefit_id', 'in', self.ids),
|
||||
'&', ('res_model', '=', 'visit.location'),
|
||||
('res_id', 'in', visit_location),
|
||||
'&', ('res_model', '=', 'service.request'),
|
||||
('res_id', 'in', service_requests),
|
||||
'&', ('res_model', '=', 'family.complaints'),
|
||||
('res_id', 'in', family_complaints),
|
||||
'&', ('res_model', '=', 'education.status'),
|
||||
('res_id', 'in', self.mother_education_status_ids.ids),
|
||||
'&', ('res_model', '=', 'family.debits'),
|
||||
('res_id', 'in', self.family_debits_ids.ids),
|
||||
'&', ('res_model', '=', 'salary.line'),
|
||||
('res_id', 'in', self.salary_ids.ids),
|
||||
'&', ('res_model', '=', 'family.member'),
|
||||
('res_id', 'in', self.member_ids.ids),
|
||||
('member_id', 'in', self.member_ids.ids),
|
||||
'&', ('res_model', '=', 'member.hobbies'),
|
||||
('res_id', 'in', hobby_ids),
|
||||
'&', ('res_model', '=', 'education.status'),
|
||||
('res_id', 'in', member_education_status_ids),
|
||||
'&', ('res_model', '=', 'member.diseases'),
|
||||
('res_id', 'in', diseases_ids),
|
||||
'&', ('res_model', '=', 'member.disabilities'),
|
||||
('res_id', 'in', disabilities_ids),
|
||||
]
|
||||
def _compute_attached_docs_count(self):
|
||||
Attachment = self.env['ir.attachment']
|
||||
for benefit in self:
|
||||
benefit.doc_count = Attachment.search_count(self.get_attached_domain())
|
||||
|
||||
def view_attachments(self):
|
||||
action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
|
||||
action['domain'] = str(self.get_attached_domain())
|
||||
action['context'] = {'create': False}
|
||||
return action
|
||||
|
||||
@api.depends('salary_ids')
|
||||
def get_income_required_attach(self):
|
||||
for rec in self.salary_ids:
|
||||
|
|
@ -1141,11 +1189,11 @@ class GrantBenefitProfile(models.Model):
|
|||
message = self.create_message('waiting_approve')
|
||||
self.partner_id.send_sms_notification(message, self.phone)
|
||||
for rec in self:
|
||||
if not rec.benefit_category_id and not rec.member_income:
|
||||
raise ValidationError(_("يرجى اكمال ادخال او الموافقة على القيم المرتبطة ببيانات الدخل والمرتب والالتزامات لتحديد فئة الاسرة بشكل صحيح"))
|
||||
|
||||
if rec.member_income == 0.0:
|
||||
raise ValidationError(_("يرجى اكمال ادخال او الموافقة على القيم المرتبطة ببيانات الدخل والمرتب والالتزامات لتحديد فئة الاسرة بشكل صحيح"))
|
||||
# if not rec.benefit_category_id and not rec.member_income:
|
||||
# raise ValidationError(_("يرجى اكمال ادخال او الموافقة على القيم المرتبطة ببيانات الدخل والمرتب والالتزامات لتحديد فئة الاسرة بشكل صحيح"))
|
||||
#
|
||||
# if rec.member_income == 0.0:
|
||||
# raise ValidationError(_("يرجى اكمال ادخال او الموافقة على القيم المرتبطة ببيانات الدخل والمرتب والالتزامات لتحديد فئة الاسرة بشكل صحيح"))
|
||||
|
||||
|
||||
rec.validate_attachments()
|
||||
|
|
|
|||
|
|
@ -215,6 +215,9 @@
|
|||
<sheet>
|
||||
<div class="oe_button_box" name="button_box"
|
||||
attrs="{'invisible':[('state','in',['draft','new'])]}">
|
||||
<button class="oe_stat_button" name="view_attachments" type="object" icon="fa-file-text-o">
|
||||
<field string="Documents" name="doc_count" widget="statinfo"/>
|
||||
</button>
|
||||
<button icon="fa-users">
|
||||
<field string="Benefit Members Count" name="benefit_member_count" widget="statinfo"/>
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue