Merge pull request #5427 from expsa/younes_dev_odex25_ensan
Younes dev odex25 ensan
This commit is contained in:
commit
009b091b4c
|
|
@ -47,9 +47,12 @@ class ConfirmBenefitExpense(models.Model):
|
|||
copy=False)
|
||||
benefit_expense_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='confirm_expense_id',
|
||||
string='Benefit Expense Lines')
|
||||
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)]})
|
||||
othaim_line_ids = fields.One2many(comodel_name='benefit.expense.line', inverse_name='confirm_expense_id',
|
||||
string='Othaim Lines', domain=[('meal_card', '=', True)])
|
||||
cash_expense = fields.Boolean(string='Include Cash Expense', default=True, states={'confirm': [('readonly', True)]})
|
||||
meal_expense = fields.Boolean(string='Include Meal Expense', default=True, states={'confirm': [('readonly', True)]})
|
||||
cloth_expense = fields.Boolean(string='Include Clothing Expense', default=True,
|
||||
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')
|
||||
available_payment_method_line_ids = fields.Many2many(comodel_name='account.payment.method.line')
|
||||
|
|
@ -118,7 +121,7 @@ class ConfirmBenefitExpense(models.Model):
|
|||
self.ensure_one()
|
||||
for line in self.benefit_expense_line_ids:
|
||||
family = line.family_id
|
||||
income, meals, clotting = 0, 0, 0
|
||||
income, meals, clotting, othaim = 0, 0, 0
|
||||
if not family:
|
||||
continue
|
||||
monthly_meals = 0.0 if family.meal_card else family.family_monthly_meals
|
||||
|
|
@ -127,6 +130,7 @@ class ConfirmBenefitExpense(models.Model):
|
|||
income = family.family_monthly_income
|
||||
if self.meal_expense:
|
||||
meals = monthly_meals
|
||||
othaim = othaime
|
||||
if self.cloth_expense:
|
||||
clotting = family.family_monthly_clotting
|
||||
vals = {
|
||||
|
|
@ -139,7 +143,7 @@ class ConfirmBenefitExpense(models.Model):
|
|||
'family_monthly_income': income,
|
||||
'family_monthly_meals': meals,
|
||||
'family_monthly_clotting': clotting,
|
||||
'family_monthly_othaime': othaime,
|
||||
'family_monthly_othaime': othaim,
|
||||
}
|
||||
line.write(vals)
|
||||
|
||||
|
|
@ -152,7 +156,6 @@ class ConfirmBenefitExpense(models.Model):
|
|||
if not families:
|
||||
raise UserError(_("Please select at least one family to calculate."))
|
||||
|
||||
# Todo ask awatif
|
||||
if not rec.cash_expense and not rec.meal_expense and not rec.cloth_expense:
|
||||
raise UserError(_("At least one expense type should be selected."))
|
||||
|
||||
|
|
@ -239,25 +242,12 @@ class ConfirmBenefitExpense(models.Model):
|
|||
rec.member_count_othaim = sum(othaim_lines.mapped('benefit_member_count'))
|
||||
|
||||
def action_assistant_manager(self):
|
||||
# Todo ask awatif
|
||||
# if self.expense_type != 'family_expense':
|
||||
# self.state = 'assistant_general_manager'
|
||||
# return
|
||||
|
||||
disbursement_date = False
|
||||
# if not disbursement_date:
|
||||
last_expense = self.search(
|
||||
[("state", "=", "confirm"), ("end_date", "!=", False)],
|
||||
order="id desc",
|
||||
limit=1
|
||||
)
|
||||
if last_expense:
|
||||
disbursement_date = last_expense.end_date
|
||||
|
||||
# Apply the disbursement date to all families
|
||||
if disbursement_date:
|
||||
for family in self.family_ids:
|
||||
family.last_disbursement_date = disbursement_date
|
||||
for family in self.family_ids:
|
||||
if self.end_date and family.last_disbursement_date:
|
||||
if self.end_date > family.last_disbursement_date:
|
||||
family.last_disbursement_date = self.end_date
|
||||
else:
|
||||
family.last_disbursement_date = self.end_date
|
||||
|
||||
self.state = 'assistant_general_manager'
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
<field name="family_expense_seq"/>
|
||||
<field name="date"/>
|
||||
<field name="name" string="Description"/>
|
||||
<field name="branch_custom_ids" widget="many2many_tags"/>
|
||||
<field name="currency_id" invisible="1" groups="base.group_multi_currency"/>
|
||||
<field name="family_monthly_total" decoration-bf="1" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
|
|
@ -136,37 +135,109 @@
|
|||
attrs="{'readonly':[('state', '!=', 'draft')]}"/>
|
||||
<field name="company_id" groups="base.group_multi_company"/>
|
||||
<field name="currency_id" invisible="1" groups="base.group_multi_currency"/>
|
||||
</group>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<group>
|
||||
<field name="available_payment_method_line_ids" invisible="1"/>
|
||||
<field name="family_monthly_income" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'invisible': [('cash_expense', '=', False)]}"/>
|
||||
<field name="family_monthly_meals" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'invisible': [('meal_expense', '=', False)]}"/>
|
||||
<field name="family_monthly_clotting" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'invisible': [('cloth_expense', '=', False)]}"/>
|
||||
<field name="family_monthly_total" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="family_count_expense"/>
|
||||
<field name="member_count_expense"/>
|
||||
<field name="family_count_othaim"/>
|
||||
<field name="member_count_othaim"/>
|
||||
<field name="family_monthly_othaime" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
/>
|
||||
</group>
|
||||
</group>
|
||||
<!-- Notebook with Families page -->
|
||||
<notebook>
|
||||
<page string="Family Monthly Expense" attrs="{'invisible': [('state', '=', 'draft')]}">
|
||||
<div class="row mb-2">
|
||||
<!-- Family Count (Monthly Expense) -->
|
||||
<div class="col-6">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e3f2fd; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-home text-primary"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Family Count (Monthly Expense)
|
||||
</span>
|
||||
<span class="badge badge-primary"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_count_expense"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Member Count (Monthly Expense) -->
|
||||
<div class="col-6">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e0f7fa; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-users text-info" style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Member Count (Monthly Expense)
|
||||
</span>
|
||||
<span class="badge badge-info"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="member_count_expense"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-2">
|
||||
<div class="col-12">
|
||||
<div class="row text-center">
|
||||
<div class="col-3">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e3f2fd; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-money text-success"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Total Monthly Income
|
||||
</span>
|
||||
<span class="badge badge-primary"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_monthly_income" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Total Monthly Meals -->
|
||||
<div class="col-3">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #fff3e0; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-money text-success"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Total Monthly Meals
|
||||
</span>
|
||||
<span class="badge badge-warning"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_monthly_meals" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Total Monthly Clothing -->
|
||||
<div class="col-3">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e0f7fa; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-money text-success"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Total Monthly Clothing
|
||||
</span>
|
||||
<span class="badge badge-info"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_monthly_clotting" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Monthly Total -->
|
||||
<div class="col-3">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e8f7ef;padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-calculator text-success"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Total</span>
|
||||
<span class="badge badge-success"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_monthly_total" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<field name="benefit_expense_line_ids" readonly="1">
|
||||
<tree>
|
||||
<field name="family_id"/>
|
||||
|
|
@ -183,6 +254,64 @@
|
|||
<field name="family_monthly_clotting"
|
||||
attrs="{'column_invisible': [('parent.cloth_expense', '!=', True)]}"/>
|
||||
<field name="total_family_expenses"/>
|
||||
<field name="payment_order_id" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Othaim Line"
|
||||
attrs="{'invisible': ['|',('state', '=', 'draft'),('meal_expense', '=', False)]}">
|
||||
<div class="row mb-2">
|
||||
<!-- Family Count -->
|
||||
<div class="col-4">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e3f2fd; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-home text-primary"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Family Count (Othaim)</span>
|
||||
<span class="badge badge-primary"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_count_othaim"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Member Count -->
|
||||
<div class="col-4">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e0f7fa; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-users text-info" style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Member Count (Othaim)</span>
|
||||
<span class="badge badge-info"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="member_count_othaim"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Total Othaim -->
|
||||
<div class="col-4">
|
||||
<div class="d-flex flex-column align-items-center"
|
||||
style="background-color: #e8f5e9; padding: 8px; border-radius: 8px;">
|
||||
<i class="fa fa-money text-success"
|
||||
style="font-size: 20px; margin-bottom: 4px;"/>
|
||||
<span style="font-size: 12px; color: #555;">Total Othaim</span>
|
||||
<span class="badge badge-success"
|
||||
style="font-size: 14px; padding: 4px 8px; margin-top: 3px; border-radius: 8px;">
|
||||
<field name="family_monthly_othaime" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<field name="othaim_line_ids" readonly="1">
|
||||
<tree>
|
||||
<field name="family_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="family_category_id"/>
|
||||
<field name="start_date" invisible="1"/>
|
||||
<field name="end_date" invisible="1"/>
|
||||
<field name="meal_card"/>
|
||||
<field name="benefit_member_count"/>
|
||||
<field name="family_monthly_othaime"/>
|
||||
<field name="payment_order_id" invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
|||
Loading…
Reference in New Issue