[IMP] odex_benefit: IMP benefit
This commit is contained in:
parent
2f5a54dd60
commit
8373f078b5
|
|
@ -10057,6 +10057,7 @@ msgstr "إعادة جدولة"
|
||||||
|
|
||||||
#. module: odex_benefit
|
#. 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_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_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_grant_benefit__researcher_id
|
||||||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__researcher_id
|
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__researcher_id
|
||||||
|
|
@ -17365,6 +17366,7 @@ msgid "Third Approve"
|
||||||
msgstr "اعتماد مديرة خدمات المستفيدين الإيقاف"
|
msgstr "اعتماد مديرة خدمات المستفيدين الإيقاف"
|
||||||
|
|
||||||
#. module: odex_benefit
|
#. module: odex_benefit
|
||||||
|
#: code:addons/odex_benefit/models/seasonal_service.py:0
|
||||||
#: code:addons/odex_benefit/models/family_expense.py:0
|
#: code:addons/odex_benefit/models/family_expense.py:0
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Reason for Return"
|
msgid "Reason for Return"
|
||||||
|
|
@ -17615,3 +17617,66 @@ msgstr "رقم الجوال"
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Please enter a valid Saudi mobile number (example: 05xxxxxxxx)."
|
msgid "Please enter a valid Saudi mobile number (example: 05xxxxxxxx)."
|
||||||
msgstr "رجاءً أدخل رقم جوال سعودي صالح (مثال: 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"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ class ConfirmBenefitExpense(models.Model):
|
||||||
line_domain_ids = fields.Many2many(comodel_name='benefit.expense.line', compute='_compute_domain_ids',
|
line_domain_ids = fields.Many2many(comodel_name='benefit.expense.line', compute='_compute_domain_ids',
|
||||||
string="Return Line Domain",
|
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', )
|
compute='_compute_has_draft_return_lines', )
|
||||||
|
|
||||||
@api.depends('return_expense_line_ids')
|
@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_othaime = sum(lines.mapped('family_monthly_othaime'))
|
||||||
rec.family_monthly_total = rec.family_monthly_income + rec.family_monthly_meals + rec.family_monthly_clotting
|
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')
|
othaim_lines = lines.filtered('meal_card')
|
||||||
rec.family_count_expense = len(expense_lines.mapped('family_id'))
|
rec.family_count_expense = len(lines.mapped('family_id'))
|
||||||
rec.member_count_expense = sum(expense_lines.mapped('benefit_member_count'))
|
rec.member_count_expense = sum(lines.mapped('benefit_member_count'))
|
||||||
|
|
||||||
rec.family_count_othaim = len(othaim_lines.mapped('family_id'))
|
rec.family_count_othaim = len(othaim_lines.mapped('family_id'))
|
||||||
rec.member_count_othaim = sum(othaim_lines.mapped('benefit_member_count'))
|
rec.member_count_othaim = sum(othaim_lines.mapped('benefit_member_count'))
|
||||||
|
|
@ -352,21 +351,21 @@ class ConfirmBenefitExpense(models.Model):
|
||||||
|
|
||||||
if not return_lines:
|
if not return_lines:
|
||||||
raise UserError(_("No return lines in draft state to send to specialist."))
|
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:
|
for line in return_lines:
|
||||||
family = line.family_id
|
family = line.family_id
|
||||||
researcher = family.researcher_id if hasattr(family, 'researcher_id') else False
|
researcher = family.researcher_id if hasattr(family, 'researcher_id') else False
|
||||||
|
|
||||||
if not researcher:
|
if not researcher:
|
||||||
lines_without_specialist |= line
|
lines_without_researcher |= line
|
||||||
continue
|
continue
|
||||||
line.write({
|
line.write({
|
||||||
'researcher_id': researcher.id,
|
'researcher_id': researcher.id,
|
||||||
'state': 'waiting_processing'
|
'state': 'waiting_processing'
|
||||||
})
|
})
|
||||||
if lines_without_specialist:
|
if lines_without_researcher:
|
||||||
families_without_specialist = lines_without_specialist.mapped('family_id.name')
|
families_without_specialist = lines_without_researcher.mapped('family_id.name')
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
"The following families do not have an assigned researcher:\n%s\n\n"
|
"The following families do not have an assigned researcher:\n%s\n\n"
|
||||||
"Please assign researchers to these families before sending."
|
"Please assign researchers to these families before sending."
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class BenefitExpenseLine(models.Model):
|
||||||
('waiting_processing', 'Waiting Processing'),
|
('waiting_processing', 'Waiting Processing'),
|
||||||
('processing_done', 'Processing Done'),
|
('processing_done', 'Processing Done'),
|
||||||
], string="Status", default='draft', tracking=True)
|
], 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')
|
@api.depends('family_monthly_income', 'family_monthly_clotting', 'family_monthly_meals')
|
||||||
def _compute_total_family_expenses(self):
|
def _compute_total_family_expenses(self):
|
||||||
|
|
|
||||||
|
|
@ -384,11 +384,14 @@ class SeasonalService(models.Model):
|
||||||
rec.state = 'draft'
|
rec.state = 'draft'
|
||||||
|
|
||||||
def action_reset_to_calculated(self):
|
def action_reset_to_calculated(self):
|
||||||
for rec in self:
|
self.ensure_one()
|
||||||
rec.service_requests_ids.write({'state': 'draft'})
|
return {
|
||||||
rec.payment_order_id.unlink()
|
'name': _('Reason for Return'),
|
||||||
rec.vendor_bill.unlink()
|
'type': 'ir.actions.act_window',
|
||||||
rec.state = 'calculated'
|
'res_model': 'reason.for.return.wizard',
|
||||||
|
'view_mode': 'form',
|
||||||
|
'target': 'new',
|
||||||
|
}
|
||||||
|
|
||||||
def action_open_related_move_records(self):
|
def action_open_related_move_records(self):
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@
|
||||||
groups="odex_benefit.group_family_services_manager"
|
groups="odex_benefit.group_family_services_manager"
|
||||||
type="object" states="draft" class="btn btn-info"/>
|
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)]}"
|
attrs="{'invisible': ['|','|',('state','!=','draft'),('is_return_calculation', '=', False),('has_draft_return_lines', '=', False)]}"
|
||||||
string="Send to Researchers" class="btn btn-warning"/>
|
string="Send to Researchers" class="btn btn-warning"/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
<button name="action_reset_to_calculated" type="object"
|
<button name="action_reset_to_calculated" type="object"
|
||||||
string="Reset"
|
string="Reset"
|
||||||
class="oe_highlight"
|
class="btn btn-danger"
|
||||||
groups="odex_benefit.group_family_services_manager"
|
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"
|
<button name="action_done" type="object"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
from odoo import models, fields, api, _
|
from odoo import models, fields, api, _
|
||||||
|
|
||||||
|
|
||||||
class ReasonForReturnWizard(models.TransientModel):
|
class ReasonForReturnWizard(models.TransientModel):
|
||||||
_name = 'reason.for.return.wizard'
|
_name = 'reason.for.return.wizard'
|
||||||
_description = '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>State Changed:</b> %s → Calculated<br/>'
|
||||||
'<b>Reset By:</b> %s<br/>'
|
'<b>Reset By:</b> %s<br/>'
|
||||||
'<b>Reason:</b> %s'
|
'<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(
|
expense.sudo().message_post(
|
||||||
body=message,
|
body=message,
|
||||||
subject=_('Benefit Expense Reset'),
|
subject=_('Benefit Expense Reset'),
|
||||||
|
|
@ -35,9 +37,27 @@ class ReasonForReturnWizard(models.TransientModel):
|
||||||
if expense.move_id:
|
if expense.move_id:
|
||||||
expense.sudo().move_id.unlink()
|
expense.sudo().move_id.unlink()
|
||||||
expense.sudo().state = 'calculated'
|
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'}
|
return {'type': 'ir.actions.act_window_close'}
|
||||||
|
|
||||||
|
|
||||||
class ReturnReasonWizard(models.TransientModel):
|
class ReturnReasonWizard(models.TransientModel):
|
||||||
_name = "return.reason.wizard"
|
_name = "return.reason.wizard"
|
||||||
_description = "Return Reason Wizard"
|
_description = "Return Reason Wizard"
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,11 @@ class ReasearcherFamilyWizard(models.TransientModel):
|
||||||
branches = self.benefit_ids.mapped('branch_family_id')
|
branches = self.benefit_ids.mapped('branch_family_id')
|
||||||
if len(branches) > 1:
|
if len(branches) > 1:
|
||||||
raise ValidationError(_('All selected families must be from the same branch'))
|
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)
|
create_visit = self.env.context.get('create_visit', False)
|
||||||
|
|
||||||
for benefit in self.benefit_ids:
|
for benefit in self.benefit_ids:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue