Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] [17.0] school_transport : Migrated into 17.0 #290

Open
wants to merge 3 commits into
base: 17.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions school_transport/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

{
"name": "Transport Management for Education ERP",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Serpent Consulting Services Pvt. Ltd.",
"website": "http://www.serpentcs.com",
"license": "AGPL-3",
"category": "School Management",
"complexity": "easy",
"summary": "A Module For Transport & Vehicle Management In School",
"depends": ["school", "fleet"],
"images": ["static/description/SchoolTransport.png"],
"depends": ["school", "fleet", "school_hostel"],
"images": ["static/description/Banner_school_transport_17.png"],
"data": [
"security/transport_security.xml",
"security/ir.model.access.csv",
Expand Down
85 changes: 43 additions & 42 deletions school_transport/models/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ class FleetVehicle(models.Model):
@api.depends("vehi_participants_ids")
def _compute_participants(self):
"""Method to get number participant."""
for rec in self:
rec.participant_count = len(
rec.vehi_participants_ids.filtered(
lambda r: r.vehicle_id.id == rec.id and r.state != "over"
for vehicle in self:
vehicle.participant_count = len(
vehicle.vehi_participants_ids.filtered(
lambda participant: participant.vehicle_id.id == vehicle.id
and participant.state != "over"
)
)

Expand Down Expand Up @@ -73,12 +74,11 @@ def _search(
student_obj = self.env["student.transport"]
student_rec = student_obj.browse(self._context.get("name"))
args += [("id", "in", student_rec.sudo().trans_vehicle_ids.ids)]
return super(FleetVehicle, self)._search(
return super()._search(
args,
offset=offset,
limit=limit,
order=order,
count=count,
access_rights_uid=access_rights_uid,
)

Expand All @@ -97,8 +97,8 @@ def check_licence_number(self):
if driver_rec:
raise ValidationError(
_(
""" The licence number you have entered already exist.
Please enter different licence number!"""
"The licence number you have entered already exist."
"Please enter different licence number!"
)
)

Expand Down Expand Up @@ -155,7 +155,6 @@ def _search(
offset=0,
limit=None,
order=None,
count=False,
access_rights_uid=None,
):
"""Inherited method to get domain from student transportation"""
Expand All @@ -173,11 +172,10 @@ def _search(
],
)
)
return super(TransportParticipant, self)._search(
return super()._search(
args,
offset=offset,
limit=limit,
count=count,
access_rights_uid=access_rights_uid,
)

Expand All @@ -190,7 +188,7 @@ def unlink(self):
for rec in self:
if rec.state == "running":
raise ValidationError(_("You cannot delete record in running state!."))
return super(TransportParticipant, self).unlink()
return super().unlink()


class StudentTransports(models.Model):
Expand Down Expand Up @@ -276,7 +274,8 @@ def check_dates(self):
if rec.start_date < new_dt or rec.end_date < new_dt:
raise ValidationError(
_(
"Start date or End date should be greater than or equal to the current date!"
"Start date or End date should be"
" greater than or equal to the current date!"
)
)

Expand All @@ -292,7 +291,7 @@ def unlink(self):
raise ValidationError(
_("You can delete record in draft state or cancel state only!")
)
return super(StudentTransports, self).unlink()
return super().unlink()


class StudentStudent(models.Model):
Expand Down Expand Up @@ -322,7 +321,7 @@ def set_alumni(self):
trans_regi_rec.state = "cancel"
if trans_student_rec:
trans_student_rec.active = False
return super(StudentStudent, self).set_alumni()
return super().set_alumni()


class TransportRegistration(models.Model):
Expand Down Expand Up @@ -433,7 +432,7 @@ def onchange_name(self):
@api.model
def create(self, vals):
"""Inherited create method to call onchange methods"""
ret_val = super(TransportRegistration, self).create(vals)
ret_val = super().create(vals)
if ret_val:
ret_val.onchange_registration_month()
return ret_val
Expand All @@ -448,7 +447,7 @@ def unlink(self):
"state only!"
)
)
return super(TransportRegistration, self).unlink()
return super().unlink()

def transport_fees_pay(self):
"""Method to generate invoice of participant."""
Expand Down Expand Up @@ -614,33 +613,35 @@ def action_create_payments(self):
"""
Override method to write paid amount in hostel student
"""
res = super(AccountPaymentRegister, self).action_create_payments()
res = super().action_create_payments()
invoice = False
for rec in self:
if self._context.get("active_model") == "account.move":
if self._context.get("active_model") == "account.move.line":
invoice = self.env["account.move"].browse(
self._context.get("active_ids", [])
)
vals = {}
if invoice.transport_student_id and invoice.payment_state == "paid":
fees_payment = invoice.transport_student_id.paid_amount + rec.amount
vals.update(
{
"state": "paid",
"paid_amount": fees_payment,
"remain_amt": 0.0,
"tax_amount": invoice.amount_tax,
}
self._context.get("active_id", [])
)
elif invoice.transport_student_id and invoice.payment_state == "not_paid":
fees_payment = invoice.transport_student_id.paid_amount + rec.amount
vals.update(
{
"state": "pending",
"paid_amount": fees_payment,
"tax_amount": invoice.amount_tax,
"remain_amt": invoice.amount_residual,
}
)
invoice.transport_student_id.write(vals)
vals = {}
if invoice.transport_student_id and invoice.payment_state == "paid":
fees_payment = invoice.transport_student_id.paid_amount + rec.amount
vals.update(
{
"state": "paid",
"paid_amount": fees_payment,
"remain_amt": 0.0,
"tax_amount": invoice.amount_tax,
}
)
elif (
invoice.transport_student_id and invoice.payment_state == "not_paid"
):
fees_payment = invoice.transport_student_id.paid_amount + rec.amount
vals.update(
{
"state": "pending",
"paid_amount": fees_payment,
"tax_amount": invoice.amount_tax,
"remain_amt": invoice.amount_residual,
}
)
invoice.transport_student_id.write(vals)
return res
55 changes: 26 additions & 29 deletions school_transport/report/report_view.xml
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>

<record id="paperformat_margin" model="report.paperformat">
<field name="name">Report margin</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">50</field>
<field name="margin_bottom">30</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>
<field name="header_line" eval="False" />
<field name="header_spacing">45</field>
<field name="dpi">80</field>
</record>
<record id="paperformat_margin" model="report.paperformat">
<field name="name">Report margin</field>
<field name="default" eval="True" />
<field name="format">A4</field>
<field name="page_height">0</field>
<field name="page_width">0</field>
<field name="orientation">Portrait</field>
<field name="margin_top">50</field>
<field name="margin_bottom">30</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>
<field name="header_line" eval="False" />
<field name="header_spacing">45</field>
<field name="dpi">80</field>
</record>

<record id="report_student_transport_qweb" model="ir.actions.report">
<field name="name">Transport Root Detail</field>
<field name="model">student.transport</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">school_transport.participants</field>
<field name="report_file">school_transport.participants</field>
<field
name="binding_model_id"
ref="school_transport.model_student_transport"
/>
<field name="paperformat_id" ref="school_transport.paperformat_margin" />
<field name="binding_type">report</field>
<field
<record id="report_student_transport_qweb" model="ir.actions.report">
<field name="name">Transport Root Detail</field>
<field name="model">student.transport</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">school_transport.participants</field>
<field name="report_file">school_transport.participants</field>
<field name="binding_model_id" ref="school_transport.model_student_transport" />
<field name="paperformat_id" ref="school_transport.paperformat_margin" />
<field name="binding_type">report</field>
<field
name="groups_id"
eval="[(4, ref('school_transport.group_transportation_manager'))]"
/>
</record>
</record>

</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified school_transport/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion school_transport/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<section class="oe_container">
<div class='oe_row oe_cover'>
<a href="http://www.serpentcs.com" target="new"><img src="serpent_logo.png" align="right"></a>
</div>
</div>
</section>

<section class="oe_container" style="background:#DCDCDC">
Expand Down
Loading