[IMP] odex_benefit: IMP benefit
This commit is contained in:
parent
0a14f4b671
commit
2ff7e20a4c
|
|
@ -17356,16 +17356,6 @@ msgstr "هل تحتاج موافقة مديرة خدمات المستفيدين"
|
|||
msgid "Third Approve"
|
||||
msgstr "اعتماد مديرة خدمات المستفيدين الإيقاف"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__confirm_benefit_expense__state__waiting_processing
|
||||
msgid "Waiting for Processing"
|
||||
msgstr "بانتظار المعالجة"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_confirm_benefit_expense__assigned_supervisor_id
|
||||
msgid "Assigned Supervisor"
|
||||
msgstr "المشرف"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_expense.py:0
|
||||
#, python-format
|
||||
|
|
@ -17373,21 +17363,20 @@ msgid "Reason for Return"
|
|||
msgstr "سبب الإرجاع"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_expense.py:0
|
||||
#: 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
|
||||
#: code:addons/odex_benefit/models/family_expense.py:0
|
||||
#: code:addons/odex_benefit/models/family_expense_line.py:0
|
||||
#, python-format
|
||||
msgid "You can only process when status is 'Waiting for Processing'."
|
||||
msgstr "يمكنك المعالجة فقط عندما تكون الحالة 'بانتظار المعالجة'."
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_expense.py:0
|
||||
#: code:addons/odex_benefit/models/family_expense_line.py:0
|
||||
#, python-format
|
||||
msgid "<b>Processing Completed</b><br/><b>Processed By:</b> %s"
|
||||
msgstr "<b>اكتملت المعالجة</b><br/><b>تمت المعالجة بواسطة:</b> %s"
|
||||
|
|
@ -17398,11 +17387,6 @@ msgstr "<b>اكتملت المعالجة</b><br/><b>تمت المعالجة بو
|
|||
msgid "Bank Return Processing"
|
||||
msgstr "معالجة رجيع البنك"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_confirm_benefit_expense_form
|
||||
msgid "Process"
|
||||
msgstr "تمت المعالجة"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/wizards/reason_for_return_wizard.py:0
|
||||
#, python-format
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
default=lambda x: _('New'))
|
||||
state = fields.Selection(selection=[
|
||||
('draft', 'Draft'),
|
||||
('waiting_processing', 'Waiting for Processing'),
|
||||
('calculated', 'Calculated'),
|
||||
('assistant_general_manager', 'Waiting For The Assistant General Manager'),
|
||||
('accounting_approve', 'Accounting Approve'),
|
||||
|
|
@ -99,7 +98,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
line_domain_ids = fields.Many2many(comodel_name='benefit.expense.line', compute='_compute_domain_ids',
|
||||
string="Return Line Domain",
|
||||
)
|
||||
assigned_supervisor_id = fields.Many2one('hr.employee',string='Assigned Supervisor',tracking=True,copy=False)
|
||||
|
||||
@api.depends('payment_order_id', 'payment_order_id.state', 'move_id', 'move_id.state')
|
||||
def _compute_payment_move_state(self):
|
||||
|
|
@ -180,6 +178,11 @@ class ConfirmBenefitExpense(models.Model):
|
|||
if not return_lines:
|
||||
raise UserError(_("Please select at least one return line to calculate."))
|
||||
|
||||
if return_lines.filtered(lambda l: l.state == 'waiting_processing'):
|
||||
raise UserError(
|
||||
_("You cannot calculate because some return lines are still in 'Waiting Processing' state."))
|
||||
|
||||
self.benefit_expense_line_ids.unlink()
|
||||
lines = []
|
||||
for line in return_lines:
|
||||
lines.append((0, 0, {
|
||||
|
|
@ -231,7 +234,10 @@ class ConfirmBenefitExpense(models.Model):
|
|||
for rec in self:
|
||||
if rec.state != 'calculated':
|
||||
raise UserError(_("You can only recalculate when status is 'Calculated'."))
|
||||
rec._update_benefit_expense_lines()
|
||||
if rec.is_return_calculation:
|
||||
rec._calculate_return_lines()
|
||||
else:
|
||||
rec._update_benefit_expense_lines()
|
||||
|
||||
@api.depends('is_return_calculation', 'branch_custom_ids', 'start_date', 'end_date')
|
||||
def _compute_domain_ids(self):
|
||||
|
|
@ -345,28 +351,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
'target': 'new',
|
||||
}
|
||||
|
||||
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):
|
||||
self.ensure_one()
|
||||
if self.state != 'waiting_processing':
|
||||
raise UserError(_("You can only process when status is 'Waiting for Processing'."))
|
||||
|
||||
self.message_post(
|
||||
body=_('<b>Processing Completed</b><br/><b>Processed By:</b> %s') % self.env.user.name,
|
||||
message_type='notification',
|
||||
)
|
||||
|
||||
self.state = 'calculated'
|
||||
|
||||
def action_open_related_move_records(self):
|
||||
moves = self.move_id.ids
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class BenefitExpenseLine(models.Model):
|
|||
_name = 'benefit.expense.line'
|
||||
_description = 'Benefit Expense Line'
|
||||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_rec_name = 'family_id'
|
||||
|
||||
confirm_expense_id = fields.Many2one(comodel_name='confirm.benefit.expense', string='Confirm Benefit Expense',
|
||||
ondelete='cascade')
|
||||
|
|
@ -28,6 +29,12 @@ class BenefitExpenseLine(models.Model):
|
|||
payment_order_id = fields.Many2one('payment.orders', string='Payment Order', ondelete="set null", copy=False)
|
||||
return_reason_id = fields.Many2one("return.reason", string="Return Reason")
|
||||
is_return = fields.Boolean(string="Is Returned?", default=False)
|
||||
state = fields.Selection([
|
||||
('draft', 'Draft'),
|
||||
('waiting_processing', 'Waiting Processing'),
|
||||
('processing_done', 'Processing Done'),
|
||||
], string="Status", default='draft', tracking=True)
|
||||
assigned_supervisor_id = fields.Many2one('hr.employee', string='Assigned Supervisor', tracking=True, copy=False)
|
||||
|
||||
@api.depends('family_monthly_income', 'family_monthly_clotting', 'family_monthly_meals')
|
||||
def _compute_total_family_expenses(self):
|
||||
|
|
@ -47,3 +54,25 @@ class BenefitExpenseLine(models.Model):
|
|||
'default_line_model': 'benefit.expense.line',
|
||||
}
|
||||
}
|
||||
|
||||
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):
|
||||
self.ensure_one()
|
||||
if self.state != 'waiting_processing':
|
||||
raise UserError(_("You can only process when status is 'Waiting for Processing'."))
|
||||
|
||||
self.message_post(
|
||||
body=_('<b>Processing Completed</b><br/><b>Processed By:</b> %s') % self.env.user.name,
|
||||
message_type='notification',
|
||||
)
|
||||
|
||||
self.state = 'processing_done'
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@
|
|||
<field name="model">benefit.expense.line</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Benefit Expense Line">
|
||||
<header>
|
||||
<button name="action_process_return" string="Process"
|
||||
groups="odex_benefit.group_family_services_manager"
|
||||
type="object"
|
||||
states="waiting_processing"
|
||||
class="oe_highlight"/>
|
||||
<field name="state" widget="statusbar" statusbar_visible="draft,waiting_processing,processing_done"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
|
|
@ -65,6 +73,15 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_bank_return_benefit_expense" model="ir.actions.act_window">
|
||||
<field name="name">Bank Return Processing</field>
|
||||
<field name="res_model">benefit.expense.line</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="context">{'create': False}</field>
|
||||
<field name="domain">[('state','=','waiting_processing')]</field>
|
||||
</record>
|
||||
|
||||
<!-- Action -->
|
||||
<record id="action_benefit_expense_line" model="ir.actions.act_window">
|
||||
<field name="name">Benefit Expense Lines</field>
|
||||
|
|
|
|||
|
|
@ -49,19 +49,6 @@
|
|||
groups="odex_benefit.group_family_services_manager"
|
||||
type="object" states="draft" class="btn btn-info"/>
|
||||
|
||||
<button name="action_assign_supervisor" string="Assign to Supervisor"
|
||||
groups="odex_benefit.group_family_services_manager"
|
||||
type="object"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'draft'), ('is_return_calculation', '=', False)]}"
|
||||
class="btn-primary"/>
|
||||
|
||||
<!-- Waiting Processing State Buttons -->
|
||||
<button name="action_process_return" string="Process"
|
||||
groups="odex_benefit.group_family_services_manager"
|
||||
type="object"
|
||||
states="waiting_processing"
|
||||
class="oe_highlight"/>
|
||||
|
||||
<button string="Confirm" type="object" name="action_assistant_manager" class="oe_highlight"
|
||||
states="calculated" groups="odex_benefit.group_family_services_manager"/>
|
||||
<button string="Withdraw" type="object" name="action_reset_to_draft" class="btn btn-danger"
|
||||
|
|
@ -137,9 +124,6 @@
|
|||
</div>
|
||||
<field name="is_return_calculation" widget="boolean_toggle"
|
||||
attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||
<field name="assigned_supervisor_id"
|
||||
attrs="{'invisible': ['|',('assigned_supervisor_id','=',False),('is_return_calculation', '=', False)]}"
|
||||
readonly="1"/>
|
||||
<field name="branch_custom_ids" required="1"
|
||||
widget="many2many_tags" attrs="{'readonly':[('state', '!=', 'draft')]}"
|
||||
/>
|
||||
|
|
@ -163,7 +147,7 @@
|
|||
<!-- Notebook with Families page -->
|
||||
<notebook>
|
||||
<page string="Family Monthly Expense"
|
||||
attrs="{'invisible': [('state', 'in', ['draft','waiting_processing'])]}">
|
||||
attrs="{'invisible': [('state', 'in', ['draft'])]}">
|
||||
<div class="row mb-2">
|
||||
<!-- Family Count (Monthly Expense) -->
|
||||
<div class="col-6">
|
||||
|
|
@ -390,6 +374,18 @@
|
|||
<field name="payment_order_id" invisible="1"/>
|
||||
<field name="is_return"/>
|
||||
<field name="return_reason_id"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-info="state == 'draft'"
|
||||
decoration-warning="state == 'waiting_processing'"
|
||||
decoration-success="state == 'processing_done'"
|
||||
/>
|
||||
<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>
|
||||
</field>
|
||||
</page>
|
||||
|
|
@ -431,15 +427,6 @@
|
|||
<field name="view_id" ref="view_confirm_benefit_expense_tree"/>
|
||||
</record>
|
||||
|
||||
<record id="action_bank_return_benefit_expense" model="ir.actions.act_window">
|
||||
<field name="name">Bank Return Processing</field>
|
||||
<field name="res_model">confirm.benefit.expense</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('state','=','waiting_processing')]</field>
|
||||
<field name="view_id" ref="view_confirm_benefit_expense_tree"/>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="view_move_line_tree_new_code" model="ir.ui.view">
|
||||
<field name="name">account.move.line.form</field>
|
||||
<field name="model">account.move.line</field>
|
||||
|
|
|
|||
|
|
@ -206,20 +206,20 @@ class AssignSupervisorWizard(models.TransientModel):
|
|||
active_id = self._context.get('active_id')
|
||||
active_model = self._context.get('active_model')
|
||||
|
||||
if active_model == 'confirm.benefit.expense':
|
||||
expense = self.env[active_model].browse(active_id)
|
||||
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.message_post(
|
||||
expense_line.message_post(
|
||||
body=message,
|
||||
subject=_('Assigned to Supervisor'),
|
||||
message_type='notification',
|
||||
)
|
||||
expense.write({
|
||||
expense_line.write({
|
||||
'assigned_supervisor_id': self.supervisor_id.id,
|
||||
'state': 'waiting_processing'
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue