Merge pull request #4716 from expsa/samir-aladawi-updates-on-benefit

[UPD] odex_benefit
This commit is contained in:
SamirLADOUI-sa 2025-09-20 08:13:39 +01:00 committed by GitHub
commit 4716fd34e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 130 additions and 130 deletions

View File

@ -3308,6 +3308,11 @@ msgstr ""
msgid "Create A Club"
msgstr ""
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.visits_form
msgid "Create New Visit"
msgstr "إنشاء زيارة جديدة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Create Periodic visit"
@ -9337,6 +9342,17 @@ msgstr "عدد أوامر نقطة البيع"
msgid "Positive"
msgstr ""
#. module: odex_benefit
#: code:addons/odex_benefit/models/visit.py:0
#, python-format
msgid "Postpone Visit"
msgstr "تأجيل الزيارة"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.visits_form
msgid "Postponement"
msgstr "تأجيل"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Preview Attachment"
@ -9770,10 +9786,14 @@ msgstr "سبب الرفض"
#: model_terms:ir.ui.view,arch_db:odex_benefit.service_request_search
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_entity_final_refused_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_entity_refused_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_location_refusal_reason_wizard_form
msgid "Refused"
msgstr "مرفوض"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_location_refusal_reason_wizard_form
msgid "Confirm"
msgstr "تأكيد"
#. module: odex_benefit
#: model:ir.model,name:odex_benefit.model_entity_refused_reason_wizard
msgid "Refused Reason Wizard"
@ -10092,6 +10112,11 @@ msgstr "ملفات مطلوبة"
msgid "Rerearcher Wizard"
msgstr " توجيه الملف للاخصائي"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.visits_form
msgid "Reschedule"
msgstr "إعادة جدولة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_changes_requests__researcher_ids
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__researcher_id
@ -10379,7 +10404,7 @@ msgstr "جاري الزيارة"
#. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__visit_location__state__pending
msgid "Pending"
msgstr "معلق"
msgstr "معلقة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_program_plane_line__score
@ -15418,7 +15443,7 @@ msgstr "سبب رفض الزيارة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_visit_location_refusal_reason_wizard__suspend_reason_id
msgid "Refusal Reason"
msgstr "سبب الرفض"
msgstr "السبب"
#. module: odex_benefit
#: code:addons/odex_benefit/wizards/visit_location_refused_wizard.py:0

View File

@ -659,7 +659,7 @@ class ResDistricts(models.Model):
class VisitsSettings(models.Model):
_name = 'visits.types'
name = fields.Char(string="Name",required=True)
name = fields.Char(string="Name", required=True)
creation_method = fields.Selection(
[('manual', 'Manual'),('automatic', 'Automatic')],
string="Creation Method",

View File

@ -37,9 +37,9 @@ class Visit(models.Model):
visit_types = fields.Many2one(
'visits.types',
string='Visits Types',
ondelete="restrict"
ondelete='restrict'
)
visit_types_creation_method = fields.Selection(related='visit_types.creation_method')
evaluation = fields.Selection(
[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6')],
string='Evaluation')
@ -64,41 +64,42 @@ class Visit(models.Model):
survey_url = fields.Char(string="Survey URL")
def action_postpone(self):
"""Open wizard to postpone"""
context = dict(self.env.context or {})
context['target_state'] = "pending"
context['active_id'] = self.id
return {
'name': _('Postpone Visit'),
'view_mode': 'form',
'view_type': 'form',
'type': 'ir.actions.act_window',
'res_model': 'visit.location.refusal.reason.wizard',
'view_id': self.env.ref('odex_benefit.view_visit_location_refusal_reason_wizard_form').id,
'target': 'new',
'context': context,
}
# added by eslam
def action_reschedule(self):
for rec in self:
rec.state = "contact"
# 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
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,
}
@api.depends('response_id')
def _compute_response_count(self):
@ -121,7 +122,7 @@ class Visit(models.Model):
def unlink(self):
for order in self:
if order.state not in ['draft']:
if order.state not in ['draft'] or order.visit_types.creation_method == 'automatic':
raise UserError(_('You cannot delete this record'))
return super(Visit, self).unlink()
@ -338,14 +339,14 @@ class Visit(models.Model):
# author_id=self.env.ref('base.partner_root').id
# )
def action_close(self):
self.ensure_one()
if self.visit_types.survey_id:
if not self.response_id:
raise UserError(_("You must send the evaluation form before closing the visit."))
if self.response_id.state != 'done':
raise UserError(_("The visit cannot be closed before the family completes the evaluation form."))
self.state = 'close'
# def action_close(self):
# self.ensure_one()
# if self.visit_types.survey_id:
# if not self.response_id:
# raise UserError(_("You must send the evaluation form before closing the visit."))
# if self.response_id.state != 'done':
# raise UserError(_("The visit cannot be closed before the family completes the evaluation form."))
# self.state = 'close'
@api.depends("researcher_team")
def get_researcher_ids(self):
@ -393,24 +394,3 @@ 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

@ -4,3 +4,10 @@ class SurveyUserInput(models.Model):
_inherit = 'survey.user_input'
visit_id = fields.Many2one('visit.location', string="Visit")
def _mark_done(self):
super(SurveyUserInput, self)._mark_done()
self.visit_id.write({
'state': 'close'
})

View File

@ -84,35 +84,41 @@
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_create_new_visit"
string="Create New Visit"
type="object"
states="close"/>
<button name="action_postpone"
string="Postponement"
type="object"
class="btn-warning"
states="contact,schedule_a_visit"/>
<button name="action_reschedule"
string="Reschedule"
type="object"
states="pending"/>
<button name="action_done" string="Done" type="object" class="oe_highlight"
states="schedule_a_visit"/>
<button name="action_skip_otp"
string="Skip OTP Verification" states="schedule_a_visit"
type="object" class="btn btn-danger"
string="Skip OTP Verification"
states="schedule_a_visit"
type="object"
class="btn-danger"
groups="odex_benefit.group_otp_manager"/>
<button name="action_cancel" string="Visit Cancel" type="object"
<button name="action_cancel"
string="Visit Cancel"
type="object"
class="btn-danger"
states="contact,schedule_a_visit"/>
<button name="action_close" string="Close" type="object" states="done"/>
<!-- <button name="action_close" string="Close" type="object" states="done"/> -->
<button name="action_send_survey"
attrs="{'invisible':[('state', '!=', 'done')]}"
type="object" string="Resend Survey Link" class="oe_highlight"/>
<button name="geo_localize" string="Map" type="object" class="oe_highlight"
<button name="geo_localize"
string="Map"
type="object"
class="oe_highlight"
icon="fa-map"
attrs="{'invisible':['|',('benefit_id', '=', False),('state', '=', 'done')]}"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,contact,schedule_a_visit,cancel,done,close"/>
@ -134,9 +140,23 @@
</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'])]}"
<field name="visit_types_creation_method" invisible="1" />
<field name="visit_types"
domain="[('creation_method','=','manual')]"
attrs="{'readonly':[
'|',
('state', 'in', ['close', 'cancel']),
('visit_types_creation_method', '=', 'automatic')
]
}"
required="1"/>
<field name="benefit_id"
attrs="{'readonly':[
'|',
('state', 'in', ['close', 'cancel']),
('visit_types_creation_method', '=', 'automatic')
]
}"
required="1"/>
<field name="sms_phone"/>
<field name="researcher_team" required="1"/>
@ -226,37 +246,5 @@
</search>
</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>

View File

@ -16,7 +16,7 @@
<field name="refusal_notes" no_label="1"/>
</group>
<footer>
<button name="action_confirm_return" type="object" string="Refused" class="oe_highlight"/>
<button name="action_confirm_return" type="object" string="Confirm" class="oe_highlight"/>
or
<button special="cancel" string="Cancel"/>
</footer>