Merge pull request #1603 from expsa/ensan_tasks_19_10
Benefit customization
This commit is contained in:
commit
6120261fc0
|
|
@ -459,6 +459,7 @@ class GrantBenefitProfile(models.Model):
|
|||
total_move_lines = fields.Integer(string="Total Move Lines", compute='_get_total_move_lines')
|
||||
invoices_count = fields.Integer(string="Invoices Count", compute='_get_invoices_count')
|
||||
required_attach = fields.Selection(selection=[('true', 'True'), ('false', 'False')],compute='get_required_attach',store=True)
|
||||
income_required_attach = fields.Selection(selection=[('true', 'True'), ('false', 'False')],compute='get_income_required_attach',store=True)
|
||||
sa_iban = fields.Char('SA',default='SA',readonly=True)
|
||||
#Replacement Mother
|
||||
add_replacement_mother = fields.Boolean('Add Replacement Mother?')
|
||||
|
|
@ -533,6 +534,19 @@ class GrantBenefitProfile(models.Model):
|
|||
else:
|
||||
self.required_attach = 'true'
|
||||
|
||||
@api.depends('salary_ids')
|
||||
def get_income_required_attach(self):
|
||||
for rec in self.salary_ids:
|
||||
if rec.is_required and not rec.salary_attach:
|
||||
self.income_required_attach = None
|
||||
break
|
||||
elif rec.is_required and rec.salary_attach:
|
||||
self.income_required_attach = 'true'
|
||||
elif rec.is_default and not rec.is_required and (rec.salary_attach or not rec.salary_attach):
|
||||
self.income_required_attach = 'true'
|
||||
else:
|
||||
self.income_required_attach = 'true'
|
||||
|
||||
def _get_invoices_count(self):
|
||||
for rec in self:
|
||||
rec.invoices_count = self.env['account.move'].search_count([
|
||||
|
|
@ -786,6 +800,7 @@ class GrantBenefitProfile(models.Model):
|
|||
|
||||
# Prepare the list of default attachments for the one2many field
|
||||
default_attachments_data = []
|
||||
income_attachments_data = []
|
||||
for attach in default_attachment:
|
||||
if attach.attach_type == 'family_attach':
|
||||
default_attachments_data.append((0, 0, {
|
||||
|
|
@ -793,11 +808,18 @@ class GrantBenefitProfile(models.Model):
|
|||
'is_required': attach.is_required,
|
||||
'is_default': attach.is_default,
|
||||
}))
|
||||
if attach.attach_type == 'income_attach':
|
||||
income_attachments_data.append((0, 0, {
|
||||
'income_type': attach.id,
|
||||
'is_required': attach.is_required,
|
||||
'is_default': attach.is_default,
|
||||
}))
|
||||
|
||||
# Add the default attachments to the res dictionary for attachment_ids
|
||||
if 'attachment_ids' in fields:
|
||||
res['attachment_ids'] = default_attachments_data
|
||||
|
||||
if 'salary_ids' in fields:
|
||||
res['salary_ids'] = income_attachments_data
|
||||
return res
|
||||
|
||||
@api.model
|
||||
|
|
@ -1541,7 +1563,7 @@ class GrantBenefitProfile(models.Model):
|
|||
else:
|
||||
ben.non_member_count = 0.0
|
||||
|
||||
@api.depends('salary_ids', 'expenses_ids', 'family_debits_ids','mother_income')
|
||||
@api.depends('salary_ids', 'expenses_ids', 'family_debits_ids','mother_income','benefit_member_count')
|
||||
def get_member_income(self):
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
max_income_for_mother = validation_setting.max_income_for_mother
|
||||
|
|
|
|||
|
|
@ -289,13 +289,33 @@ class Salary(models.Model):
|
|||
benefit_id = fields.Many2one(
|
||||
'grant.benefit')
|
||||
salary_type = fields.Char()
|
||||
income_type = fields.Many2one('income.type',string='Income Type')
|
||||
income_type = fields.Many2one('attachments.settings',string='Income Type',domain="[('attach_type','=','income_attach')]")
|
||||
salary_amount = fields.Float(
|
||||
string='Income Amount',
|
||||
required=False)
|
||||
salary_attach = fields.Binary(string="Attachment",attachment=True)
|
||||
salary_attach = fields.Many2many('ir.attachment',string="Attachment")
|
||||
attach_start_date = fields.Date(string='Attach Start Date')
|
||||
attach_end_date = fields.Date(string='Attach End Date')
|
||||
is_required = fields.Boolean(string='Is Required?')
|
||||
is_default = fields.Boolean(string='Is Default?')
|
||||
state = fields.Selection(string='Status',selection=[('accepted', 'Accepted'),('refused', 'Refused')])
|
||||
# total_salary = fields.Float(string="Total Salary", compute='_compute_total_salary',store=True)
|
||||
|
||||
# @api.depends('salary_amount','state')
|
||||
# def _compute_total_salary(self):
|
||||
# total = 0
|
||||
# for record in self:
|
||||
# # Apply your custom condition here
|
||||
# records = self.env['salary.line'].search([('state', '=', 'accepted')])
|
||||
# for rec in records:
|
||||
# total += rec.salary_amount
|
||||
# record.total_salary = total
|
||||
|
||||
def action_accept(self):
|
||||
self.state = 'accepted'
|
||||
|
||||
def action_refuse(self):
|
||||
self.state = 'refused'
|
||||
|
||||
class ibanBanks(models.Model):
|
||||
_inherit = 'res.bank'
|
||||
|
|
@ -594,7 +614,7 @@ class AttachmentsSettings(models.Model):
|
|||
disabilities_id = fields.Many2one('disabilities.settings',string='Disabilities')
|
||||
attach_type = fields.Selection(
|
||||
[('family_attach', _('Family Attach')), ('member_attach', _('Member Attach')), ('hobbies_attach', _('Hobbies Attach')),
|
||||
('diseases_attach', _('Diseases Attach')), ('disabilities_attach', _('Disabilities Attach'))])
|
||||
('diseases_attach', _('Diseases Attach')), ('disabilities_attach', _('Disabilities Attach')), ('income_attach', _('Income Attach'))])
|
||||
is_required = fields.Boolean(string='Is Required?')
|
||||
is_default = fields.Boolean(string='Is Default?')
|
||||
|
||||
|
|
|
|||
|
|
@ -864,15 +864,23 @@
|
|||
</page>
|
||||
<page string="Income and salary">
|
||||
<field name="salary_ids" attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}">
|
||||
<tree editable="bottom">
|
||||
<tree editable="bottom" delete="0">
|
||||
<field name="benefit_id" invisible="1"/>
|
||||
<field name="income_type"/>
|
||||
<field name="salary_amount" sum="salary_amount"/>
|
||||
<field name="salary_attach"/>
|
||||
<field name="salary_amount"/>
|
||||
<field name="salary_attach" widget="many2many_attachment_preview"/>
|
||||
<field name="attach_start_date"/>
|
||||
<field name="attach_end_date"/>
|
||||
<button name="action_accept" type="object" string="Accept" class="oe_highlight" attrs="{'invisible':[('state','=','accepted')]}"/>
|
||||
<button name="action_refuse" type="object" string="Refuse" class="oe_highlight" attrs="{'invisible':[('state','=','refused')]}"/>
|
||||
<field name="state" readonly="1" force_save="1"/>
|
||||
<field name="is_required" invisible="1"/>
|
||||
<field name="is_default" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
<group>
|
||||
<field name="income_required_attach" attrs="{'required':[('state','not in',['draft'])]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Family Cars" attrs="{'invisible':[('has_car','=',False)]}">
|
||||
<group>
|
||||
|
|
|
|||
Loading…
Reference in New Issue