FIX issues in Service and debits service
This commit is contained in:
parent
27e2cb8b63
commit
ace4014edd
|
|
@ -24,12 +24,11 @@ class PaymentOrders(models.Model):
|
|||
res.name = self.env['ir.sequence'].sudo().next_by_code('payment.orders.sequence') or _('New')
|
||||
return res
|
||||
|
||||
# @api.model
|
||||
# def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
# if self.env.user and self.env.user.id and self.env.user.has_group(
|
||||
# "odex_benefit.group_benefit_accountant_accept"):
|
||||
# args += [('accountant_id', '=', self.env.user.id)]
|
||||
# return super(PaymentOrders, self).search(args, offset, limit, order, count)
|
||||
@api.model
|
||||
def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
if self.env.user and self.env.user.id and self.env.user.has_group("odex_benefit.group_benefit_payment_accountant_accept"):
|
||||
args += [('accountant_id', '=', self.env.user.id)]
|
||||
return super(PaymentOrders, self).search(args, offset, limit, order, count)
|
||||
|
||||
def _get_total_moves(self):
|
||||
for rec in self:
|
||||
|
|
|
|||
|
|
@ -126,12 +126,15 @@ class ServiceRequest(models.Model):
|
|||
state_a = fields.Selection(related='state', tracking=False)
|
||||
state_b = fields.Selection(related='state', tracking=False)
|
||||
|
||||
# @api.model
|
||||
# def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
# if self.env.user and self.env.user.id and self.env.user.has_group(
|
||||
# "odex_benefit.group_benefit_accountant_accept"):
|
||||
# args += [('accountant_id', '=', self.env.user.id)]
|
||||
# return super(ServiceRequest, self).search(args, offset, limit, order, count)
|
||||
@api.model
|
||||
def search(self, args, offset=0, limit=None, order=None, count=False):
|
||||
if self.env.user and self.env.user.id and self.env.user.has_group("odex_benefit.group_benefit_accountant_accept")\
|
||||
and not self.env.user.has_group("odex_benefit.group_benefit_payment_accountant_accept") :
|
||||
args += [('accountant_id', '=', self.env.user.id)]
|
||||
if self.env.user and self.env.user.id and self.env.user.has_group("odex_benefit.group_benefit_accountant_accept")\
|
||||
and self.env.user.has_group("odex_benefit.group_benefit_payment_accountant_accept") :
|
||||
args += []
|
||||
return super(ServiceRequest, self).search(args, offset, limit, order, count)
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
|
|
@ -645,6 +648,14 @@ class ServiceRequest(models.Model):
|
|||
'message': _(
|
||||
"You cannot request more than %s") % rec.max_hospitals_transportation_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
|
||||
if rec.requested_service_amount > rec.service_cat.max_debits_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_debits_amount}
|
||||
return res
|
||||
|
||||
@api.onchange('requested_quantity','benefit_type')
|
||||
def onchange_requested_quantity(self):
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ class ServicesSettings(models.Model):
|
|||
is_this_service_for_student = fields.Boolean(string='Is Service For Student?')
|
||||
service_type = fields.Selection([('rent', 'Rent'),('home_restoration', 'Home Restoration'),('alternative_housing', 'Alternative Housing'),('home_maintenance','Home Maintenance')
|
||||
,('complete_building_house','Complete Building House'),('electrical_devices','Electrical Devices'),('home_furnishing','Home furnishing')
|
||||
,('electricity_bill','Electricity bill'),('water_bill','Water bill'),('buy_car','Buy Car'),('recruiting_driver','Recruiting Driver'),('transportation_insurance','Transportation Insurance')]
|
||||
,('electricity_bill','Electricity bill'),('water_bill','Water bill'),('buy_car','Buy Car'),('recruiting_driver','Recruiting Driver')
|
||||
,('transportation_insurance','Transportation Insurance'),('debits','Debits')]
|
||||
,string='Service Type')
|
||||
max_amount_for_student = fields.Float(string='Max Amount for Student')
|
||||
raise_amount_for_orphan = fields.Float(string='Raise Amount For Orphan')
|
||||
|
|
@ -50,6 +51,8 @@ class ServicesSettings(models.Model):
|
|||
max_universities_training_institutes_transportation_amount = fields.Float(string='Max Universities Training Institutes Transportation Amount')
|
||||
max_hospitals_transportation_amount = fields.Float(string='Max Hospitals Transportation Amount')
|
||||
max_programs_transportation_amount = fields.Float(string='Max Programs Transportation Amount')
|
||||
#Debits
|
||||
max_debits_amount = fields.Float(string='Max Debits Amount')
|
||||
|
||||
class RentLines(models.Model):
|
||||
_name = 'rent.lines'
|
||||
|
|
|
|||
|
|
@ -63,7 +63,12 @@
|
|||
<!-- <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>-->
|
||||
</record>
|
||||
<record id="group_benefit_accountant_accept" model="res.groups">
|
||||
<field name="name">Accountant Accept</field>
|
||||
<field name="name">Service Request Accountant Accept</field>
|
||||
<field name="category_id" ref="odex25_account_payment_fix.module_category_payment_access"/>
|
||||
<!-- <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>-->
|
||||
</record>
|
||||
<record id="group_benefit_payment_accountant_accept" model="res.groups">
|
||||
<field name="name">Payment Orders Accountant Accept</field>
|
||||
<field name="category_id" ref="odex25_account_payment_fix.module_category_payment_access"/>
|
||||
<!-- <field name="implied_ids" eval="[(4, ref('group_benefit_info'))]"/>-->
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -149,6 +149,12 @@
|
|||
<field name="max_programs_transportation_amount"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Transportation Insurance Settings" attrs="{'invisible':[('service_type','!=','debits')]}">
|
||||
<group>
|
||||
<field name="benefit_category_ids" widget="many2many_tags"/>
|
||||
<field name="max_debits_amount"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class ServiceRequestInherit(models.Model):
|
|||
)
|
||||
rec.project_id = project
|
||||
|
||||
@api.onchange('requested_service_amount', 'benefit_type', 'date', 'service_cat','family_id','device_id','exception_or_steal','home_furnishing_exception')
|
||||
@api.onchange('requested_service_amount', 'benefit_type', 'date', 'service_cat','family_id','device_id','exception_or_steal','home_furnishing_exception','rent_period')
|
||||
def onchange_requested_service_amount(self):
|
||||
res = {}
|
||||
today = fields.Date.today()
|
||||
|
|
@ -147,19 +147,22 @@ class ServiceRequestInherit(models.Model):
|
|||
existing_requests_within_three_years = self.search(domain)
|
||||
|
||||
# Include current record in the calculation
|
||||
total_amount_in_three_years = sum(existing_requests_within_three_years.mapped('requested_service_amount'))
|
||||
total_amount_in_three_years = sum(
|
||||
existing_requests_within_three_years.mapped('requested_service_amount'))
|
||||
total_amount_in_three_years += self.requested_service_amount or 0
|
||||
if not rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount}
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount}
|
||||
return res
|
||||
if rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount_if_exception:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount_if_exception}
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount_if_exception}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'electricity_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electricity_bill':
|
||||
|
|
@ -267,4 +270,12 @@ class ServiceRequestInherit(models.Model):
|
|||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.max_hospitals_transportation_amount}
|
||||
return res
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
|
||||
if rec.requested_service_amount > rec.service_cat.max_debits_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_debits_amount}
|
||||
return res
|
||||
Loading…
Reference in New Issue