[IMP] odex_benefit: IMP benefit

This commit is contained in:
younes 2025-12-16 19:46:57 +01:00
parent 2f5a54dd60
commit 8373f078b5
8 changed files with 114 additions and 22 deletions

View File

@ -10057,6 +10057,7 @@ 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_benefit_expense_line__researcher_id
#: model:ir.model.fields,field_description:odex_benefit.field_family_complaints__researcher_id
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__researcher_id
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__researcher_id
@ -17365,6 +17366,7 @@ msgid "Third Approve"
msgstr "اعتماد مديرة خدمات المستفيدين الإيقاف"
#. module: odex_benefit
#: code:addons/odex_benefit/models/seasonal_service.py:0
#: code:addons/odex_benefit/models/family_expense.py:0
#, python-format
msgid "Reason for Return"
@ -17615,3 +17617,66 @@ msgstr "رقم الجوال"
#, python-format
msgid "Please enter a valid Saudi mobile number (example: 05xxxxxxxx)."
msgstr "رجاءً أدخل رقم جوال سعودي صالح (مثال: 05xxxxxxxx)."
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_confirm_benefit_expense__has_draft_return_lines
msgid "Has Draft Return Lines"
msgstr "هل يحتوي على سطور رجيع مسودة"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_expense.py:0
#, python-format
msgid "This action is only available for return calculations."
msgstr "هذا الإجراء متاح فقط لحسابات الرجيع."
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_expense.py:0
#, python-format
msgid "No return lines in draft state to send to specialist."
msgstr "لا توجد سطور رجيع في حالة المسودة لإرسالها إلى الأخصائي."
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_expense.py:0
#, python-format
msgid ""
"The following families do not have an assigned researcher:\n"
"%s\n"
"\n"
"Please assign researchers to these families before sending."
msgstr "الأسر التالية ليس لديها أخصائي:\n"
"%s\n"
"\n"
"يرجى إسناد أخصائيين إلى هذه الأسر قبل الإرسال."
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__researcher_opinion
msgid "Specialist Opinion"
msgstr "رأي الأخصائي"
#. module: odex_benefit
#: code:addons/odex_benefit/models/service_request.py:0
#, python-format
msgid "Please write the specialist opinion before completing the action."
msgstr "يرجى كتابة رأي الأخصائي قبل إكمال الإجراء."
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
msgid "Send to Researchers"
msgstr "إرسال إلى الأخصائيين"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.service_request_form
msgid "Researcher Opinion"
msgstr "رأي الأخصائي"
#. module: odex_benefit
#: code:addons/odex_benefit/wizards/reason_for_return_wizard.py:0
#, python-format
msgid ""
"<b>State Changed:</b> %s → Calculated<br/><b>Returned By:</b> "
"%s<br/><b>Reason:</b> %s"
msgstr "<b>تم تغيير الحالة:</b> %s → تم الحساب<br/><b>تم الإرجاع بواسطة:</b> "
"%s<br/><b>السبب:</b> %s"

View File

