Merge pull request #5317 from expsa/tt_dev_odex25_ensan
[IMP] odex_benefit: IMP benefit
This commit is contained in:
commit
8ccebbcec6
|
|
@ -1047,11 +1047,6 @@ msgstr "حساب"
|
|||
msgid "Account Holder Name"
|
||||
msgstr "اسم مالك الحساب"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__confirm_benefit_expense__state__account_manager
|
||||
msgid "Account Manager"
|
||||
msgstr "اعتماد المدير المالي"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__acc_number
|
||||
msgid "Account Number"
|
||||
|
|
@ -3207,7 +3202,7 @@ msgstr "مصاريف الاسر"
|
|||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__confirm_benefit_expense__state__confirm
|
||||
msgid "Confirmed"
|
||||
msgstr "مؤكد"
|
||||
msgstr "تم"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_benefits_representative__child_ids
|
||||
|
|
@ -4183,11 +4178,6 @@ msgstr "تاريخ التوصيل"
|
|||
msgid "Department"
|
||||
msgstr "القسم"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__confirm_benefit_expense__state__depart_manager
|
||||
msgid "Department Manager"
|
||||
msgstr "اعتماد رئيس اقسم"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_branch_settings__name
|
||||
msgid "Department Name"
|
||||
|
|
|
|||
|
|
@ -30,9 +30,8 @@ class ConfirmBenefitExpense(models.Model):
|
|||
state = fields.Selection(selection=[
|
||||
('draft', 'Draft'),
|
||||
('calculated', 'Calculated'),
|
||||
('assistant_general_manager', 'Waiting For The Assistant General Manager'), # Translate
|
||||
('depart_manager', 'Department Manager'),
|
||||
('account_manager', 'Account Manager'),
|
||||
('assistant_general_manager', 'Waiting For The Assistant General Manager'),
|
||||
('accounting_approve', 'Accounting Approve'),
|
||||
('cancel', 'Cancelled'),
|
||||
('confirm', 'Confirmed'),
|
||||
], string='Status', default='draft', required=True, copy=False, tracking=True)
|
||||
|
|
@ -40,8 +39,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
('family_expense', 'Family Expense'),
|
||||
('family_invoice', 'Meal Card Invoice'),
|
||||
], string='Expense Type', default='family_expense', required=True)
|
||||
journal_id = fields.Many2one(comodel_name='account.journal', string="Journal", copy=False)
|
||||
|
||||
name = fields.Char(string="Name", states={'confirm': [('readonly', True)]}, copy=False)
|
||||
date = fields.Date(string="Date", default=fields.Date.context_today, required=False,
|
||||
states={'confirm': [('readonly', True)]})
|
||||
|
|
@ -57,7 +54,8 @@ class ConfirmBenefitExpense(models.Model):
|
|||
cash_expense = fields.Boolean(string='Include Cash Expense', states={'confirm': [('readonly', True)]})
|
||||
meal_expense = fields.Boolean(string='Include Meal Expense', states={'confirm': [('readonly', True)]})
|
||||
cloth_expense = fields.Boolean(string='Include Clothing Expense', states={'confirm': [('readonly', True)]})
|
||||
|
||||
payment_order_id = fields.Many2one('payment.orders', string='Payment Order', ondelete="set null", copy=False)
|
||||
move_id = fields.Many2one('account.move', ondelete='cascade')
|
||||
# payment_method_id = fields.Many2one(comodel_name='account.payment.method.line', string='Payment Method',
|
||||
# readonly=False, store=True, copy=False,
|
||||
# states={'confirm': [('readonly', True)]},
|
||||
|
|
@ -80,10 +78,31 @@ class ConfirmBenefitExpense(models.Model):
|
|||
family_monthly_total = fields.Float(string="Total", compute='_get_family_monthly_values')
|
||||
branch_custom_id = fields.Many2one(comodel_name='branch.settings', string="Branch")
|
||||
family_domain_ids = fields.Many2many(comodel_name='grant.benefit', compute='_compute_domain_ids')
|
||||
journal_domain_ids = fields.Many2many(comodel_name='account.journal', compute='_compute_domain_ids')
|
||||
company_id = fields.Many2one('res.company', default=lambda self: self.env.company)
|
||||
currency_id = fields.Many2one(comodel_name='res.currency', string="Company Currency",
|
||||
related='company_id.currency_id')
|
||||
payment_state = fields.Selection(string='Payment State', selection=[
|
||||
('none', 'None'),
|
||||
('waiting', 'Waiting Payment'),
|
||||
('done', 'Done Payment'), ], copy=False, compute="_compute_payment_state", store=True)
|
||||
|
||||
@api.depends('payment_order_id', 'payment_order_id.state', 'move_id', 'move_id.state')
|
||||
def _compute_payment_state(self):
|
||||
for rec in self:
|
||||
payment_state = 'none'
|
||||
if rec.payment_order_id:
|
||||
if rec.payment_order_id.state == "done":
|
||||
payment_state = "done"
|
||||
rec.state = "confirm"
|
||||
else:
|
||||
payment_state = "waiting"
|
||||
elif rec.move_id:
|
||||
if rec.move_id.state == "posted":
|
||||
payment_state = "done"
|
||||
rec.state = "confirm"
|
||||
else:
|
||||
payment_state = "waiting"
|
||||
rec.payment_state = payment_state
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
|
|
@ -94,20 +113,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
res.family_expense_seq = self.env['ir.sequence'].sudo().next_by_code('family.expense.sequence') or _('New')
|
||||
return res
|
||||
|
||||
# @api.onchange('branch_custom_id') # Specify dependencies
|
||||
# def _onchange_family_ids(self):
|
||||
# for record in self:
|
||||
# if record.branch_custom_id :
|
||||
# # Logic to determine the family_ids based on branch_custom_id
|
||||
# related_records = self.env['grant.benefit'].search([('branch_custom_id', '=', record.branch_custom_id.id),('state','=','second_approve')])
|
||||
# if related_records:
|
||||
# record.family_ids = [(6, 0, related_records.ids)] # 6 means 'set' in Many2many
|
||||
# else:
|
||||
# record.family_ids = [(5,)] # Clear the records if source_field is empty
|
||||
# raise UserError(_('Select Family'))
|
||||
# else:
|
||||
# record.family_ids = [(5,)] # Clear the records if source_field is empty
|
||||
|
||||
def _update_benefit_expense_lines(self):
|
||||
self.ensure_one()
|
||||
for line in self.benefit_expense_line_ids:
|
||||
|
|
@ -183,12 +188,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
@api.depends('expense_type', 'date', 'branch_custom_id', 'start_date', 'end_date')
|
||||
def _compute_domain_ids(self):
|
||||
for rec in self:
|
||||
journal_domain = []
|
||||
if rec.expense_type == 'family_expense':
|
||||
journal_domain = [('type', 'in', ['bank', 'cash'])]
|
||||
elif rec.expense_type == 'family_invoice':
|
||||
journal_domain = [('type', 'in', ['purchase'])]
|
||||
|
||||
# Define base domain for family selection
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
base_domain = ['|', ('state', '=', 'second_approve'), '&',
|
||||
|
|
@ -220,13 +219,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
base_domain.append(('id', 'not in', conflicting_family_ids))
|
||||
|
||||
rec.family_domain_ids = self.env['grant.benefit'].search(base_domain)
|
||||
# related_records = self.family_ids = self.env['grant.benefit'].search(base_domain)
|
||||
# if related_records:
|
||||
# self.family_ids = [(6, 0, related_records.ids)] # 6 means 'set' in Many2many
|
||||
# else:
|
||||
# self.family_ids = [(5,)] # Clear the records if source_field is empty
|
||||
# rec.family_ids = self.env['grant.benefit'].search(base_domain).ids
|
||||
rec.journal_domain_ids = self.env['account.journal'].search(journal_domain)
|
||||
|
||||
def unlink(self):
|
||||
for rec in self:
|
||||
|
|
@ -242,13 +234,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
rec.family_monthly_clotting = sum(rec.benefit_expense_line_ids.mapped('family_monthly_clotting'))
|
||||
rec.family_monthly_total = rec.family_monthly_income + rec.family_monthly_meals + rec.family_monthly_clotting
|
||||
|
||||
@api.onchange('expense_type')
|
||||
def _onchange_journal_id(self):
|
||||
if self.expense_type == 'family_expense':
|
||||
self.journal_id = self.env["family.validation.setting"].search([], limit=1).journal_id.id
|
||||
else:
|
||||
self.journal_id = False
|
||||
|
||||
def action_assistant_manager(self):
|
||||
if self.expense_type != 'family_expense':
|
||||
self.state = 'assistant_general_manager'
|
||||
|
|
@ -271,17 +256,16 @@ class ConfirmBenefitExpense(models.Model):
|
|||
|
||||
self.state = 'assistant_general_manager'
|
||||
|
||||
def action_depart_manager(self):
|
||||
self.state = 'depart_manager'
|
||||
|
||||
def action_accounting_manager(self):
|
||||
self.state = 'account_manager'
|
||||
def action_accounting_approve(self):
|
||||
self.state = 'accounting_approve'
|
||||
|
||||
def action_cancel(self):
|
||||
self.state = 'cancel'
|
||||
|
||||
def action_reset_to_draft(self):
|
||||
self.benefit_expense_line_ids.unlink()
|
||||
self.payment_order_id.unlink()
|
||||
self.move_id.unlink()
|
||||
self.state = 'draft'
|
||||
|
||||
def _get_total_move_lines(self):
|
||||
|
|
@ -354,22 +338,8 @@ class ConfirmBenefitExpense(models.Model):
|
|||
# else:
|
||||
# pay.payment_method_id = False
|
||||
|
||||
# @api.depends('journal_id')
|
||||
# def _compute_payment_method_line_fields(self):
|
||||
# for pay in self:
|
||||
# pay.available_payment_method_line_ids = pay.journal_id._get_available_payment_method_lines('outbound')
|
||||
|
||||
@api.onchange('expense_type', 'date', 'branch_custom_id', 'start_date', 'end_date')
|
||||
def _onchange_expense_type(self):
|
||||
"""Restrict families to a single expense type per month."""
|
||||
journal_domain = []
|
||||
|
||||
# Define journal domains based on expense type
|
||||
if self.expense_type == 'family_expense':
|
||||
journal_domain = [('type', 'in', ['bank', 'cash'])]
|
||||
elif self.expense_type == 'family_invoice':
|
||||
journal_domain = [('type', 'in', ['purchase'])]
|
||||
|
||||
# Define base domain for family selection
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
|
||||
|
|
@ -411,11 +381,10 @@ class ConfirmBenefitExpense(models.Model):
|
|||
return {
|
||||
'domain': {
|
||||
'family_ids': base_domain,
|
||||
'journal_id': journal_domain,
|
||||
}
|
||||
}
|
||||
|
||||
def action_confirm_selected(self):
|
||||
def action_accounting_transfer(self):
|
||||
for rec in self:
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
lines = rec.benefit_expense_line_ids
|
||||
|
|
@ -440,12 +409,13 @@ class ConfirmBenefitExpense(models.Model):
|
|||
if not credit_account_id:
|
||||
raise UserError(_("Please select credit account."))
|
||||
|
||||
self.env['payment.orders'].create({
|
||||
payment_order = self.env['payment.orders'].create({
|
||||
'state': 'draft',
|
||||
'accountant_id': validation_setting.accountant_id.id,
|
||||
'benefit_expense_line_ids': [(6, 0, rec.benefit_expense_line_ids.ids)],
|
||||
'type': 'benefit_expense',
|
||||
})
|
||||
rec.payment_order_id = payment_order
|
||||
else:
|
||||
account_id = validation_setting.meal_expense_account_id
|
||||
invoice_lines = []
|
||||
|
|
@ -465,13 +435,13 @@ class ConfirmBenefitExpense(models.Model):
|
|||
'invoice_date': rec.date,
|
||||
'family_confirm_id': rec.id,
|
||||
'benefit_family_ids': [(6, 0, rec.benefit_expense_line_ids.mapped('family_id').ids)],
|
||||
'journal_id': rec.journal_id.id,
|
||||
'journal_id': validation_setting.journal_id.id,
|
||||
'invoice_line_ids': invoice_lines,
|
||||
'ref': rec.name,
|
||||
}
|
||||
|
||||
invoice = self.env['account.move'].create(invoice_vals)
|
||||
invoice.action_post()
|
||||
rec.state = 'confirm'
|
||||
rec.move_id = invoice
|
||||
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ class SeasonalService(models.Model):
|
|||
if rec.payment_order_state:
|
||||
if rec.payment_order_id.state == "done":
|
||||
payment_order_state = "done"
|
||||
rec.service_requests_ids.write({'state': 'send_request_to_supplier'})
|
||||
rec.state = 'waiting_receive'
|
||||
else:
|
||||
payment_order_state = "waiting"
|
||||
rec.payment_order_state = payment_order_state
|
||||
|
|
@ -192,11 +194,6 @@ class SeasonalService(models.Model):
|
|||
rec.state = 'waiting_receive'
|
||||
rec.service_requests_ids.write({'state': 'send_request_to_supplier'})
|
||||
|
||||
def action_accounting_approve(self):
|
||||
for rec in self:
|
||||
rec.service_requests_ids.write({'state': 'send_request_to_supplier'})
|
||||
rec.state = 'waiting_receive'
|
||||
|
||||
def action_create_payment_order(self):
|
||||
for rec in self:
|
||||
self.env['payment.orders'].create({
|
||||
|
|
|
|||
|
|
@ -16,10 +16,16 @@
|
|||
options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-info="state in ['draft','calculated']"
|
||||
decoration-warning="state in ['account_manager','depart_manager','assistant_general_manager']"
|
||||
decoration-warning="state in ['assistant_general_manager']"
|
||||
decoration-success="state in ['confirm']"
|
||||
decoration-muted="state == 'cancel'"
|
||||
/>
|
||||
<field name="payment_state"
|
||||
widget="badge"
|
||||
decoration-info="payment_state == 'none'"
|
||||
decoration-warning="payment_state == 'waiting'"
|
||||
decoration-success="payment_state == 'done'"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
@ -32,10 +38,8 @@
|
|||
<form string="Confirm Benefit Expense">
|
||||
<header>
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="draft,calculated,assistant_general_manager,depart_manager,account_manager,confirm"/>
|
||||
<!-- <button string="Cancel" type="object" name="action_cancel" class="btn btn-danger"-->
|
||||
<!-- states="assistant_general_manager,depart_manager,account_manager"-->
|
||||
<!-- groups="odex_benefit.group_benefit_manager"/>-->
|
||||
statusbar_visible="draft,calculated,accounting_approve,assistant_general_manager,confirm"/>
|
||||
|
||||
<button name="action_calculate" string="Calculate"
|
||||
type="object" states="draft" class="btn btn-info"/>
|
||||
|
||||
|
|
@ -43,25 +47,22 @@
|
|||
states="calculated"/>
|
||||
<button string="Withdraw" type="object" name="action_reset_to_draft" class="btn btn-danger"
|
||||
states="calculated"/>
|
||||
<button name="action_recalculate" string="Recalculate" class="btn btn-info"
|
||||
<button string="Recalculate" name="action_recalculate" class="btn btn-info"
|
||||
type="object" states="calculated"/>
|
||||
|
||||
<button string="Confirm" type="object" name="action_depart_manager" class="oe_highlight"
|
||||
<button string="Confirm" type="object" name="action_accounting_approve" class="oe_highlight"
|
||||
states="assistant_general_manager"
|
||||
groups="odex25_account_payment_fix.group_depart_manager"/>
|
||||
<button string="Reset" type="object" name="action_reset_to_draft" class="btn btn-danger"
|
||||
states="assistant_general_manager"
|
||||
groups="odex25_account_payment_fix.group_depart_manager"/>
|
||||
|
||||
<button string="Confirm" type="object" name="action_accounting_manager" class="oe_highlight"
|
||||
states="depart_manager" groups="odex25_account_payment_fix.group_accounting_manager"/>
|
||||
<button string="Accounting Transfer" type="object" name="action_accounting_transfer"
|
||||
class="oe_highlight"
|
||||
attrs="{'invisible': ['|','|',('state', '!=', 'accounting_approve'),'&',('payment_order_id','!=',False),('expense_type','=','family_expense'),'&',('move_id','!=',False),('expense_type','=','family_invoice')]}"
|
||||
/>
|
||||
<button string="Reset" type="object" name="action_reset_to_draft" class="btn btn-danger"
|
||||
states="depart_manager" groups="odex25_account_payment_fix.group_accounting_manager"/>
|
||||
|
||||
<button string="Confirm" type="object" name="action_confirm_selected" class="oe_highlight"
|
||||
states="account_manager" groups="odex25_account_payment_fix.group_general_manager"/>
|
||||
<button string="Reset" type="object" name="action_reset_to_draft" class="btn btn-danger"
|
||||
states="account_manager" groups="odex25_account_payment_fix.group_general_manager"/>
|
||||
states="accounting_approve"/>
|
||||
</header>
|
||||
<sheet>
|
||||
<div class="oe_button_box" name="button_box">
|
||||
|
|
@ -72,8 +73,12 @@
|
|||
<field name="total_invoices" widget="statinfo" string="Total Moves"/>
|
||||
</button>
|
||||
</div>
|
||||
<field name="payment_state" invisible="1"/>
|
||||
<widget name="web_ribbon" title="Payment Done" bg_color="bg-success"
|
||||
attrs="{'invisible': [('payment_state', '!=', 'done')]}"/>
|
||||
<widget name="web_ribbon" title="Payment Waiting" bg_color="bg-warning"
|
||||
attrs="{'invisible': [('payment_state', '!=', 'waiting')]}"/>
|
||||
<field name="family_domain_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="journal_domain_ids" widget="many2many_tags" invisible="1"/>
|
||||
<div class="oe_title">
|
||||
<h1>
|
||||
<field name="family_expense_seq" readonly="1"/>
|
||||
|
|
@ -98,10 +103,11 @@
|
|||
</group>
|
||||
<group>
|
||||
<field name="expense_type" required="1" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||
<field name="journal_id" domain="[('id', 'in', journal_domain_ids)]"
|
||||
attrs="{'required': [('expense_type', '=', 'family_invoice')],'invisible': [('expense_type', '!=', 'family_invoice')]}"
|
||||
forec_save="1"/>
|
||||
<field name="date" required="1" attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||
<field name="payment_order_id" readonly="1"
|
||||
attrs="{'invisible': [('payment_order_id', '=', False)]}"/>
|
||||
<field name="move_id" readonly="1"
|
||||
attrs="{'invisible': [('move_id', '=', False)]}"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
|
|
@ -183,12 +189,6 @@
|
|||
<filter string="Draft" name="draft" domain="[('state','=','draft')]"/>
|
||||
<separator/>
|
||||
<separator/>
|
||||
<filter string="Depart Manager" name="depart_manager" domain="[('state', '=', 'depart_manager')]"/>
|
||||
<separator/>
|
||||
<separator/>
|
||||
<filter string="Account Manager" name="account_manager" domain="[('state', '=', 'account_manager')]"/>
|
||||
<separator/>
|
||||
<separator/>
|
||||
<filter string="Cancel" name="cancel" domain="[('state', '=', 'cancel')]"/>
|
||||
<separator/>
|
||||
<separator/>
|
||||
|
|
|
|||
|
|
@ -142,9 +142,9 @@
|
|||
/>
|
||||
<field name="payment_order_state"
|
||||
widget="badge"
|
||||
decoration-info="state == 'none'"
|
||||
decoration-warning="state == 'waiting'"
|
||||
decoration-success="state == 'done'"
|
||||
decoration-info="payment_order_state == 'none'"
|
||||
decoration-warning="payment_order_state == 'waiting'"
|
||||
decoration-success="payment_order_state == 'done'"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
|
|
|
|||
|
|
@ -491,7 +491,12 @@
|
|||
decoration-danger="state in ['refused']"
|
||||
decoration-info="state in ['first_approve','waiting_approve']"
|
||||
decoration-warning="state in ['researcher']"/>
|
||||
<field name="payment_order_state"/>
|
||||
<field name="payment_order_state"
|
||||
widget="badge"
|
||||
decoration-info="payment_order_state == 'none'"
|
||||
decoration-warning="payment_order_state == 'waiting'"
|
||||
decoration-success="payment_order_state == 'done'"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
Loading…
Reference in New Issue