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] library: migrated into 17.0 #283

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
9 changes: 7 additions & 2 deletions library/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
"name": "Library Management for Education ERP",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"author": "Serpent Consulting Services Pvt. Ltd.",
"category": "School Management",
"website": "http://www.serpentcs.com",
Expand All @@ -22,8 +22,13 @@
"views/library_view.xml",
"wizard/terminate_reason.xml",
],
"assets": {
"web.assets_backend": [
"library/static/src/css/library.css",
]
},
"demo": ["demo/library_demo.xml"],
"image": ["static/description/SchoolLibrary.png"],
"image": ["static/description/Banner_library_17.png"],
"installable": True,
"application": True,
}
6 changes: 3 additions & 3 deletions library/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ def action_create_payments(self):
"""
Override method to write paid amount in for library fine
"""
res = super(AccountPaymentRegister, self).action_create_payments()
res = super().action_create_payments()
invoice = False
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", [])
self._context.get("active_id", [])
)
if invoice.book_issue_id and invoice.payment_state == "paid":
invoice.book_issue_id.penalty = 0.00
Expand Down
32 changes: 21 additions & 11 deletions library/models/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ def create(self, vals):
"""Inherited this method to assign student values at record creation"""
if vals.get("student_id"):
self._update_student_info(vals)
return super(LibraryCard, self).create(vals)
return super().create(vals)

def write(self, vals):
"""Inherited this method to update student values at record updation"""
if vals.get("student_id"):
self._update_student_info(vals)
return super(LibraryCard, self).write(vals)
return super().write(vals)

@api.constrains("student_id", "teacher_id")
def check_member_card(self):
Expand Down Expand Up @@ -209,7 +209,7 @@ def unlink(self):
for rec in self:
if rec.state == "running":
raise UserError(_("""You cannot delete a confirmed library card!"""))
return super(LibraryCard, self).unlink()
return super().unlink()

def librarycard_expire(self):
"""Schedular to change in librarycard state when end date is over"""
Expand Down Expand Up @@ -278,6 +278,7 @@ def _compute_check_ebook(self):
default=lambda self: _("New"),
help="Enter Issue No.",
)
book_request_id = fields.Many2one("library.book.request", "Request ID")
student_id = fields.Many2one(
"student.student", "Student Name", help="Enter student"
)
Expand Down Expand Up @@ -420,8 +421,8 @@ def check_book_issue(self):
):
raise UserError(
_(
"""You cannot issue same book on same card more than once "
"at same time!"""
"You cannot issue same book on same card more than once "
"at same time!"
)
)

Expand Down Expand Up @@ -461,15 +462,15 @@ def create(self, vals):
self._update_student_vals(vals)
if vals.get("card_id") and vals.get("user") == "Teacher":
self._update_teacher_vals(vals)
return super(LibraryBookIssue, self).create(vals)
return super().create(vals)

def write(self, vals):
"""Override write method"""
if vals.get("card_id") and vals.get("user") != "Teacher":
self._update_student_vals(vals)
if vals.get("card_id") and vals.get("user") == "Teacher":
self._update_teacher_vals(vals)
return super(LibraryBookIssue, self).write(vals)
return super().write(vals)

def draft_book(self):
"""This method for books in draft state."""
Expand Down Expand Up @@ -576,6 +577,7 @@ def lost_book(self):

def cancel_book(self):
"""This method used for cancel book issue."""
self.book_request_id.write({"state": "cancel"})
self.state = "cancel"

def user_fine(self):
Expand Down Expand Up @@ -780,6 +782,7 @@ def _compute_bname(self):
default=True,
help="Set active to false to hide the category without removing it.",
)
book_issue_id = fields.Many2one("library.book.issue", "Book Issue")

@api.constrains("card_id", "name")
def check_book_request(self):
Expand Down Expand Up @@ -811,7 +814,7 @@ def create(self, vals):
"""Inherited method to generate sequence at record creation"""
seq_obj = self.env["ir.sequence"]
vals.update({"req_id": (seq_obj.next_by_code("library.book.request") or "New")})
return super(LibraryBookRequest, self).create(vals)
return super().create(vals)

def draft_book_request(self):
"""Method to change state as draft"""
Expand All @@ -829,7 +832,13 @@ def confirm_book_request(self):
):
raise UserError(_("The Membership of library card is over!"))
if self.type == "existing":
vals.update({"card_id": self.card_id.id, "name": self.name.id})
vals.update(
{
"card_id": self.card_id.id,
"book_request_id": self.id,
"name": self.name.id,
}
)
elif self.type == "ebook" and self.ebook_name:
vals.update(
{
Expand Down Expand Up @@ -859,6 +868,7 @@ def confirm_book_request(self):
else:
issue_id.write({"state": "draft"})
self.state = "confirm"
self.book_issue_id = issue_id.id
# changes state to confirm
if issue_id:
issue_id.onchange_card_issue()
Expand All @@ -881,7 +891,7 @@ def unlink(self):
" request!"
)
)
return super(LibraryBookRequest, self).unlink()
return super().unlink()

def cancle_book_request(self):
"""Method to change state as cancel"""
Expand All @@ -899,4 +909,4 @@ def set_alumni(self):
student_card_rec = lib_card_obj.search([("student_id", "=", rec.id)])
if student_card_rec:
student_card_rec.active = False
return super(StudentLibrary, self).set_alumni()
return super().set_alumni()
4 changes: 2 additions & 2 deletions library/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ProductProduct(models.Model):
@api.model
def default_get(self, fields):
"""Overide method to get default category books"""
res = super(ProductProduct, self).default_get(fields)
res = super().default_get(fields)
category = self.env["product.category"].search(
[("name", "=", "Books")], limit=1
)
Expand Down Expand Up @@ -113,7 +113,7 @@ def create(self, vals):
vals["seller_ids"] = [supplier]
else:
vals["seller_ids"].append(supplier)
return super(ProductProduct, self).create(vals)
return super().create(vals)

@api.depends("qty_available")
def _compute_books_available(self):
Expand Down
Binary file added library/static/description/Banner_library_17.png
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 library/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.
Binary file added library/static/description/icon_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions library/static/src/css/library.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.o_kanban_project_tasks .oe_kanban_align.badge,
.o_project_kanban .oe_kanban_align.badge {
background: inherit;
color: inherit;
border: 1px solid var(--success);
}
Loading