@ -98,7 +98,7 @@ class ConfirmBenefitExpense(models.Model):
line_domain_ids = fields.Many2many(comodel_name='benefit.expense.line', compute='_compute_domain_ids',
string="Return Line Domain",
)
has_draft_return_lines = fields.Boolean(string="Has Pending Return Lines",
has_draft_return_lines = fields.Boolean(string="Has Draft Return Lines",
compute='_compute_has_draft_return_lines', )
@api.depends('return_expense_line_ids')
@ -321,10 +321,9 @@ class ConfirmBenefitExpense(models.Model):
rec.family_monthly_othaime = sum(lines.mapped('family_monthly_othaime'))
rec.family_monthly_total = rec.family_monthly_income + rec.family_monthly_meals + rec.family_monthly_clotting
expense_lines = lines.filtered(lambda l: not l.meal_card)
othaim_lines = lines.filtered('meal_card')
rec.family_count_expense = len(expense_lines.mapped('family_id'))
rec.member_count_expense = sum(expense_lines.mapped('benefit_member_count'))
rec.family_count_expense = len(lines.mapped('family_id'))
rec.member_count_expense = sum(lines.mapped('benefit_member_count'))
rec.family_count_othaim = len(othaim_lines.mapped('family_id'))
rec.member_count_othaim = sum(othaim_lines.mapped('benefit_member_count'))
@ -352,21 +351,21 @@ class ConfirmBenefitExpense(models.Model):
if not return_lines:
raise UserError(_("No return lines in draft state to send to specialist."))
lines_without_specialist = self.env['benefit.expense.line']
lines_without_researcher = self.env['benefit.expense.line']
for line in return_lines:
family = line.family_id
researcher = family.researcher_id if hasattr(family, 'researcher_id') else False
if not researcher:
lines_without_specialist |= line
lines_without_researcher |= line
continue
line.write({
'researcher_id': researcher.id,
'state': 'waiting_processing'
})
if lines_without_specialist:
families_without_specialist = lines_without_specialist.mapped('family_id.name')
if lines_without_researcher:
families_without_specialist = lines_without_researcher.mapped('family_id.name')
raise UserError(_(
"The following families do not have an assigned researcher:\n%s\n\n"
"Please assign researchers to these families before sending."

View File

@ -34,7 +34,7 @@ class BenefitExpenseLine(models.Model):
('waiting_processing', 'Waiting Processing'),
('processing_done', 'Processing Done'),
], string="Status", default='draft', tracking=True)
researcher_id = fields.Many2one("committees.line", string="Researcher")
researcher_id = fields.Many2one("committees.line", string="Researcher", tracking=True, copy=False)
@api.depends('family_monthly_income', 'family_monthly_clotting', 'family_monthly_meals')
def _compute_total_family_expenses(self):

View File

@ -384,11 +384,14 @@ class SeasonalService(models.Model):
rec.state = 'draft'
def action_reset_to_calculated(self):
for rec in self:
rec.service_requests_ids.write({'state': 'draft'})
rec.payment_order_id.unlink()
rec.vendor_bill.unlink()
rec.state = 'calculated'
self.ensure_one()
return {
'name': _('Reason for Return'),
'type': 'ir.actions.act_window',
'res_model': 'reason.for.return.wizard',
'view_mode': 'form',
'target': 'new',
}
def action_open_related_move_records(self):
return {

View File

@ -49,7 +49,7 @@
groups="odex_benefit.group_family_services_manager"
type="object" states="draft" class="btn btn-info"/>
<button name="action_send_to_researcher" type="object"
<button name="action_send_to_researcher" type="object" groups="odex_benefit.group_family_services_manager"
attrs="{'invisible': ['|','|',('state','!=','draft'),('is_return_calculation', '=', False),('has_draft_return_lines', '=', False)]}"
string="Send to Researchers" class="btn btn-warning"/>

View File

@ -30,9 +30,9 @@
<button name="action_reset_to_calculated" type="object"
string="Reset"
class="oe_highlight"
class="btn btn-danger"
groups="odex_benefit.group_family_services_manager"
attrs="{'invisible': [('state', '!=', 'accounting_approve')]}"
attrs="{'invisible': [('state', 'not in', ['gm_assistant','accounting_approve'])]}"
/>
<button name="action_done" type="object"

View File

@ -2,6 +2,7 @@
from odoo import models, fields, api, _
class ReasonForReturnWizard(models.TransientModel):
_name = 'reason.for.return.wizard'
_description = 'Reason For Return Wizard'
@ -24,7 +25,8 @@ class ReasonForReturnWizard(models.TransientModel):
'<b>State Changed:</b> %s → Calculated<br/>'
'<b>Reset By:</b> %s<br/>'
'<b>Reason:</b> %s'
) % (dict(expense.fields_get(['state'])['state']['selection']).get(expense.state, expense.state), self.env.user.name,self.reason)
) % (dict(expense.fields_get(['state'])['state']['selection']).get(expense.state, expense.state),
self.env.user.name, self.reason)
expense.sudo().message_post(
body=message,
subject=_('Benefit Expense Reset'),
@ -35,9 +37,27 @@ class ReasonForReturnWizard(models.TransientModel):
if expense.move_id:
expense.sudo().move_id.unlink()
expense.sudo().state = 'calculated'
elif active_model == 'seasonal.service':
seasonal = self.env[active_model].browse(active_id)
old_state = dict(seasonal.fields_get(['state'])['state']['selection']).get(seasonal.state, seasonal.state)
message = _(
"<b>State Changed:</b> %s → Calculated<br/>"
"<b>Returned By:</b> %s<br/>"
"<b>Reason:</b> %s"
) % (old_state, self.env.user.name, self.reason)
seasonal.sudo().message_post(
body=message,
message_type='notification',
)
seasonal.sudo().service_requests_ids.write({'state': 'draft'})
seasonal.sudo().payment_order_id.unlink()
seasonal.sudo().vendor_bill.unlink()
seasonal.sudo().state = 'calculated'
return {'type': 'ir.actions.act_window_close'}
class ReturnReasonWizard(models.TransientModel):
_name = "return.reason.wizard"
_description = "Return Reason Wizard"

View File

@ -89,6 +89,11 @@ class ReasearcherFamilyWizard(models.TransientModel):
branches = self.benefit_ids.mapped('branch_family_id')
if len(branches) > 1:
raise ValidationError(_('All selected families must be from the same branch'))
draft_records = self.benefit_ids.filtered(lambda b: b.state == 'draft')
if draft_records:
raise ValidationError(
_('You cannot assign a researcher while one or more files are in Draft state.')
)
create_visit = self.env.context.get('create_visit', False)
for benefit in self.benefit_ids: