Merge pull request #5745 from expsa/trt

Trt
This commit is contained in:
kchyounes19 2025-12-16 19:48:39 +01:00 committed by GitHub
commit 7b833a5442
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 202 additions and 148 deletions

View File

@ -2752,7 +2752,6 @@ msgstr "بإمكانه النشر "
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_reason_wizard_form #: model_terms:ir.ui.view,arch_db:odex_benefit.view_suspend_reason_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_skip_otp_wizard_form #: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_skip_otp_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.visit_location_otp_wizard_form #: model_terms:ir.ui.view,arch_db:odex_benefit.visit_location_otp_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_assign_supervisor_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_location_refusal_reason_wizard_form #: model_terms:ir.ui.view,arch_db:odex_benefit.view_visit_location_refusal_reason_wizard_form
msgid "Cancel" msgid "Cancel"
msgstr "إلغاء" msgstr "إلغاء"
@ -10058,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
@ -17366,19 +17366,12 @@ 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"
msgstr "سبب الإرجاع" msgstr "سبب الإرجاع"
#. module: odex_benefit
#: code:addons/odex_benefit/models/family_expense_line.py:0
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_assign_supervisor_wizard_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
#, python-format
msgid "Assign to Supervisor"
msgstr "إسناد للمشرف"
#. module: odex_benefit #. module: odex_benefit
#: code:addons/odex_benefit/models/family_expense_line.py:0 #: code:addons/odex_benefit/models/family_expense_line.py:0
#, python-format #, python-format
@ -17413,41 +17406,6 @@ msgstr ""
msgid "Benefit Expense Reset" msgid "Benefit Expense Reset"
msgstr "إعادة تعيين مصروفات الاسر" msgstr "إعادة تعيين مصروفات الاسر"
#. module: odex_benefit
#: model:ir.model,name:odex_benefit.model_assign_supervisor_wizard
msgid "Assign Supervisor Wizard"
msgstr "معالج إسناد المشرف"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_assign_supervisor_wizard__supervisor_id
msgid "Supervisor"
msgstr "المشرف"
#. module: odex_benefit
#: code:addons/odex_benefit/wizards/researcher_wizard.py:0
#, python-format
msgid ""
"<b>Assigned to Supervisor</b><br/><b>Supervisor:</b> %s<br/><b>Assigned "
"By:</b> %s"
msgstr ""
"<b>تم الإسناد إلى المشرف</b><br/><b>المشرف:</b> %s<br/><b>تم الإسناد بواسطة:</b> %s"
#. module: odex_benefit
#: code:addons/odex_benefit/wizards/researcher_wizard.py:0
#, python-format
msgid "Assigned to Supervisor"
msgstr "تم الإسناد إلى المشرف"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_assign_supervisor_wizard_form
msgid "Select a supervisor..."
msgstr "اختر مشرفًا..."
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_assign_supervisor_wizard_form
msgid "Confirm Assignment"
msgstr "تأكيد الإسناد"
#. module: odex_benefit #. module: odex_benefit
#: code:addons/odex_benefit/models/family_expense.py:0 #: code:addons/odex_benefit/models/family_expense.py:0
#, python-format #, python-format
@ -17466,11 +17424,6 @@ msgstr "بانتظار المعالجة"
msgid "Processing Done" msgid "Processing Done"
msgstr "تمت المعالجة" msgstr "تمت المعالجة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_benefit_expense_line__assigned_supervisor_id
msgid "Assigned Supervisor"
msgstr "المشرف"
#. module: odex_benefit #. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_expense_line_form #: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_expense_line_form
msgid "Process" msgid "Process"
@ -17664,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"

View File

@ -98,6 +98,17 @@ 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 Draft Return Lines",
compute='_compute_has_draft_return_lines', )
@api.depends('return_expense_line_ids')
def _compute_has_draft_return_lines(self):
for rec in self:
if rec.return_expense_line_ids:
draft_lines = rec.return_expense_line_ids.filtered(lambda l: l.state == 'draft')
rec.has_draft_return_lines = bool(draft_lines)
else:
rec.has_draft_return_lines = False
@api.depends('payment_order_id', 'payment_order_id.state', 'move_id', 'move_id.state') @api.depends('payment_order_id', 'payment_order_id.state', 'move_id', 'move_id.state')
def _compute_payment_move_state(self): def _compute_payment_move_state(self):
@ -310,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'))
@ -332,6 +342,35 @@ class ConfirmBenefitExpense(models.Model):
self.sudo().action_accounting_transfer() self.sudo().action_accounting_transfer()
self.sudo().state = 'accounting_approve' self.sudo().state = 'accounting_approve'
def action_send_to_researcher(self):
for rec in self:
if not rec.is_return_calculation:
raise UserError(_("This action is only available for return calculations."))
return_lines = rec.return_expense_line_ids.filtered(lambda l: l.state == 'draft')
if not return_lines:
raise UserError(_("No return lines in draft state to send to specialist."))
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_researcher |= line
continue
line.write({
'researcher_id': researcher.id,
'state': 'waiting_processing'
})
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."
) % ", ".join(families_without_specialist))
def action_cancel(self): def action_cancel(self):
self.state = 'cancel' self.state = 'cancel'

View File

@ -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)
assigned_supervisor_id = fields.Many2one('hr.employee', string='Assigned Supervisor', tracking=True, copy=False) 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):
@ -55,16 +55,6 @@ class BenefitExpenseLine(models.Model):
} }
} }
def action_assign_supervisor(self):
self.ensure_one()
return {
'name': _('Assign to Supervisor'),
'type': 'ir.actions.act_window',
'res_model': 'assign.supervisor.wizard',
'view_mode': 'form',
'target': 'new',
}
def action_process_return(self): def action_process_return(self):
self.ensure_one() self.ensure_one()
if self.state != 'waiting_processing': if self.state != 'waiting_processing':

View File

@ -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 {

View File

@ -207,6 +207,7 @@ class ServiceRequest(models.Model):
agree_terms = fields.Boolean(string="I agree to the Terms and Conditions", default=False, ) agree_terms = fields.Boolean(string="I agree to the Terms and Conditions", default=False, )
related_information_html = fields.Html(string="Related Information", related_information_html = fields.Html(string="Related Information",
compute='_compute_related_information_html', store=True, ) compute='_compute_related_information_html', store=True, )
researcher_opinion = fields.Html(string='Specialist Opinion',tracking=True)
@api.depends('service_cat', 'family_id', 'member_id', 'benefit_type') @api.depends('service_cat', 'family_id', 'member_id', 'benefit_type')
def _compute_related_information_html(self): def _compute_related_information_html(self):
@ -549,6 +550,10 @@ class ServiceRequest(models.Model):
def action_researcher_send_request(self): def action_researcher_send_request(self):
for rec in self: for rec in self:
if not rec.researcher_opinion or not rec.researcher_opinion.strip():
raise ValidationError(
_('Please write the specialist opinion before completing the action.')
)
if not rec.requested_service_amount or rec.requested_service_amount <= 0: if not rec.requested_service_amount or rec.requested_service_amount <= 0:
raise UserError(_("Please enter a valid service amount.")) raise UserError(_("Please enter a valid service amount."))

View File

@ -168,8 +168,7 @@ access_grant_benefit_account_move_line,access_grant_benefit_account_move_line,mo
access_grant_benefit_account_move,access_grant_benefit_account_move,model_account_move,odex_benefit.group_benefit_info,1,0,0,0 access_grant_benefit_account_move,access_grant_benefit_account_move,model_account_move,odex_benefit.group_benefit_info,1,0,0,0
access_expense_line_family_services_manager,access_expense_line_family_services_manager,model_benefit_expense_line,odex_benefit.group_family_services_manager,1,1,1,1 access_expense_line_family_services_manager,access_expense_line_family_services_manager,model_benefit_expense_line,odex_benefit.group_family_services_manager,1,1,1,1
access_expense_line_benefit_manager,access_expense_line_benefit_manager,model_benefit_expense_line,odex_benefit.group_benefit_manager,1,1,1,1 access_expense_line_benefit_manager,access_expense_line_benefit_manager,model_benefit_expense_line,odex_benefit.group_benefit_manager,1,1,1,1
access_expense_researcher,access_expense_researcher,model_benefit_expense_line,odex_benefit.group_benefit_info,1,0,0,0 access_expense_researcher,access_expense_researcher,model_benefit_expense_line,odex_benefit.group_benefit_info,1,1,0,0
access_family_bank_report_wizard,access_family_bank_report_wizard,model_family_bank_report_wizard,base.group_user,1,1,1,1 access_family_bank_report_wizard,access_family_bank_report_wizard,model_family_bank_report_wizard,base.group_user,1,1,1,1
access_return_reason,access_return_reason,model_return_reason,base.group_user,1,1,1,1 access_return_reason,access_return_reason,model_return_reason,base.group_user,1,1,1,1
access_return_reason_wizard,access_return_reason_wizard,model_return_reason_wizard,base.group_user,1,1,1,1 access_return_reason_wizard,access_return_reason_wizard,model_return_reason_wizard,base.group_user,1,1,1,1
access_assign_supervisor_wizard,access_assign_supervisor_wizard,model_assign_supervisor_wizard,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
168 access_grant_benefit_account_move access_grant_benefit_account_move model_account_move odex_benefit.group_benefit_info 1 0 0 0
169 access_expense_line_family_services_manager access_expense_line_family_services_manager model_benefit_expense_line odex_benefit.group_family_services_manager 1 1 1 1
170 access_expense_line_benefit_manager access_expense_line_benefit_manager model_benefit_expense_line odex_benefit.group_benefit_manager 1 1 1 1
171 access_expense_researcher access_expense_researcher model_benefit_expense_line odex_benefit.group_benefit_info 1 0 1 0 0
172 access_family_bank_report_wizard access_family_bank_report_wizard model_family_bank_report_wizard base.group_user 1 1 1 1
173 access_return_reason access_return_reason model_return_reason base.group_user 1 1 1 1
174 access_return_reason_wizard access_return_reason_wizard model_return_reason_wizard base.group_user 1 1 1 1
access_assign_supervisor_wizard access_assign_supervisor_wizard model_assign_supervisor_wizard base.group_user 1 1 1 1

View File

@ -350,5 +350,31 @@
<field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/> <field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
<field name="active" eval="True" /> <field name="active" eval="True" />
</record> </record>
<record id="benefit_expense_line_rule_researcher" model="ir.rule">
<field name="name">Show Bank Return Line Assigned To Researcher</field>
<field name="model_id" ref="model_benefit_expense_line"/>
<field name="domain_force">['|',
('family_id.assigned_researcher_id.employee_id','in', user.employee_id.ids),
('family_id.researcher_id.employee_id', 'in', user.employee_id.ids)]</field>
<field name="groups" eval="[(4, ref('group_benefit_researcher'))]"/>
<field name="active" eval="True" />
</record>
<record id="benefit_expense_line_rule_all" model="ir.rule">
<field name="name">Show All Bank Return Line</field>
<field name="model_id" ref="model_benefit_expense_line"/>
<field name="domain_force">[(1, '=', 1)]</field>
<field name="groups" eval="[(4, ref('group_benefit_manager')),(4, ref('group_benefit_supervisor')),(4, ref('group_family_services_manager'))]"/>
<field name="active" eval="True" />
</record>
<record id="benefit_expense_line_rule_branch_manager" model="ir.rule">
<field name="name">Show Bank Return Line of Own Branch</field>
<field name="model_id" ref="model_benefit_expense_line"/>
<field name="domain_force">[('branch_id.branch.manager_id', '=', user.employee_id.id)]</field>
<field name="groups" eval="[(4, ref('group_benefit_branch_manager'))]"/>
<field name="active" eval="True" />
</record>
</data> </data>
</odoo> </odoo>

View File

@ -1077,7 +1077,7 @@
<menuitem id="menu_confirm_benefit_expense" name="Benefit Expense Flow" parent="odex_benefit.benefit_services" <menuitem id="menu_confirm_benefit_expense" name="Benefit Expense Flow" parent="odex_benefit.benefit_services"
action="action_confirm_benefit_expense" sequence="11" groups="odex_benefit.group_family_services_manager,odex_benefit.group_benefit_manager"/> action="action_confirm_benefit_expense" sequence="11" groups="odex_benefit.group_family_services_manager,odex_benefit.group_benefit_manager"/>
<menuitem id="menu_bank_return_benefit_expense" name="Bank Return Processing" parent="odex_benefit.benefit_services" <menuitem id="menu_bank_return_benefit_expense" name="Bank Return Processing" parent="odex_benefit.benefit_services"
action="action_bank_return_benefit_expense" sequence="15" groups="odex_benefit.group_family_services_manager,odex_benefit.group_benefit_manager"/> action="action_bank_return_benefit_expense" sequence="15" groups="odex_benefit.group_benefit_researcher,odex_benefit.group_family_services_manager,odex_benefit.group_benefit_manager"/>
<menuitem id="menu_family_bank_report_root" <menuitem id="menu_family_bank_report_root"
name="Family Bank Report" name="Family Bank Report"
parent="account.menu_finance_payables" parent="account.menu_finance_payables"

View File

@ -45,8 +45,8 @@
<group> <group>
<field name="family_id"/> <field name="family_id"/>
<field name="branch_id"/> <field name="branch_id"/>
<field name="assigned_supervisor_id" <field name="researcher_id"
attrs="{'invisible': [('assigned_supervisor_id','=',False)]}"/> attrs="{'invisible': [('researcher_id','=',False)]}"/>
<field name="family_category_id"/> <field name="family_category_id"/>
<field name="meal_card"/> <field name="meal_card"/>
<field name="benefit_member_count"/> <field name="benefit_member_count"/>

View File

@ -49,6 +49,10 @@
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" 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"/>
<button string="Confirm" type="object" name="action_assistant_manager" class="oe_highlight" <button string="Confirm" type="object" name="action_assistant_manager" class="oe_highlight"
states="calculated" groups="odex_benefit.group_family_services_manager"/> states="calculated" groups="odex_benefit.group_family_services_manager"/>
<button string="Withdraw" type="object" name="action_reset_to_draft" class="btn btn-danger" <button string="Withdraw" type="object" name="action_reset_to_draft" class="btn btn-danger"
@ -62,11 +66,6 @@
<button string="Reset" type="object" name="action_reset_to_calculated" class="btn btn-danger" <button string="Reset" type="object" name="action_reset_to_calculated" class="btn btn-danger"
states="assistant_general_manager" states="assistant_general_manager"
groups="odex_benefit.group_benefit_manager"/> groups="odex_benefit.group_benefit_manager"/>
<!--<button string="Accounting Transfer" type="object" name="action_accounting_transfer"
class="oe_highlight" groups="odex_benefit.group_family_services_manager"
attrs="{'invisible': ['|','|',('state', '!=', 'accounting_approve'),('payment_order_id','!=',False),('move_id','!=',False)]}"
/>-->
<button string="Reset" type="object" name="action_reset_to_calculated" class="btn btn-danger" <button string="Reset" type="object" name="action_reset_to_calculated" class="btn btn-danger"
states="accounting_approve" groups="odex_benefit.group_family_services_manager"/> states="accounting_approve" groups="odex_benefit.group_family_services_manager"/>
</header> </header>
@ -142,6 +141,7 @@
<field name="currency_id" invisible="1" groups="base.group_multi_currency"/> <field name="currency_id" invisible="1" groups="base.group_multi_currency"/>
<field name="available_payment_method_line_ids" invisible="1"/> <field name="available_payment_method_line_ids" invisible="1"/>
<field name="line_domain_ids" invisible="1"/> <field name="line_domain_ids" invisible="1"/>
<field name="has_draft_return_lines" invisible="1"/>
</group> </group>
</group> </group>
<!-- Notebook with Families page --> <!-- Notebook with Families page -->
@ -379,14 +379,7 @@
decoration-warning="state == 'waiting_processing'" decoration-warning="state == 'waiting_processing'"
decoration-success="state == 'processing_done'" decoration-success="state == 'processing_done'"
/> />
<field name="assigned_supervisor_id" optional="hide"/> <field name="researcher_id" optional="hide"/>
<button name="action_assign_supervisor"
string="Assign to Supervisor"
groups="odex_benefit.group_family_services_manager"
type="object"
attrs="{'invisible': ['|','|',('parent.state', '!=', 'draft'),('state', '!=', 'draft'), ('is_return', '=', False)]}"
class="btn-primary"
/>
</tree> </tree>
</field> </field>
</page> </page>

View File

@ -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"

View File

@ -444,6 +444,13 @@
</group> </group>
</group> </group>
</page> </page>
<page string="Researcher Opinion">
<group>
<field name="researcher_opinion" nolabel="1"
placeholder="Please write the specialist opinion here..."
/>
</group>
</page>
<page string="Related Information"> <page string="Related Information">
<group> <group>
<field name="related_information_html" nolabel="1" readonly="1"/> <field name="related_information_html" nolabel="1" readonly="1"/>

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
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'
@ -24,20 +25,39 @@ 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'),
message_type='notification',) message_type='notification', )
if expense.payment_order_id: if expense.payment_order_id:
expense.sudo().payment_order_id.unlink() expense.sudo().payment_order_id.unlink()
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"

View File

@ -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:
@ -226,36 +231,3 @@ class ReasearcherFamilyWizard(models.TransientModel):
subtype_id=self.env.ref('mail.mt_note').id, subtype_id=self.env.ref('mail.mt_note').id,
notify_by_email=False, notify_by_email=False,
) )
class AssignSupervisorWizard(models.TransientModel):
_name = 'assign.supervisor.wizard'
_description = 'Assign Supervisor Wizard'
supervisor_id = fields.Many2one('hr.employee', string='Supervisor', required=True, domain=[('job_id', '!=', False)])
def action_confirm(self):
self.ensure_one()
active_id = self._context.get('active_id')
active_model = self._context.get('active_model')
if active_model == 'benefit.expense.line':
expense_line = self.env[active_model].browse(active_id)
message = _(
'<b>Assigned to Supervisor</b><br/>'
'<b>Supervisor:</b> %s<br/>'
'<b>Assigned By:</b> %s'
) % (self.supervisor_id.name, self.env.user.name)
expense_line.message_post(
body=message,
subject=_('Assigned to Supervisor'),
message_type='notification',
)
expense_line.write({
'assigned_supervisor_id': self.supervisor_id.id,
'state': 'waiting_processing'
})
return {'type': 'ir.actions.act_window_close'}

View File

@ -35,7 +35,8 @@
<field name="is_submitted" invisible="1"/> <field name="is_submitted" invisible="1"/>
<field name="branch_custom_id" attrs="{'invisible':[('branch_has_employees','=',True)]}"/> <field name="branch_custom_id" attrs="{'invisible':[('branch_has_employees','=',True)]}"/>
<field name="branch_has_employees" invisible="1"/> <field name="branch_has_employees" invisible="1"/>
<field name="researcher_team" domain="[('branch_custom_id', '=',branch_custom_id)]" required="1" <field name="researcher_team" domain="[('branch_custom_id', '=',branch_custom_id)]"
required="1"
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/> options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
</group> </group>
<footer> <footer>
@ -57,9 +58,11 @@
<group> <group>
<field name="benefit_ids" widget="many2many_tags" invisible="1"/> <field name="benefit_ids" widget="many2many_tags" invisible="1"/>
<field name="is_submitted" invisible="1"/> <field name="is_submitted" invisible="1"/>
<field name="branch_custom_id" invisible="1" attrs="{'invisible':[('branch_has_employees','=',True)]}"/> <field name="branch_custom_id" invisible="1"
attrs="{'invisible':[('branch_has_employees','=',True)]}"/>
<field name="branch_has_employees" invisible="1"/> <field name="branch_has_employees" invisible="1"/>
<field name="researcher_team" required="1" <field name="researcher_team" required="1"
domain="[('branch_custom_id', '=',branch_custom_id)]"
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/> options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
<field name="assignment_type" required="1"/> <field name="assignment_type" required="1"/>
</group> </group>
@ -73,24 +76,5 @@
</field> </field>
</record> </record>
<record id="view_assign_supervisor_wizard_form" model="ir.ui.view">
<field name="name">assign.supervisor.wizard.form</field>
<field name="model">assign.supervisor.wizard</field>
<field name="arch" type="xml">
<form string="Assign to Supervisor">
<group>
<field name="supervisor_id"
placeholder="Select a supervisor..."
required="1"
options="{'no_create': True, 'no_create_edit': True}"/>
</group>
<footer>
<button string="Confirm Assignment" name="action_confirm"
type="object" class="btn-primary"/>
<button string="Cancel" class="btn-secondary" special="cancel"/>
</footer>
</form>
</field>
</record>
</data> </data>
</odoo> </odoo>