Browse Source

added full code

pull/3/merge
niyas 10 years ago
parent
commit
1cf7280f70
  1. 57
      library_management/.gitignore
  2. 4
      library_management/__init__.py
  3. 30
      library_management/__openerp__.py
  4. 14
      library_management/demo.xml
  5. 772
      library_management/library.py
  6. 244
      library_management/registration.py
  7. 14
      library_management/report.xml
  8. 1
      library_management/report/__init__.py
  9. 34
      library_management/report/report_invoice_parser.py
  10. 73
      library_management/res_config.py
  11. 53
      library_management/res_config_view.xml
  12. 29
      library_management/security/ir.model.access.csv
  13. 2
      library_management/security/library.account.config.csv
  14. 2
      library_management/security/library.fine.per.day.conf.csv
  15. 2
      library_management/security/library.store.conf.csv
  16. BIN
      library_management/static/description/icon.png
  17. BIN
      library_management/static/src/img/book1.png
  18. 722
      library_management/view/library.xml
  19. 130
      library_management/view/registration.xml
  20. 70
      library_management/view/report_invoice.xml
  21. 49
      library_management/view/user_view.xml

57
library_management/.gitignore

@ -0,0 +1,57 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/

4
library_management/__init__.py

@ -0,0 +1,4 @@
import library
import registration
import report
import res_config

30
library_management/__openerp__.py

@ -0,0 +1,30 @@
{
'name': 'Public Library Management ',
'version': '1.0',
'author' : 'Cybrosys',
'category': 'Tools',
'summary': 'book management',
'description': """
Public Library Management
================================
Module to manage library.
Books Information,
Publisher and Author Information,
Book Rack Tracking etc...
""",
'depends' : ['base', 'sale', 'report_intrastat', 'stock', 'mail', 'account', 'account_accountant'],
'data' : [
'view/registration.xml',
'view/library.xml',
'view/user_view.xml',
'res_config_view.xml',
'view/report_invoice.xml',
'report.xml',
'security/ir.model.access.csv',
'demo.xml',
],
'images': [],
'demo': [],
'installable' : True,
'application': True,
}

14
library_management/demo.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="first_course_item" model="library.book.returnday">
<field name="day">10</field>
<field name="fine_amt">5</field>
</record>
<!--<record id="demo_data_validity" model="library.validity">-->
<!--<field name="year">2</field>-->
<!--<field name="month">1</field>-->
<!--<field name="day">8</field>-->
<!--</record>-->
</data>
</openerp>

772
library_management/library.py

@ -0,0 +1,772 @@
from openerp import models, fields, tools, api
from openerp.tools.translate import _
from datetime import datetime, timedelta, date
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT, image_colorize, image_resize_image_big
import openerp
from openerp.exceptions import Warning
class library_rack(models.Model):
_name = 'library.rack'
code = fields.Char(string='Code', size=64, required=True, readonly=True,
help="it will be show the position of book")
name = fields.Char(string='Name', size=16)
active = fields.Boolean('Active', default=True)
book_ids = fields.One2many('product.product', compute='compute_book')
_sql_constraints = [('code.unique', 'unique(code)', 'The code of the rack must be unique !!'),
('name_uniq', 'unique (name)', 'The name of rack already exists !!')]
_defaults = {'code': lambda self, cr, uid, context: 'rack'}
def create(self, cr, uid, values, context=None):
if values.get('code', _('rack')) == _('rack'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.rack')
return super(library_rack, self).create(cr, uid, values, context=context)
def compute_book(self):
book_obj = self.pool.get('product.product')
browse = self.browse(self._ids)
student_ids = book_obj.search(self._cr, self._uid, [('rack', '=', browse.name)])
self.book_ids = student_ids
class product_lang(models.Model):
_name = 'product.lang'
code = fields.Char('Code', size=4, required=True, readonly=True)
name = fields.Char('Name', size=128, required=True)
book_ids = fields.One2many('product.product', compute='compute_book')
_sql_constraints = [('name_uniq', 'unique (name)', 'The name of the language must be unique !'),
('code_uniq', 'unique (code)', 'The code of the lang must be unique !')]
_defaults = {
'code': lambda self, cr, uid, context: 'language'
}
def create(self, cr, uid, values, context=None):
if values.get('code', _('language')) == _('language'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'product.lang')
return super(product_lang, self).create(cr, uid, values, context=context)
def compute_book(self):
book_obj = self.pool.get('product.product')
browse = self.browse(self._ids)
student_ids = book_obj.search(self._cr, self._uid, [('lang', '=', browse.name)])
self.book_ids = student_ids
class library_book_returnday(models.Model):
_name = 'library.book.returnday'
_rec_name = 'day'
day = fields.Integer('Days', default=1, required=True, help="It show the no of day/s for returning book")
code = fields.Char('Code', readonly=True, size=16)
fine_amt = fields.Float('Fine Amount', default=1, required=True,
help="Fine amount to be paid after due of book return date")
_sql_constraints = [('name_uniq', 'unique (code)', 'The code of the return days must be unique !')]
_defaults = {'code': lambda self, cr, uid, context: 'day'}
def create(self, cr, uid, values, context=None):
if values.get('code', _('day')) == _('day'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.book.returnday')
return super(library_book_returnday, self).create(cr, uid, values, context=context)
class library_price_category(models.Model):
_name = 'library.price.category'
_description = 'Book Category'
name = fields.Char('Category', size=64, required=True)
code = fields.Char('Code', readonly=True)
book_ids = fields.One2many('product.product', compute='compute_book')
_sql_constraints = [('name_uniq', 'unique (code)', 'The code of the category must be unique !')]
_defaults = {'code': lambda self, cr, uid, context: 'category'}
def create(self, cr, uid, values, context=None):
if values.get('code', _('category')) == _('category'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.price.cat')
return super(library_price_category, self).create(cr, uid, values, context=context)
def compute_book(self):
book_obj = self.pool.get('product.product')
browse = self.browse(self._ids)
student_ids = book_obj.search(self._cr, self._uid, [('book_cat', '=', browse.name)])
self.book_ids = student_ids
class stock_change_quantity(models.Model):
_inherit = "stock.change.product.qty"
def change_product_qty(self, cr, uid, ids, context=None):
conf = self.pool.get('ir.values')
store_conf = conf.get_default(cr, uid, 'library.config.settings', 'store')
ware_brow = self.pool.get('stock.warehouse').browse(cr, uid, store_conf, context=context)
if store_conf == False or store_conf == None:
raise Warning(_("Warning"), _("Set a store to library from Library settings"))
get_conf_store = ware_brow.code
if context is None:
context = {}
inventory_obj = self.pool.get('stock.inventory')
inventory_line_obj = self.pool.get('stock.inventory.line')
po_id = context.get('active_id')
prod_obj = self.pool.get('product.product')
prod = prod_obj.browse(cr, uid, po_id, context=context)
for data in self.browse(cr, uid, ids, context=context):
get_trans_loc = data.location_id.location_id.name
if get_conf_store == get_trans_loc:
prod_obj.write(cr, uid, po_id, {'total_copies': data.new_quantity,
'available_copies': data.new_quantity})
if data.new_quantity < 0:
raise Warning(_("Warning"), _("Quantity cannot be negative."))
ctx = context.copy()
ctx['location'] = data.location_id.id
ctx['lot_id'] = data.lot_id.id
if data.product_id.id and data.lot_id.id:
filter = 'none'
elif data.product_id.id:
filter = 'product'
else:
filter = 'none'
inventory_id = inventory_obj.create(cr, uid, {
'name': _('INV: %s') % tools.ustr(data.product_id.name),
'filter': filter,
'product_id': data.product_id.id,
'location_id': data.location_id.id,
'lot_id': data.lot_id.id}, context=context)
product = data.product_id.with_context(location=data.location_id.id, lot_id=data.lot_id.id)
th_qty = product.qty_available
line_data = {
'inventory_id': inventory_id,
'product_qty': data.new_quantity,
'location_id': data.location_id.id,
'product_id': data.product_id.id,
'product_uom_id': data.product_id.uom_id.id,
'theoretical_qty': th_qty,
'prod_lot_id': data.lot_id.id
}
inventory_line_obj.create(cr, uid, line_data, context=context)
inventory_obj.action_done(cr, uid, [inventory_id], context=context)
return {}
class library_book_issue(models.Model):
_name = 'library.book.issue'
_description = "Library information"
name = fields.Many2one('product.product', 'Book Name', required=True)
issue_code = fields.Char('Issue No.', size=24, required=True, readonly=True, copy=False)
user = fields.Many2one('res.partner', 'User Name')
invoice_id = fields.Many2one('account.invoice', "User's Invoice")
date_issue = fields.Datetime('Release Date', readonly=True, default=datetime.now(),
help="Release(Issue) date of the book")
date_return = fields.Datetime(string='Return Date', readonly=True,
help="Book To Be Return On This Date", copy=False)
actual_return_date = fields.Datetime("Actual Return Date", readonly=True, help="Actual Return Date of Book")
penalty = fields.Float(string='Penalty For Late Book Return',
help='It show the late book return penalty', readonly=True)
lost_penalty = fields.Float(string='Fine', help='It show the penalty for lost book')
day_to_return_book = fields.Many2one("library.book.returnday", "Book Return Days", copy=False)
card_id = fields.Many2one("library.card", "Card No", required=True)
state = fields.Selection([('draft', 'Draft'), ('issue', 'Issued'), ('transfered', 'Transfered'),
('reissue', 'Reissued'), ('cancel', 'Cancelled'), ('lost', 'Lost'),
('return', 'Returned'), ('paid', 'Paid')], "State")
color = fields.Integer("Color Index")
_defaults = {
'state': 'draft',
'issue_code': lambda self, cr, uid, context: 'issue'
}
def create(self, cr, uid, values, context=None):
if values.get('issue_code', _('issue')) == _('issue'):
values['issue_code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.book.issue')
return super(library_book_issue, self).create(cr, uid, values, context=context)
@api.multi
def invoice_print(self):
return self.env['report'].get_action(self, 'library_management.report_invoice_library')
def _library_reminder(self, cr, uid, context=None):
tommarrow = datetime.now() + timedelta(days=1)
issue_obj = self.pool.get('library.book.issue')
late_ids = issue_obj.search(cr, uid, [('state', '=', 'transfered')])
for i in late_ids:
a = issue_obj.browse(cr, uid, i, context)
date_return = datetime.strptime(a.date_return, DEFAULT_SERVER_DATETIME_FORMAT)
if tommarrow.date() == date_return.date():
post_vars = {'subject': "Library- Reminder",
'body': "Hello " + str(a.user.name) + ", Your book(" + str(a.name.name) +
") return date is tommarrow" + "(" + str(date_return.date()) + ")" +
". Please try to return the book as soon as possible. Else You need to pay the fine.",
'model': 'library.book.issue',
'partner_ids': [a.user.id]}
thread_pool = self.pool.get('mail.thread')
thread_pool.message_post(cr, uid, False, type="comment", subtype="mt_comment",
context=context, **post_vars)
def transfer_book(self, cr, uid, ids, context=None):
for order in self.browse(cr, uid, ids):
conf = self.pool.get('ir.values')
store_conf = conf.get_default(cr, uid, 'library.config.settings', 'store')
ware_brow = self.pool.get('stock.warehouse').browse(cr, uid, store_conf, context=context)
if store_conf == False or store_conf == None:
raise Warning(_("Warning"), _("Set a store to library from Library settings"))
product_rec = self.pool.get('product.product').browse(cr, uid, order.name.id, context=context)
book = product_rec.name
uom_id = product_rec.uom_id
searc = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', '=', book)])
whstocks = self.pool.get('stock.location').search(cr, uid, [('location_id.name', '=', ware_brow.code),
('name', '=', 'Stock')], context=context)
whstock = whstocks[0]
whsto = self.pool.get('stock.location').browse(cr, uid, whstock, context=None)
search_picks = self.pool.get('stock.picking.type'). \
search(cr, uid, [('warehouse_id.name', '=', ware_brow.name)], context=context)
search_pick = search_picks[2]
picking_vals = {
'picking_type_id': search_pick,
'partner_id': order.user.id,
'date': date.today(),
'origin': order.issue_code,
}
picking_id = self.pool.get('stock.picking').create(cr, uid, picking_vals, context=context)
vals = {
'name': order.id or '',
'product_id': searc[0],
'product_uom': uom_id.id,
'date': date.today(),
'location_id': whsto.id,
'location_dest_id': order.user.property_stock_customer.id,
'picking_id': picking_id,
}
move_id = self.pool.get('stock.move').create(cr, uid, vals, context=context)
self.pool.get('stock.move').force_assign(cr, uid, [move_id], context=context)
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'context': context,
'type': 'ir.actions.act_window',
'res_id': picking_id
}
def issue_book(self, cr, uid, ids, context=None):
product_obj = self.pool.get('product.product')
for issue in self.browse(cr, uid, ids, context=context):
card_ids = self.search(cr, uid, [('card_id', '=', issue.card_id.id),
('state', 'in', ['issue', 'reissue', 'transfered'])])
if issue.card_id.book_limit > len(card_ids) and issue.name.available_copies > 0:
self.write(cr, uid, ids, {'state': 'issue', 'date_issue': datetime.now()}, context=context)
elif issue.card_id.book_limit <= len(card_ids) and issue.name.available_copies > 0:
raise Warning(_("Warning"), _("Exceeded maximum book limit..."))
elif issue.card_id.book_limit > len(card_ids) and issue.name.available_copies <= 0:
raise Warning(_("Warning"), _("Sorry, Currently book not available"))
elif issue.card_id.book_limit <= len(card_ids) and issue.name.available_copies <= 0:
raise Warning(_("Warning"), _("Sorry, Currently book not available and Exceeded maximum book limit..."))
else:
pass
return True
def user_fine(self, cr, uid, ids, context=None):
conf = self.pool.get('ir.values')
account_conf = conf.get_default(cr, uid, 'library.config.settings', 'account_id')
if account_conf == False or account_conf == None:
raise Warning(_("Warning"), _("Set an account for library from Library settings"))
lib_account = account_conf
for i in self.browse(cr, uid, ids):
state = i.state
book = i.name.id
issue_code = i.issue_code
invoice_obj = self.pool.get('account.invoice')
obj_data = self.pool.get('ir.model.data')
pen = 0.0
fine_per_day = 0.0
lost_pen = 0.0
for record in self.browse(cr, uid, ids):
a = record.date_return
a = datetime.strptime(a, DEFAULT_SERVER_DATETIME_FORMAT)
usr = record.user.id
addr = record.user.contact_address
user_account = record.user.property_account_receivable.id
vals_invoice = {
'partner_id': usr,
'address_invoice_id': addr,
'date_invoice': date.today().strftime('%Y-%m-%d'),
'account_id': user_account,
}
invoice_lines = []
if state == 'lost':
lost_pen = record.lost_penalty
invoice_line2 = {
'name': issue_code,
'price_unit': lost_pen,
'product_id': book,
'account_id': lib_account
}
invoice_lines.append((0, 0, invoice_line2))
if state != 'lost':
b = record.actual_return_date
b = datetime.strptime(b, DEFAULT_SERVER_DATETIME_FORMAT)
dif = b.date() - a.date()
day = dif.days
conf = self.pool.get('ir.values')
store_conf = conf.get_default(cr, uid, 'library.config.settings', 'fine_per_day')
fine_amount = store_conf
if fine_amount < 0.0:
raise Warning(_("Warning"),
_("Fine per day must be positive.Set a fine amount from Library settings"))
fine_per_day += fine_amount * day
invoicee_obj = self.pool.get('account.invoice.line')
invoicee_search = invoicee_obj.search(cr, uid, [])
for i in invoicee_obj.browse(cr, uid, invoicee_search, context=context):
if i.name == issue_code:
raise Warning(_("Warning"), _("Cannot create two invoice line with same issue code."))
if a < b:
pen = record.penalty + fine_per_day
invoice_line1 = {
'name': issue_code,
'price_unit': pen,
'product_id': book,
'account_id': lib_account
}
else:
invoice_line1 = {
'name': issue_code,
'price_unit': 0.00,
'product_id': book,
'account_id': lib_account
}
invoice_lines.append((0, 0, invoice_line1))
vals_invoice.update({'invoice_line': invoice_lines})
new_invoice_id = invoice_obj.create(cr, uid, vals_invoice)
data_id = obj_data._get_id(cr, uid, 'account', 'invoice_form')
data = obj_data.browse(cr, uid, data_id, context=context)
view_id = data.res_id
return {
'name': _("New Invoice"),
'view_mode': 'form',
'view_id': [view_id],
'view_type': 'form',
'res_model': 'account.invoice',
'type': 'ir.actions.act_window',
'nodestroy': True,
'res_id': new_invoice_id,
'target': 'current',
'context': {}
}
def reissue_book(self, cr, uid, ids, context=None):
new = self.pool.get('library.book.issue').browse(cr, uid, ids, context=context)
day_to_return_book = new.day_to_return_book.id
return_days = self.pool.get('library.book.returnday')
browse = return_days.browse(cr, uid, day_to_return_book, context)
for item in browse:
day = item.day
ret_date = datetime.now() + timedelta(days=day)
self.write(cr, uid, ids, {'state': 'reissue'}, context=context)
self.write(cr, uid, ids, {'date_issue': datetime.now(), 'date_return': ret_date}, context=context)
return True
def lost_book(self, cr, uid, ids, context=None):
product_obj = self.pool.get('product.product')
for issue in self.browse(cr, uid, ids, context=context):
avail = issue.name.available_copies
total = issue.name.total_copies - 1
product_obj.write(cr, uid, issue.name.id, {'total_copies': total}, context=context)
product_obj.write(cr, uid, issue.name.id, {'available_copies': avail}, context=context)
self.write(cr, uid, ids, {'state': 'lost'}, context=context)
return True
def return_book(self, cr, uid, ids, context=None):
for order in self.browse(cr, uid, ids):
product_rec = self.pool.get('product.product').browse(cr, uid, order.name.id, context=context)
book = product_rec.name
searc = self.pool.get('product.product').search(cr, uid, [('product_tmpl_id', '=', book)])
conf = self.pool.get('ir.values')
store_conf = conf.get_default(cr, uid, 'library.config.settings', 'store')
ware_brow = self.pool.get('stock.warehouse').browse(cr, uid, store_conf, context=context)
if store_conf == False:
raise Warning(_("Warning"), _("Set a store to library from Library settings"))
whstocks = self.pool.get('stock.location'). \
search(cr, uid, [('location_id.name', '=', ware_brow.code), ('name', '=', 'Stock')], context=context)
whstock = whstocks[0]
whsto = self.pool.get('stock.location').browse(cr, uid, whstock, context=None)
search_picks = self.pool.get('stock.picking.type'). \
search(cr, uid, [('warehouse_id.name', '=', ware_brow.name)], context=context)
search_pick = search_picks[0]
picking_vals = {
'picking_type_id': search_pick,
'partner_id': order.user.id,
'date': date.today(),
'origin': order.issue_code,
}
picking_id = self.pool.get('stock.picking').create(cr, uid, picking_vals, context=context)
vals = {
'name': order.id or '',
'product_id': searc[0],
'product_uom': product_rec.uom_id.id,
'date': date.today(),
'location_id': order.user.property_stock_customer.id,
'location_dest_id': whsto.id,
'picking_id': picking_id,
}
move_id = self.pool.get('stock.move').create(cr, uid, vals, context=context)
self.pool.get('stock.move').force_assign(cr, uid, [move_id], context=context)
return {
'view_type': 'form',
'view_mode': 'form',
'res_model': 'stock.picking',
'context': context,
'type': 'ir.actions.act_window',
'res_id': picking_id
}
def cancel_book(self, cr, uid, ids, context=None):
product_obj = self.pool.get('product.product')
for issue in self.browse(cr, uid, ids, context=context):
avail = issue.name.available_copies + 1
product_obj.write(cr, uid, issue.name.id, {'availability': 'available', 'available_copies': avail}, context)
self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
return True
def draft_book(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'draft'}, context=context)
return True
def onchange_card_id(self, cr, uid, ids, card_id, context=None):
if card_id:
card_detail = self.pool.get('library.card')
browse = card_detail.browse(cr, uid, card_id, context)
for item in browse:
user = item.username
return {'value': {'user': user}}
def on_change_book_name(self, cr, uid, ids, book_name, context=None):
if book_name:
fine = 0.0
for line in self.browse(cr, uid, book_name, context=context):
book = self.pool.get('product.product')
bb = book.browse(cr, uid, book_name, context)
fine = bb.lst_price
return {'value': {'lost_penalty': fine}}
def on_change_day_to_return(self, cr, uid, ids, day_to_return_book, context=None):
if day_to_return_book:
new = self.pool.get('library.book.issue').browse(cr, uid, ids, context=context)
datee = new.date_issue
date = datetime.strptime(str(datee), DEFAULT_SERVER_DATETIME_FORMAT)
return_days = self.pool.get('library.book.returnday')
browse = return_days.browse(cr, uid, day_to_return_book, context)
for item in browse:
day = item.day
penalty = item.fine_amt
ret_date = date + timedelta(days=day)
self.write(cr, uid, ids, {'date_return': ret_date, 'penalty': penalty}, context)
return {'value': {'date_return': ret_date, 'penalty': penalty}}
class card_details(models.Model):
_name = 'library.card'
name = fields.Char(string='Card No', size=64, required=True)
username = fields.Many2one('res.partner', "User Name", required=True)
have_valid_card = fields.Boolean('Have valid Card')
book_limit = fields.Integer("Book Limit", required=True)
account_ids = fields.One2many('library.book.issue', compute='compute_account')
_sql_constraints = [('name_uniq', 'unique (name)', 'The card name must be unique !')]
_defaults = {'name': lambda self, cr, uid, context: 'card',
'have_valid_card': False}
def copy(self, cr, uid, id, default=None, context=None):
raise Warning(_('Forbbiden to duplicate'),
_('It is not possible to duplicate the record, please create a new one.'))
def create(self, cr, uid, values, context=None):
if values.get('name', _('card')) == _('card'):
values['name'] = self.pool.get('ir.sequence').get(cr, uid, 'library.card')
return super(card_details, self).create(cr, uid, values, context=context)
def compute_account(self):
issue_obj = self.pool.get('library.book.issue')
browse = self.browse(self._ids)
student_ids = issue_obj.search(self._cr, self._uid, [('card_id', '=', browse.name)])
self.account_ids = student_ids
def onchange_username(self, cr, uid, ids, username, context=None):
if username:
card_obj = self.pool.get('library.card')
card_ids = card_obj.search(cr, uid, [('username', '=', username), ('have_valid_card', '=', True)])
if len(card_ids) > 0:
return {'value': {'username': " ", 'user': False, 'book_limit': 0},
'warning': {'title': 'Warning', 'message': 'Already the user have a card !'}}
reg_obj = self.pool.get('library.registration')
reg_user_draft = reg_obj.search(cr, uid, [('name', '=', username), ('state', '=', 'draft')])
length_draft = len(reg_user_draft)
if length_draft > 0:
return {'value': {'username': " ", 'user': False, 'book_limit': 0},
'warning': {'title': 'Warning',
'message': 'Already the user have a registration in draft state!'}}
reg_user_cancel = reg_obj.search(cr, uid, [('name', '=', username), ('state', '=', 'cancel')])
length_cancel = len(reg_user_cancel)
if length_cancel > 0:
return {'value': {'username': " ", 'user': False, 'book_limit': 0},
'warning': {'title': 'Warning',
'message': 'Already the user have a registration in cancel state!'}}
reg_user_reg = reg_obj.search(cr, uid, [('name', '=', username), ('state', '=', 'registered')])
length_reg = len(reg_user_reg)
if length_reg == 0:
return {'value': {'username': " ", 'user': False, 'book_limit': 0},
'warning': {'title': 'Warning',
'message': 'Card not allowed for users without valid registration!'}}
# def onchange_user(self, cr, uid, ids, user, context=None):
# if user:
# if user == 'student':
# booklimit = 3
# if user == 'teacher':
# booklimit = 5
# if user == 'others':
# booklimit = 2
# self.write(cr, uid, ids,{'book_limit': booklimit}, context)
# return {'value': {'book_limit': booklimit}}
class library_validity(models.Model):
_name = 'library.validity'
_rec_name = 'code'
code = fields.Char('Code', readonly=True, size=16)
name = fields.Char('Name', readonly=True, default="0 Years, 0 Months, 0 Days", compute='compute_validity')
year = fields.Integer('Year')
month = fields.Integer('Month')
day = fields.Integer('Day')
_defaults = {'code': lambda self, cr, uid, context: 'Validity'}
def create(self, cr, uid, values, context=None):
val_obj = self.search(cr, uid, [])
for rcd in val_obj:
val_details = self.browse(cr, uid, rcd, context)
if val_details.year == values['year'] and val_details.month == values['month'] and val_details.day == \
values['day']:
raise Warning(_("Warning"), _("The record with same validity period already exists."))
if values.get('code', _('Validity')) == _('Validity'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.validity')
return super(library_validity, self).create(cr, uid, values, context=context)
def write(self, cr, uid, ids, vals, context=None):
year = month = day = 0
if 'year' in vals:
year = vals['year']
if 'month' in vals:
month = vals['month']
if 'day' in vals:
day = vals['day']
if context is None:
context = {}
val_obj = self.search(cr, uid, [])
for rcd in val_obj:
val_details = self.browse(cr, uid, rcd, context)
if val_details.year == year and val_details.month == month and val_details.day == day:
raise Warning(_("Warning"), _("The record with same validity period already exists."))
return super(library_validity, self).write(cr, uid, ids, vals, context=context)
@api.depends('year', 'month', 'day')
def compute_validity(self):
year = self.year
month = self.month
day = self.day
validity = str(year) + " Years," + str(month) + " Months," + str(day) + " Days"
self.name = validity
class res_partner(models.Model):
_inherit = 'res.partner'
librarian = fields.Boolean('librarain')
_defaults = {'librarian': False,
}
class library_books(models.Model):
_inherit = 'product.product'
book = fields.Boolean('Book')
editor = fields.Many2one('res.partner', 'Editor', change_default=True)
author = fields.Many2one('library.author', 'Author', size=30)
publisher = fields.Many2one('library.publisher', 'Publisher', size=30)
total_copies = fields.Integer('Total Copies')
available_copies = fields.Integer('Available Copies')
book_cat = fields.Many2one('library.price.category', "Book Category")
availability = fields.Boolean('Available', default=True)
year_of_publication = fields.Integer('Year of Publication')
barcode = fields.Char('Barcode')
rack = fields.Many2one('library.rack', 'Rack', size=16, help="it will be show the position of book")
isbn = fields.Char('ISBN Code', size=64, unique=True, help="It show the International Standard Book Number")
lang = fields.Many2one('product.lang', 'Language')
date_parution = fields.Date('Release date', help="Release(Issue) date of the book")
creation_date = fields.Datetime('Creation date', readonly=True, help="Record creation date")
date_retour = fields.Date('Return Date', readonly=True, help='Book Return date')
nbpage = fields.Integer('Number of pages', size=8)
back = fields.Selection([('hard', 'Hardback'), ('paper', 'Paperback')], 'Reliure',
help="It show the books binding type")
pocket = fields.Char('Pocket', size=32)
num_pocket = fields.Char('Collection Num.', size=32, help="It show the collection number in which book is resides")
num_edition = fields.Integer('Num. edition', help="Edition number of book")
format = fields.Char('Format', help="The general physical appearance of a book")
history_ids = fields.One2many('library.book.issue', compute='compute_history')
_sql_constraints = [
('unique_ean13', 'unique(ean13)', 'The ean13 field must be unique across all the products'),
('code_uniq', 'unique (code)', 'The code of the product must be unique !')]
_defaults = {'availability': 'available',
}
def compute_history(self):
book_obj = self.pool.get('library.book.issue')
browse = self.browse(self._ids)
student_ids = book_obj.search(self._cr, self._uid, [('name', '=', browse.name)])
self.history_ids = student_ids
def _get_default_image(self, cr, uid, is_company, context=None, colorize=False):
image_medium = image_colorize(
open(openerp.modules.get_module_resource('library_management', 'static/src/img', 'book1.png')).read())
return image_resize_image_big(image_medium.encode('base64'))
def onchange_total(self, cr, uid, ids, total_copies, context=None):
prod_obj = self.pool.get('product.product')
for issue in self.browse(cr, uid, ids, context=context):
prod_obj.write(cr, uid, issue.id, {'available_copies': total_copies}, context)
return {'value': {'available_copies': total_copies}}
# def create(self, cr, uid, values, context=None):
# values['book'] = True
# return super(library_books, self).create(cr, uid, values, context=context)
class library_author(models.Model):
_name = 'library.author'
name = fields.Char('Name', size=30, required=True, select=True)
code = fields.Char('Code', readonly=True)
born_date = fields.Date('Date of Birth')
death_date = fields.Date('Date of Death')
biography = fields.Text('Biography')
note = fields.Text('Notes')
book_ids = fields.One2many('product.product', compute='compute_book')
_sql_constraints = [('name_uniq', 'unique (name)', 'The name of the author must be unique !'),
('code_uniq', 'unique (code)', 'The code of the collection must be unique !')]
_defaults = {'code': lambda self, cr, uid, context: 'author'}
def create(self, cr, uid, values, context=None):
if values.get('code', _('author')) == _('author'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.author')
return super(library_author, self).create(cr, uid, values, context=context)
def unlink(self, cr, uid, ids, context=None):
author_obj = self.browse(cr, uid, ids)
book_obj = self.pool.get('product.product')
search_obj = book_obj.search(cr, uid, [('book', '=', True)])
for author in author_obj:
for i in search_obj:
if book_obj.browse(cr, uid, i).author.name == author.name:
raise Warning(_("Warning"), _("Deletion unsuccessful."),
_("Author refered in some records in books."))
# Call the parent method to eliminate the records.
super(library_author, self).unlink(cr, uid, ids, context)
def compute_book(self):
book_obj = self.pool.get('product.product')
browse = self.browse(self._ids)
student_ids = book_obj.search(self._cr, self._uid, [('author', '=', browse.name)])
self.book_ids = student_ids
class library_publisher(models.Model):
_name = 'library.publisher'
name = fields.Char('Name', size=30, required=True)
code = fields.Char('Code', readonly=True)
_sql_constraints = [('code_uniq', 'unique (code)', 'The code of the publisher must be unique !')]
_defaults = {'code': lambda self, cr, uid, context: 'publisher'}
def create(self, cr, uid, values, context=None):
if values.get('code', _('publisher')) == _('publisher'):
values['code'] = self.pool.get('ir.sequence').get(cr, uid, 'library.publisher')
return super(library_publisher, self).create(cr, uid, values, context=context)
class tranfer_wizard(models.Model):
_inherit = 'stock.transfer_details'
@api.one
def do_detailed_transfer(self, context=None):
active_id = context.get('active_ids')
processed_ids = []
# Create new and update existing pack operations
for lstits in [self.item_ids, self.packop_ids]:
for prod in lstits:
pack_datas = {
'product_id': prod.product_id.id,
'product_uom_id': prod.product_uom_id.id,
'product_qty': prod.quantity,
'package_id': prod.package_id.id,
'lot_id': prod.lot_id.id,
'location_id': prod.sourceloc_id.id,
'location_dest_id': prod.destinationloc_id.id,
'result_package_id': prod.result_package_id.id,
'date': prod.date if prod.date else datetime.now(),
'owner_id': prod.owner_id.id,
}
if prod.packop_id:
prod.packop_id.with_context(no_recompute=True).write(pack_datas)
processed_ids.append(prod.packop_id.id)
else:
pack_datas['picking_id'] = self.picking_id.id
packop_id = self.env['stock.pack.operation'].create(pack_datas)
processed_ids.append(packop_id.id)
# Delete the others
packops = self.env['stock.pack.operation'].search(
['&', ('picking_id', '=', self.picking_id.id), '!', ('id', 'in', processed_ids)])
packops.unlink()
# Execute the transfer of the picking
self.picking_id.do_transfer()
issue_code_search = self.pool.get('stock.picking').browse(self._cr, self._uid, active_id)
for i in issue_code_search:
issue_code = i.origin
picking_type = i.picking_type_id.name
issue_obj = self.pool.get('library.book.issue')
issue_search = issue_obj.search(self._cr, self._uid, [('issue_code', '=', issue_code)])
issue_browse = issue_obj.browse(self._cr, self._uid, issue_search)
product_obj = self.pool.get('product.product')
if picking_type == 'Receipts':
for i in issue_browse:
issue_obj.write(self._cr, self._uid, issue_search,
{'state': 'return', 'actual_return_date': datetime.now()})
avail = i.name.available_copies + 1
product_obj.write(self._cr, self._uid, i.name.id,
{'availability': 'available', 'available_copies': avail}, context)
else:
for i in issue_browse:
issue_obj.write(self._cr, self._uid, issue_search, {'state': 'transfered'})
avail = i.name.available_copies - 1
product_obj.write(self._cr, self._uid, i.name.id, {'available_copies': avail}, context)
return True
class account_wizard(models.Model):
_inherit = 'account.voucher'
def button_proforma_voucher(self, cr, uid, ids, context=None):
active_id = context.get('active_ids')
self.pool.get('account.invoice').write(cr, uid, active_id, {'state': 'paid'})
account_obj = self.pool.get('account.invoice').browse(cr, uid, active_id)
for i in account_obj.invoice_line:
issue = i.name
issue_obj = self.pool.get('library.book.issue')
issue_search = issue_obj.search(cr, uid, [('issue_code', '=', issue)])
for i in issue_search:
issue_obj.write(cr, uid, i, {'state': 'paid'})
return {'type': 'ir.actions.act_window_close'}

244
library_management/registration.py

@ -0,0 +1,244 @@
from openerp import models, fields, api
import openerp
from datetime import datetime,time,date,timedelta
from openerp.tools.translate import _
from openerp.exceptions import Warning
from openerp.tools import image_colorize, image_resize_image_big
class library_registratin(models.Model):
_name = "library.registration"
_rec_name = 'name'
validity = fields.Many2one('library.validity', 'Validity')
from_id = fields.Date(string='Valid From')
to = fields.Date(string='Valid To', compute='compute_valid_to')
notes = fields.Text('Notes')
photo = fields.Binary('Photo')
name = fields.Many2one('res.partner', string='Member', size=64, required=True)
card_no = fields.Char(string='Card No', size=64, readonly=True, help='Unique Card No', copy=False)
registration_date = fields.Date('Registration Date')
phone = fields.Char('Phone', size=12)
mobile = fields.Char('Mobile', size=12)
state = fields.Selection([('draft', 'Draft'), ('registered', 'Registered'),('assigned_card', 'Card Assigned'), ('cancel', 'Cancel')])
user = fields.Char("Position")
book_limit = fields.Integer("Book Limit", required=True)
_sql_constraints = [('card_no.unique', 'unique(card_no)', 'already existing request id. try another ID')]
_defaults = {
'card_no': lambda obj, cr, uid, context: 'Registration no',
'state': 'draft',
'photo': lambda self, cr, uid, ctx: self._get_default_image(cr, uid, ctx.get('default_is_company', False), ctx),
}
@api.depends('from_id', 'validity')
def compute_valid_to(self):
if self.validity:
days = 0
if self.validity.year:
days += self.validity.year*365
if self.validity.month:
days += self.validity.month*30
if self.validity.day:
days += self.validity.day
from_id = datetime.strptime(str(self.from_id), '%Y-%m-%d')
to = from_id + timedelta(days=days)
self.to = to
def unlink(self, cr, uid, ids, context=None):
reg_obj = self.browse(cr, uid, ids)
issue_obj = self.pool.get('library.book.issue')
search_obj = issue_obj.search(cr, uid, [])
for reg in reg_obj:
for i in search_obj:
if issue_obj.browse(cr, uid, i).user == reg.name:
raise Warning(_("Warning"), _("Deletion unsuccessful."),
_("User have some book issues. Delete those records first!!"))
super(library_registratin, self).unlink(cr, uid, ids, context)
def create(self, cr, uid, values, context=None):
if values.get('card_no', _('Registration no')) == _('Registration no'):
values['card_no'] = self.pool.get('ir.sequence').get(cr, uid, 'reg.no')
return super(library_registratin, self).create(cr, uid, values, context=context)
def _registered_user_manager(self, cr, uid, context=None):
today = date.today()
reg_obj = self.pool.get('library.registration')
late_ids = reg_obj.search(cr, uid, [('to', '<', today)])
for i in late_ids:
reg_obj.write(cr, uid, i, {'state': 'cancel'})
def _get_default_image(self, cr, uid, is_company, context=None, colorize=False):
image = image_colorize(open(openerp.modules.get_module_resource('base', 'static/src/img', 'avatar.png')).read())
return image_resize_image_big(image.encode('base64'))
def getdata(self, cr, uid, ids, name, context=None):
reg_obj = self.pool.get('library.registration')
reg_user_registered = reg_obj.search(cr, uid, [('name', '=', name), ('state', '=', 'registered')])
length_registered = len(reg_user_registered)
reg_user_assigned_card = reg_obj.search(cr, uid, [('name', '=', name), ('state', '=', 'assigned_card')])
length_assigned_card = len(reg_user_assigned_card)
reg_user_cancel = reg_obj.search(cr, uid, [('name', '=', name), ('state', '=', 'cancel')])
length_cancel = len(reg_user_cancel)
reg_user_draft = reg_obj.search(cr, uid, [('name', '=', name), ('state', '=', 'draft')])
length_draft = len(reg_user_draft)
if length_draft == 1:
return {'value': {'name': " "}, 'warning': {'title': 'Warning',
'message': 'User already have a record for registration in draft state'}}
if length_cancel == 1:
return {'value': {'name': " "}, 'warning': {'title': 'Warning',
'message': 'User already have a record for registration in cancel state'}}
if length_assigned_card == 1 or length_registered == 1:
return {'value': {'name': " "}, 'warning': {'title': 'Warning',
'message': 'User already have a record for registration'}}
obj = self.pool.get('res.partner')
rec = obj.browse(cr, uid, name, context=None)
for i in rec:
return {'value': {'mobile': i.mobile, 'phone': i.phone}}
def register(self, cr, uid, ids, context=None):
# flag = 0
pool_reg = self.pool.get('library.registration')
pool_partner = self.pool.get('res.partner')
lib_rec = pool_reg.browse(cr, uid, ids, context=None)
child_name = lib_rec.name.id
res_part_browse1 = pool_partner.browse(cr, uid, [child_name], context=None)
if res_part_browse1.librarian == True:
raise Warning(_("Warning"), _("Already registered..."))
else:
reg_date = date.today()
a = timedelta(days=365)
b = reg_date + a
self.write(cr, uid, ids, {'registration_date': reg_date, 'state': 'registered',
'from_id': reg_date, 'to': b}, context=context)
res_part_browse1.write({'librarian': True })
def create_card(self, cr, uid, ids, context=None):
card_obj = self.pool.get('library.card')
for i in self.browse(cr, uid, ids):
username = i.name
card_ids = card_obj.search(cr, uid, [('id', '=', i.id), ('have_valid_card', '=', True)])
if len(card_ids) > 0:
raise Warning(_("Warning"), _("Already the user have a card !"))
vals = {
'username': username.id,
'book_limit': i.book_limit
}
new_card_id = card_obj.create(cr, uid, vals)
self.write(cr, uid, ids, {'state': 'assigned_card'}, context=context)
obj_data = self.pool.get('ir.model.data')
data_id = obj_data._get_id(cr, uid, 'library_management', 'product_card_form_view')
data = obj_data.browse(cr, uid, data_id, context=context)
view_id = data.res_id
card_rec = card_obj.browse(cr, uid, new_card_id, context=context)
card_obj.write(cr, uid, card_rec.id, {'have_valid_card': True}, context=context)
return {
'name': _("New card"),
'view_mode': 'form',
'view_id': [view_id],
'view_type': 'form',
'res_model': 'library.card',
'type': 'ir.actions.act_window',
'nodestroy': True,
'res_id': new_card_id,
'target': 'current',
'context': {}
}
def cancel(self, cr, uid, ids, context=None):
user_issue = self.browse(cr,uid,ids).name.id
pool_partner = self.pool.get('res.partner')
res_part_browse1 = pool_partner.browse(cr, uid, user_issue, context=None)
res_part_browse1.write({'librarian': False })
card_obj = self.pool.get('library.card')
card_search = card_obj.search(cr, uid, [('username', '=', user_issue)])
for i in card_search:
card_rec = card_obj.browse(cr, uid, i)
card_obj.write(cr, uid, card_rec.id, {'have_valid_card': False}, context=context)
# self.unlink(cr, uid, ids, context=context)
self.write(cr, uid, ids, {'state': 'cancel'}, context=context)
return True
# pool_issue = self.pool.get('library.book.issue')
# pool_card = self.pool.get('library.card')
# issues = pool_issue.search(cr, uid, [('user', '=', user_issue)])
# for items in issues:
# book = pool_issue.browse(cr, uid, items).issue_code
# if pool_issue.browse(cr, uid, items).state =='transfered':
# raise Warning(_("Warning"), _("Please return book before cancelling registration"),
# _("Issue no:"), book)
# if pool_issue.browse(cr, uid, items).state =='return':
# raise Warning(_("Warning"), _("Please pay fine of the returned book before cancelling registration"),
# _("Issue no:"), book)
# if pool_issue.browse(cr, uid, items).state =='lost':
# raise Warning(_("Warning"), _("Please pay fine of the losted book before cancelling registration"),
# _("Issue no:"), book)
# if pool_issue.browse(cr, uid, items).state =='reissue':
# raise Warning(_("Warning"), _("Please return the book before cancelling registration"),
# _("Issue no:"), book)
# cr.execute('DELETE FROM library_book_issue WHERE id = %s', ([items]))
# card = pool_card.search(cr, uid, [('username', '=', user_issue)])
# for i in card:
# cr.execute('DELETE FROM library_card WHERE id = %s', ([i]))
def draft(self, cr, uid, ids, context=None):
self.write(cr, uid, ids, {'state': 'draft'}, context=context)
return True
def renew(self, cr, uid, ids, context=None):
reg_date = date.today()
a = timedelta(days=365)
b = reg_date + a
self.write(cr, uid, ids, {'registration_date': reg_date, 'state': 'assigned_card',
'from_id': reg_date, 'to': b}, context=context)
class user_user(models.Model):
_name = "res.partner"
_inherit = 'res.partner'
position = fields.Selection([('student', 'Student'), ('teacher', 'Teacher'), ('other', 'Other')],
'Position', required=True)
reader = fields.Boolean('Reader', help="Check this box if this contact is a reader.", default=True)
_defaults = {
'image': lambda self, cr, uid, ctx: self._get_default_image(cr, uid, ctx.get('default_is_company', False), ctx)
}
def _get_default_image(self, cr, uid, is_company, context=None, colorize=False):
image = image_colorize(open(openerp.modules.get_module_resource('base', 'static/src/img', 'avatar.png')).read())
return image_resize_image_big(image.encode('base64'))
class Wizard(models.TransientModel):
_name = 'book.report'
book = fields.Many2one('product.product', "Book")
rack = fields.Many2one("library.rack", 'Rack')
author = fields.Many2one("library.author", 'Author')
language = fields.Many2one('product.lang', 'Language')
catag = fields.Many2one('library.price.category', "Book category")
def confirmfilter(self, cr, uid, ids, context=None):
i = self.browse(cr, uid, ids, context=None)
book_name = i.book.name
rack = i.rack.name
author_name = i.author.name
lang = i.language.name
catag = i.catag.name
dom = [('book', '=', True)]
if book_name != False:
dom = [('name', '=', book_name)]
if rack != False:
dom.append(('rack', '=', rack))
if author_name != False:
dom.append(('author', '=', author_name))
if lang != False:
dom.append(('lang', '=', lang))
if catag != False:
dom.append(('book_cat', '=', catag))
return {
'type': 'ir.actions.act_window',
'name': 'FILTERED BOOKS',
'view_type': 'tree',
'view_mode': 'tree',
'res_model': 'product.product',
'target': 'current',
'domain': dom
}

14
library_management/report.xml

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="action_report_invoice_library"
string="Invoice"
model="library.book.issue"
report_type="qweb-pdf"
name="library_management.report_invoice_library"
file="library_management.report_invoice_library"
menu="False"
/>
</data>
</openerp>

1
library_management/report/__init__.py

@ -0,0 +1 @@
import report_invoice_parser

34
library_management/report/report_invoice_parser.py

@ -0,0 +1,34 @@
from openerp import models
from openerp.report import report_sxw
from datetime import date
class report_lib(report_sxw.rml_parse):
_name = 'report.library_management.report_invoice_library'
def __init__(self, cr, uid, name, context=None):
if context is None:
context = {}
super(report_lib, self).__init__(cr, uid, name, context = context)
self.localcontext.update({
'timee':self._timee,
'get_data': self._get_data,
})
def _timee(self,data):
date_now=date.today().strftime('%Y-%m-%d')
return date_now
def _get_data(self,issue_code):
acc_obj=self.pool.get('account.invoice.line')
search = acc_obj.search(self.cr,self.uid,[('name', '=', issue_code)])
var = acc_obj.browse(self.cr, self.uid, search)
descri = var.name
product = var.product_id
quant = var.quantity
price = var.price_unit
subtotal = var.price_subtotal
return {'descri': descri, 'product': product.name,'quant': quant,'price': price,'subtotal': subtotal}
class report_lib_invoice(models.AbstractModel):
_name = 'report.library_management.report_invoice_library'
_inherit = 'report.abstract_report'
_template = 'library_management.report_invoice_library'
_wrapped_report_class = report_lib

73
library_management/res_config.py

@ -0,0 +1,73 @@
# -*- coding: utf-8 -*-
from openerp import SUPERUSER_ID
from openerp.tools.translate import _
from openerp.osv import fields, osv
class PropertyConfigSettings(osv.TransientModel):
_name = 'library.config.settings'
_inherit = 'res.config.settings'
def _default_company(self, cr, uid, context=None):
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
return user.company_id.id
_columns = {
'store': fields.many2one('stock.warehouse', _('Library Store'), help=_('Account used for Library Configuration')),
'account_id': fields.many2one('account.account', _('Library Account'),
domain="[('type', '=', 'receivable')]",
help=_('Account used for Library Configuration')),
'fine_per_day': fields.float(_('Fine per day')),
}
def get_default_store(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
store = ir_values.get_default(cr, uid, 'library.config.settings', 'store')
return {
'store': store,
}
def set_store(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
wizard = self.browse(cr, uid, ids)[0]
if wizard.store:
store = wizard.store
ir_values.set_default(cr, SUPERUSER_ID, 'library.config.settings', 'store', store.id)
else:
store = False
ir_values.set_default(cr, SUPERUSER_ID, 'library.config.settings', 'store', store)
def get_default_account_id(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
account_id = ir_values.get_default(cr, uid, 'library.config.settings', 'account_id')
return {
'store': account_id,
}
def set_account_id(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
wizard = self.browse(cr, uid, ids)[0]
if wizard.account_id:
account_id = wizard.account_id
ir_values.set_default(cr, SUPERUSER_ID, 'library.config.settings', 'account_id', account_id.id)
else:
account_id = False
ir_values.set_default(cr, SUPERUSER_ID, 'library.config.settings', 'account_id', account_id)
def get_default_fine_per_day(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
fine_per_day = ir_values.get_default(cr, uid, 'library.config.settings', 'fine_per_day')
return {
'store': fine_per_day,
}
def set_fine_per_day(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
wizard = self.browse(cr, uid, ids)[0]
if wizard.fine_per_day:
fine_per_day = wizard.fine_per_day
ir_values.set_default(cr, SUPERUSER_ID, 'library.config.settings', 'fine_per_day', fine_per_day)
else:
fine_per_day = 0.0
ir_values.set_default(cr, SUPERUSER_ID, 'library.config.settings', 'store',fine_per_day)

53
library_management/res_config_view.xml

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="view_property_config_settings" model="ir.ui.view">
<field name="name">Library settings</field>
<field name="model">library.config.settings</field>
<field name="arch" type="xml">
<form string="Configure Library" class="oe_form_configuration">
<header>
<button string="Apply" type="object" name="execute" class="oe_highlight"/>
or
<button string="Cancel" type="object" name="cancel" class="oe_link"/>
</header>
<separator string="Library Configuration"/>
<group>
<label for="id" string="Store" />
<div>
<div>
<label for="store" />
<field name="store" class="oe_inline"/>
</div>
</div>
<label for="id" string="Account" />
<div>
<div>
<label for="account_id" />
<field name="account_id" class="oe_inline"/>
</div>
</div>
<label for="id" string="Fine Amount" />
<div>
<div>
<label for="fine_per_day" />
<field name="fine_per_day" class="oe_inline"/>
</div>
</div>
</group>
</form>
</field>
</record>
<record id="action_library_settings" model="ir.actions.act_window">
<field name="name">Configure library</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">library.config.settings</field>
<field name="view_mode">form</field>
<field name="target">inline</field>
</record>
<menuitem id="menu_library_settings" name="Library" parent="base.menu_config"
sequence="15" action="action_library_settings"/>
</data>
</openerp>

29
library_management/security/ir.model.access.csv

@ -0,0 +1,29 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_library_registration,access_library_registration,model_library_registration,Administrator_group,1,1,1,1
access_library_card,access_library_card,model_library_card,Administrator_group,1,1,1,1
access_library_author,access_library_author,model_library_author,Administrator_group,1,1,1,1
access_library_publisher,access_library_publisher,model_library_publisher,Administrator_group,1,1,1,1
access_product_product,access_product_product,model_product_product,Administrator_group,1,1,1,1
access_res_partnerr,access_res_partnerr,model_res_partner,Administrator_group,1,1,1,1
access_stock_change_product_qty,access_stock_change_product_qty,model_stock_change_product_qty,Administrator_group,1,1,1,1
access_library_rack,access_library_rack,model_library_rack,Administrator_group,1,1,1,1
access_product_lang,access_product_lang,model_product_lang,Administrator_group,1,1,1,1
access_library_book_returnday,access_library_book_returnday,model_library_book_returnday,Administrator_group,1,1,1,1
access_library_price_category,access_library_price_category,model_library_price_category,Administrator_group,1,1,1,1
access_library_book_issue,access_library_book_issue,model_library_book_issue,Administrator_group,1,1,1,1
access_library_registration1,access_library_registration1,model_library_registration,librarian_group,1,1,1,1
access_book_report1,access_book_report1,model_book_report,librarian_group,1,1,1,1
access_library_card1,access_library_card1,model_library_card,librarian_group,1,1,1,1
access_library_rack1,access_library_rack1,model_library_rack,librarian_group,1,1,1,1
access_product_lang1,access_product_lang1,model_product_lang,librarian_group,1,1,1,1
access_library_book_returnday1,access_library_book_returnday1,model_library_book_returnday,librarian_group,1,1,1,1
access_library_price_category1,access_library_price_category1,model_library_price_category,librarian_group,1,1,1,1
access_library_book_issue1,access_library_book_issue1,model_library_book_issue,librarian_group,1,1,1,1
access_library_author1,access_library_author1,model_library_author,librarian_group,1,1,1,1
access_library_publisher1,access_library_publisher1,model_library_publisher,librarian_group,1,1,1,1
access_product_product1,access_product_product1,model_product_product,librarian_group,1,1,1,1
access_res_partnerr1,access_res_partnerr1,model_res_partner,librarian_group,1,1,1,1
access_stock_change_product_qty1,access_stock_change_product_qty1,model_stock_change_product_qty,librarian_group,1,1,1,1
access_stock_transfer_details,access_stock_transfer_details,model_stock_transfer_details,,1,1,1,1
access_library_validity,access_library_validity,model_library_validity,Administrator_group,1,1,0,0
1 id name model_id/id group_id/id perm_read perm_write perm_create perm_unlink
2 access_library_registration access_library_registration model_library_registration Administrator_group 1 1 1 1
3 access_library_card access_library_card model_library_card Administrator_group 1 1 1 1
4 access_library_author access_library_author model_library_author Administrator_group 1 1 1 1
5 access_library_publisher access_library_publisher model_library_publisher Administrator_group 1 1 1 1
6 access_product_product access_product_product model_product_product Administrator_group 1 1 1 1
7 access_res_partnerr access_res_partnerr model_res_partner Administrator_group 1 1 1 1
8 access_stock_change_product_qty access_stock_change_product_qty model_stock_change_product_qty Administrator_group 1 1 1 1
9 access_library_rack access_library_rack model_library_rack Administrator_group 1 1 1 1
10 access_product_lang access_product_lang model_product_lang Administrator_group 1 1 1 1
11 access_library_book_returnday access_library_book_returnday model_library_book_returnday Administrator_group 1 1 1 1
12 access_library_price_category access_library_price_category model_library_price_category Administrator_group 1 1 1 1
13 access_library_book_issue access_library_book_issue model_library_book_issue Administrator_group 1 1 1 1
14 access_library_registration1 access_library_registration1 model_library_registration librarian_group 1 1 1 1
15 access_book_report1 access_book_report1 model_book_report librarian_group 1 1 1 1
16 access_library_card1 access_library_card1 model_library_card librarian_group 1 1 1 1
17 access_library_rack1 access_library_rack1 model_library_rack librarian_group 1 1 1 1
18 access_product_lang1 access_product_lang1 model_product_lang librarian_group 1 1 1 1
19 access_library_book_returnday1 access_library_book_returnday1 model_library_book_returnday librarian_group 1 1 1 1
20 access_library_price_category1 access_library_price_category1 model_library_price_category librarian_group 1 1 1 1
21 access_library_book_issue1 access_library_book_issue1 model_library_book_issue librarian_group 1 1 1 1
22 access_library_author1 access_library_author1 model_library_author librarian_group 1 1 1 1
23 access_library_publisher1 access_library_publisher1 model_library_publisher librarian_group 1 1 1 1
24 access_product_product1 access_product_product1 model_product_product librarian_group 1 1 1 1
25 access_res_partnerr1 access_res_partnerr1 model_res_partner librarian_group 1 1 1 1
26 access_stock_change_product_qty1 access_stock_change_product_qty1 model_stock_change_product_qty librarian_group 1 1 1 1
27 access_stock_transfer_details access_stock_transfer_details model_stock_transfer_details 1 1 1 1
28 access_library_validity access_library_validity model_library_validity Administrator_group 1 1 0 0

2
library_management/security/library.account.config.csv

@ -0,0 +1,2 @@
"id"
library_account_config_1
1 id
2 library_account_config_1

2
library_management/security/library.fine.per.day.conf.csv

@ -0,0 +1,2 @@
"id"
library_fine_per_day_conf_1
1 id
2 library_fine_per_day_conf_1

2
library_management/security/library.store.conf.csv

@ -0,0 +1,2 @@
"id"
library_store_conf_1
1 id
2 library_store_conf_1

BIN
library_management/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
library_management/static/src/img/book1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

722
library_management/view/library.xml

@ -0,0 +1,722 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<menuitem name="Library Management" id="menu_root" sequence="1" groups="library_management.Administrator_group,library_management.librarian_group"/>
<menuitem name="OPAC" id="menu_opac" parent="menu_root" sequence="3"/>
<menuitem name="Library" id="menu_generral" parent="menu_root" sequence="2"/>
<menuitem name="Configuration" parent="menu_root" id="menu_configuration" sequence="10" groups="library_management.Administrator_group" />
<record id="seq_book_rack_type" model="ir.sequence.type">
<field name="name">Rack</field>
<field name="code">library.rack</field>
</record>
<record id="seq_book_rack" model="ir.sequence">
<field name="name">Rack</field>
<field name="code">library.rack</field>
<field name="prefix">RACK</field>
<field name="padding">3</field>
</record>
<!-- Library Rack Form View -->
<record model="ir.ui.view" id="rack_form">
<field name="name">library.rack.form</field>
<field name="model">library.rack</field>
<field name="arch" type="xml">
<form string="Rack" version="7.0">
<sheet>
<group>
<field name="code" style="width:40%%"/>
<field name="name"/>
<field name="active"/>
</group>
<notebook>
<page string="General Information">
<separator string="Books" colspan="4"/>
<field name="book_ids" nolabel="1" colspan="4">
<tree string="Book Information">
<!--<field name="book_id"/>-->
<field name="name"/>
<field name="author"/>
<field name="list_price"/>
</tree>
</field>
</page></notebook>
</sheet>
</form>
</field>
</record>
<!-- Library Rack Tree View -->
<record model="ir.ui.view" id="rack_tree">
<field name="name">library.rack.tree</field>
<field name="model">library.rack</field>
<field name="arch" type="xml">
<tree string="Authors">
<field name="name"/>
<field name="code"/>
<field name="active"/>
</tree>
</field>
</record>
<!-- Library Rack Search View -->
<record model="ir.ui.view" id="rack_search">
<field name="name">library.rack.search</field>
<field name="model">library.rack</field>
<field name="arch" type="xml">
<search string="Authors">
<field name="name"/>
<field name="code"/>
<field name="active"/>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_library_rack">
<field name="name">Library Rack</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">library.rack</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record id="seq_book_lang_type" model="ir.sequence.type">
<field name="name">Language</field>
<field name="code">product.lang</field>
</record>
<record id="seq_book_lang" model="ir.sequence">
<field name="name">Language</field>
<field name="code">product.lang</field>
<field name="prefix">L</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_lang">
<field name="name">Languages</field>
<field name="res_model">product.lang</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="product_lang_tree_view">
<field name="name">product.lang.tree</field>
<field name="model">product.lang</field>
<field name="arch" type="xml">
<tree string="Product Languages">
<field name="code"/>
<field name="name"/>
</tree>
</field>
</record>
<!--Product Language form view -->
<record model="ir.ui.view" id="product_lang_form_view">
<field name="name">product.lang.form</field>
<field name="model">product.lang</field>
<field name="arch" type="xml">
<form string="Product Languages">
<sheet>
<separator string="Languages"/>
<group col="4" colspan="2">
<field name="code" placeholder="Language Code"/>
<field name="name" placeholder="Language Name"/>
</group>
<notebook>
<page string="General Information">
<separator string="Books" colspan="4"/>
<field name="book_ids" nolabel="1" colspan="4">
<tree string="Book Information">
<!--<field name="book_id"/>-->
<field name="name"/>
<field name="author"/>
<field name="list_price"/>
</tree>
</field>
</page></notebook>
</sheet>
</form>
</field>
</record>
<record id="seq_book_returnday_type" model="ir.sequence.type">
<field name="name">returnday</field>
<field name="code">library.book.returnday</field>
</record>
<record id="seq_book_returnday" model="ir.sequence">
<field name="name">returnday</field>
<field name="code">library.book.returnday</field>
<field name="prefix">D</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_lang_book_day">
<field name="name">Book Return Days</field>
<field name="res_model">library.book.returnday</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="product_book_return_search_view">
<field name="name">library.book.returnday.search</field>
<field name="model">library.book.returnday</field>
<field name="arch" type="xml">
<search string="Book Return day">
<field name="code"/>
<field name="day"/>
<field name="fine_amt"/>
</search>
</field>
</record>
<record model="ir.ui.view" id="product_book_return_tree_view">
<field name="name">library.book.returnday.tree</field>
<field name="model">library.book.returnday</field>
<field name="arch" type="xml">
<tree string="Book Return day">
<field name="code"/>
<field name="day" />
<field name="fine_amt"/>
</tree>
</field>
</record>
<!-- Book return day form view -->
<record model="ir.ui.view" id="product_book_return_form_view">
<field name="name">library.book.returnday.form</field>
<field name="model">library.book.returnday</field>
<field name="arch" type="xml">
<form string="Book Return day" version="7.0">
<sheet>
<separator string="Book Return Days"/>
<group colspan="2" col="4">
<field name="code" placeholder="Books Code"/>
<field name="day" placeholder="Return Day/s"/>
<field name="fine_amt"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="seq_book_authors_type" model="ir.sequence.type">
<field name="name">authors</field>
<field name="code">library.author</field>
</record>
<record id="seq_book_authors" model="ir.sequence">
<field name="name">Book category</field>
<field name="code">library.author</field>
<field name="prefix">A</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_author_list">
<field name="name">Authors</field>
<field name="res_model">library.author</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="author_form">
<field name="name">library.author.form</field>
<field name="model">library.author</field>
<field name="arch" type="xml">
<form string="Authors" version="7.0" >
<sheet>
<separator string="Author"/>
<group>
<group>
<field name="name" placeholder="Author Name"/>
<field name="code"/>
</group>
<group>
<field name="born_date" placeholder="DOB"/>
<field name="death_date" placeholder="Death date"/>
</group>
</group>
<notebook>
<page string="General Information">
<separator string="Books" colspan="4"/>
<field name="book_ids" nolabel="1" colspan="4">
<tree string="Book Information">
<field name="name"/>
<field name="lang"/>
<field name="list_price"/>
</tree>
</field>
</page>
<page string="More Information">
<separator string="Notes" colspan="4"/>
<field name="note" nolabel="1" colspan="4"/>
<separator string="Biography" colspan="4"/>
<field name="biography" nolabel="1" colspan="4"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<record id="seq_book_cat_type" model="ir.sequence.type">
<field name="name">Book category</field>
<field name="code">library.price.cat</field>
</record>
<record id="seq_book_cat" model="ir.sequence">
<field name="name">Book category</field>
<field name="code">library.price.cat</field>
<field name="prefix">CAT</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_price_category">
<field name="name">Price Category</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">library.price.category</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="library_price_category_tree">
<field name="name">library.price.category</field>
<field name="model">library.price.category</field>
<field name="arch" type="xml">
<tree string="Price Categories">
<field name="name"/>
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="library_price_category_form">
<field name="name">library.price.category</field>
<field name="model">library.price.category</field>
<field name="arch" type="xml">
<form string="Price Category" version="7.0">
<sheet>
<group>
<field name="name" select="1" placeholder="Category Name" style="width:40%%"/>
<field name="code" />
</group>
<notebook>
<page string="General Information">
<separator string="Books" colspan="4"/>
<field name="book_ids" nolabel="1" colspan="4">
<tree string="Book Information">
<!--<field name="book_id"/>-->
<field name="name"/>
<field name="author"/>
<field name="list_price"/>
</tree>
</field>
</page></notebook>
</sheet>
</form>
</field>
</record>
<record id="seq_book_publisher_type" model="ir.sequence.type">
<field name="name">publisher</field>
<field name="code">library.publisher</field>
</record>
<record id="seq_book_publisher" model="ir.sequence">
<field name="name">publisher</field>
<field name="code">library.publisher</field>
<field name="prefix">P</field>
<field name="padding">3</field>
</record>
<record id="seq_books_type" model="ir.sequence.type">
<field name="name">Books</field>
<field name="code">library.books</field>
</record>
<record id="seq_books" model="ir.sequence">
<field name="name">Books</field>
<field name="code">library.books</field>
<field name="prefix">B</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_product_book_list">
<field name="name">Books</field>
<field name="res_model">product.product</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('book','=',True)]</field>
<field name="context">{'search_default_book':1, 'default_book': True}</field>
</record>
<!--Book Issue Search View -->
<record model="ir.ui.view" id="view_book_search_1">
<field name="name">library.book.issue.search.1</field>
<field name="model">library.book.issue</field>
<field name="arch" type="xml">
<search string="Book issue Information">
<group col="10" colspan="4">
<field name="user" />
</group>
<newline/>
<group expand="0" string="Group By..." colspan="12" col="10">
<filter icon="terp-project" string="Card No" help="By Card no" context="{'group_by':'card_id'}"/>
<filter icon="terp-project" string="Book" help="By book" context="{'group_by':'name'}"/>
<filter icon="terp-project" string="User" help="By user" context="{'group_by':'user'}"/>
</group>
</search>
</field>
</record>
<record model="ir.actions.act_window" id="action_book_issues">
<field name="name">Book Issues</field>
<field name="res_model">library.book.issue</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="search_view_id" ref="view_book_search_1"/>
</record>
<record model="ir.ui.view" id="view_library_book_tree">
<field name="name">library.book.issue.tree</field>
<field name="model">library.book.issue</field>
<field name="arch" type="xml">
<tree string="Books Issue" >
<field name="issue_code"/>
<field name="name"/>
<field name="user"/>
<field name="date_issue"/>
<field name="date_return"/>
<field name="state"/>
<field name="actual_return_date"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="view_book_library_form_1">
<field name="name">library.book.issue.form</field>
<field name="model">library.book.issue</field>
<field name="arch" type="xml">
<form string="Student Information">
<header>
<button name="invoice_print" string="Print Invoice" type="object" states="paid"/>
<button name="return_book" string="Book Return" type="object" icon="terp-gtk-jump-to-rtl" states="transfered,reissue"/>
<button name="issue_book" string="Book Issue" type="object" icon="terp-gtk-jump-to-ltr" states="draft" />
<button name="transfer_book" string="Transfer" type="object" icon="terp-gtk-jump-to-ltr" states="issue"/>
<button name="reissue_book" string="Book Reissue" type="object" icon="terp-gtk-jump-to-ltr" states="transfered"/>
<button name="cancel_book" string="Cancel Issue" type="object" icon="gtk-cancel" states="issue" />
<button name="draft_book" string="Draft" type="object" icon="terp-document-new" states="cancel" />
<button name="lost_book" string="Book Lost" type="object" icon="terp-gdu-smart-failing" states="transfered,reissue" />
<button name="user_fine" string="Fine" type="object" icon="terp-dolar_ok!" states="return,lost" />
<field name="state" widget="statusbar" align="right" readonly="1"/>
</header>
<sheet style="width: 10%%,height:10%%">
<div class="oe_title oe_left">
<h2>
<field name="issue_code" attrs="{'invisible':[('state','=','draft')]}"/>
</h2>
</div>
<group>
<group>
<field name="name" domain="[('book','=',True)]" on_change="on_change_book_name(name)" widget="selection" attrs="{'readonly':[('state','not in','draft')]}"/>
</group>
<group>
<field name="card_id" domain="[('have_valid_card','=',True)]" on_change="onchange_card_id(card_id)" widget="selection" attrs="{'readonly':[('state','not in','draft')]}"/>
<field name="user" widget="selection" attrs="{'invisible':[('state','=','draft')],'readonly':[('state','not in','draft')]}"/>
</group>
</group>
<group col="4" colspan="4" attrs="{'invisible':[('state','=','draft')]}">
<separator string="Issue Date" colspan="4" col="4" />
<field name="day_to_return_book" widget="selection" on_change="on_change_day_to_return(day_to_return_book)" attrs="{'required':[('state','=','issue')],'readonly':[('state','not in',['issue','reissue'])]}"/>
<field name="date_issue" />
<field name="date_return" />
<field name="actual_return_date" />
<field name="penalty" attrs="{'invisible':[('date_return','&gt;=','actual_return_date')]}"/>
<field name="lost_penalty" attrs="{'invisible':[('state','not in','lost')]}"/>
</group>
</sheet>
</form>
</field>
</record>
<record id="seq_type_lib_card_no" model="ir.sequence.type">
<field name="name">Library Card No</field>
<field name="code">library.card</field>
</record>
<record id="seq_lib_card_no" model="ir.sequence">
<field name="name">Library Card No</field>
<field name="code">library.card</field>
<field name="prefix">C</field>
<field name="number_next">1</field>
<field name="padding">3</field>
</record>
<record id="seq_book_issue_type" model="ir.sequence.type">
<field name="name">Book issues</field>
<field name="code">library.book.issue</field>
</record>
<record id="seq_book_issue" model="ir.sequence">
<field name="name">Book issues</field>
<field name="code">library.book.issue</field>
<field name="prefix">ISSUE</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_library">
<field name="name">Card Details</field>
<field name="res_model">library.card</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('have_valid_card','=','True')]</field>
</record>
<record model="ir.ui.view" id="product_card_tree_view">
<field name="name">library.card.tree</field>
<field name="model">library.card</field>
<field name="arch" type="xml">
<tree string="Card Details">
<field name="name"/>
<field name="book_limit"/>
<field name="username"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="library_validity_form_view">
<field name="name">library.validity.form</field>
<field name="model">library.validity</field>
<field name="arch" type="xml">
<form string="Card Details" >
<sheet style="width: 10%%,height:10%%">
<group col="2" colspan="4">
<group>
<field name="code" />
<field name="name"/>
</group>
<group>
<field name="year"/>
<field name="month"/>
<field name="day"/>
</group>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.ui.view" id="library_validity_tree">
<field name="name">library.validity.tree</field>
<field name="model">library.validity</field>
<field name="arch" type="xml">
<tree string="Validity Details">
<!--<field name="name"/>-->
<field name="code"/>
</tree>
</field>
</record>
<record id="seq_validity_type" model="ir.sequence.type">
<field name="name">Validity</field>
<field name="code">library.validity</field>
</record>
<record id="seq_validity" model="ir.sequence">
<field name="name">Book category</field>
<field name="code">library.validity</field>
<field name="prefix">VAL</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_validity">
<field name="name">Validity</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">library.validity</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="product_card_form_view">
<field name="name">library.card.form</field>
<field name="model">library.card</field>
<field name="arch" type="xml">
<form string="Card Details" >
<sheet style="width: 10%%,height:10%%">
<group col="2" colspan="4">
<field name="username" on_change="onchange_username(username)" widget="selection" style="width:40%%"/>
<field name="book_limit" style="width:40%%"/>
<separator string="Borrow History" colspan="4"/>
<field name="account_ids" nolabel="1" colspan="4">
<tree string="Borrow history">
<field name="issue_code"/>
<field name="name"/>
<field name="state"/>
</tree>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record id="seq_type_lib_card_no" model="ir.sequence.type">
<field name="name">Library Card No</field>
<field name="code">library.card</field>
</record>
<record id="seq_lib_card_no" model="ir.sequence">
<field name="name">Library Card No</field>
<field name="code">library.card</field>
<field name="prefix">C</field>
<field name="number_next">1</field>
<field name="padding">3</field>
</record>
<record model="ir.actions.act_window" id="action_book_search">
<field name="name">Book Reports</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">book.report</field>
<field name="view_mode">tree,form</field>
</record>
<record model="ir.ui.view" id="wizard_booksearch_view">
<field name="name">book report</field>
<field name="model">book.report</field>
<field name = "type">form</field>
<field name="arch" type="xml">
<form string="Search Books">
<group>
<group>
<field name="book" widget="selection" domain="[('book','=',True)]" style="width:50%%"/>
<field name="catag" widget="selection" style="width:50%%"/>
<field name="rack" widget="selection" style="width:50%%"/>
</group>
<group>
<field name="author" widget="selection" style="width:50%%"/>
<field name="language" widget="selection" style="width:50%%"/>
</group>
</group>
<footer>
<button name = "confirmfilter" string = "Confirm Filter" type = "object" class = "oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel"/>
</footer>
</form>
</field>
</record>
<act_window
name = "Search Books"
res_model = "book.report"
view_mode = "form"
view_type = "form"
target = "new"
key2 = "client_action_multi"
id = "action_book_search"
/>
<record model="ir.actions.act_window" id="action_available_books">
<field name="name">Available Books</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">product.product</field>
<field name="view_type">tree</field>
<field name="view_mode">tree</field>
<field name="domain">[('available_copies','>',0)]</field>
</record>
<record model="ir.actions.act_window" id="action_book_holdings">
<field name="name">Book Holdings</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">library.book.issue</field>
<field name="view_type">tree</field>
<field name="view_mode">tree</field>
<field name="domain">[('state','=','transfered')]</field>
</record>
<record model="ir.ui.view" id="modify_product_form_view">
<field name ="name">product.product.form</field>
<field name = "model">product.product</field>
<field name = "inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='ean13']" position="before">
<field name="book" />
</xpath>
<xpath expr="//field[@name='lst_price']" position="after">
<group string="Book Details" attrs="{'invisible':[('book','=',False)]}">
<field name="editor" />
<!--<field name="book_id"/>-->
<field name="author" placeholder="Name of Author" />
<field name="publisher" />
<field name="total_copies" on_change="onchange_total(total_copies)" invisible="1"/>
<field name="available_copies" invisible="1"/>
<field name="book_cat" />
<field name="year_of_publication"/>
<field name="rack" /></group>
</xpath>
<xpath expr="//field[@name='default_code']" position="after">
<group attrs="{'invisible':[('book','=',False)]}">
<field name="isbn"/>
<field name="lang" />
<field name="date_parution"/>
<field name="creation_date"/>
<field name="date_retour"/>
<field name="nbpage"/>
<field name="back"/>
<field name="num_edition"/>
<field name="format"/>
</group>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="modify_product_tree_view">
<field name ="name">product.product.tree</field>
<field name = "model">product.product</field>
<field name = "inherit_id" ref="product.product_product_tree_view"/>
<field name="arch" type="xml">
<xpath expr="/tree[@string='Product Variants']" position="replace">
<tree string="new tree" >
<field name="name"/>
<field name="attribute_value_ids" widget="many2many_tags" invisible="1"/>
<field name="price" invisible="not context.get('pricelist',False)"/>
<field name="state" invisible="1"/>
<field name="product_tmpl_id" invisible="1"/>
<field name="author"/>
<field name="lang"/>
<field name="book_cat"/>
<field name="total_copies" invisible="1"/>
<field name="available_copies"/>
<field name="lst_price"/>
</tree>
</xpath>
</field>
</record>
<record model="ir.ui.view" id="modify_product_treestock_view">
<field name ="name">product.product.tree</field>
<field name = "model">product.product</field>
<field name = "inherit_id" ref="stock.view_stock_product_tree"/>
<field name="arch" type="xml">
<xpath expr="/tree/field[@name='qty_available']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="/tree/field[@name='virtual_available']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
<menuitem name="Book Issues" id="menu_book_issues" parent="menu_generral"
sequence="5" action="action_book_issues"/>
<menuitem name="Card Details" id="menu_courses" parent="menu_generral"
sequence="1" action="action_library"/>
<menuitem name="Search Books" id="menu_book_search" parent="menu_opac"
sequence="6" action="action_book_search"/>
<menuitem name="Available Books" id="menu_available_books" parent="menu_opac"
sequence="1" action="action_available_books"/>
<menuitem name="Book Holdings" id="menu_book_holdings" parent="menu_opac"
sequence="4" action="action_book_holdings"/>
<menuitem name="Validity" parent="menu_configuration" sequence="7" id="menu_validity" action="action_validity"/>
<!--<menuitem name="Store" id="menu_library_store" action="action_library_store" parent="menu_configuration"/>-->
<!--<menuitem name="Account" id="menu_library_account" action="action_library_account" parent="menu_configuration"/>-->
<!--<menuitem name="Fine Amount" id="menu_day_fine" action="action_day_fine" parent="menu_configuration"/>-->
<menuitem name="Library Rack" id="menu_library_rack" sequence="5" action="action_library_rack" parent="menu_configuration"/>
<menuitem name="Languages" parent="menu_configuration" id="menu_lang" sequence="4" action="action_lang"/>
<menuitem name="Author" id="author_menu" action="action_author_list" sequence="3" parent="menu_configuration"/>
<menuitem name="Books" id="menu_book_products" action="action_product_book_list" sequence="1" parent="menu_configuration"/>
<menuitem name="Book Return Days" parent="menu_configuration" sequence="6" id="menu_book_returnday" action="action_lang_book_day"/>
<menuitem name="Book Category" id="menu_price_category" action="action_price_category" sequence="2" parent="menu_configuration"/>
</data>
</openerp>

130
library_management/view/registration.xml

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record model="ir.module.category" id="group_librarian">
<field name="name">Librarian group</field>
</record>
<record id="librarian_group" model="res.groups">
<field name="name">Librarian</field>
<field name="category_id" ref="group_librarian"/>
</record>
<record id="Administrator_group" model="res.groups">
<field name="name">Administrator</field>
<field name="category_id" ref="group_librarian"/>
</record>
<!-- Sequences for card.no (Card Number) -->
<record id="seq_reg_no_type" model="ir.sequence.type">
<field name="name">Reg Number</field>
<field name="code">reg.no</field>
</record>
<record id="seq_reg_no" model="ir.sequence">
<field name="name">Reg Number</field>
<field name="code">reg.no</field>
<field name="prefix">R</field>
<field name="padding">3</field>
</record>
<record id="ir_cron_registered_users_manager" model="ir.cron">
<field name="name">Registered users Manager</field>
<field eval="True" name="active" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field name="model">library.registration</field>
<field name="function">_registered_user_manager</field>
<field name="args">()</field>
</record>
<record id="ir_cron_library_reminder" model="ir.cron">
<field name="name">Library Reminder</field>
<field eval="True" name="active" />
<field name="user_id" ref="base.user_root" />
<field name="interval_number">1</field>
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field eval="False" name="doall" />
<field name="model">library.book.issue</field>
<field name="function">_library_reminder</field>
<field name="args">()</field>
</record>
<!-- library Registration Form View -->
<record model="ir.ui.view" id="view_registration_form_1">
<field name="name">library.registration.form.1</field>
<field name="model">library.registration</field>
<field name="arch" type="xml">
<form string="Registration Form" version="7.0">
<header>
<button name="register" string="Register" type="object" class="oe_highlight" states="draft" />
<button name="create_card" string="Assign Card" type="object" states="registered" />
<button name="renew" string="Renew" type="object" states="assigned_card" />
<button name="cancel" string="Cancel" type="object" states="draft,registered,assigned_card"
confirm="Cancelling registration will delete card and cancel registration...
Are you sure you want to cancel this registration?"/>
<button name="draft" string="Draft" type="object" states="cancel"/>
<field name="state" widget="statusbar" align="right" readonly="1"/>
</header>
<sheet style="width: 10%%,height:10%%">
<newline/>
<separator string="Library Registration"/>
<div class="oe_title oe_left">
<h2>
<field name="card_no" class="oe_inline" readonly="1"/>
</h2>
<field name="photo" widget='image' class="oe_left oe_avatar" options='{"preview_image": "image_medium", "size": [90, 90]}'/>
</div>
<group col="4">
<group col="2" attrs="{'readonly':[('state','not in','draft')]}">
<separator string="Personal Information" colspan="4"/>
<field name="name" placeholder="User" on_change="getdata(name)" style="width:40%%"/>
<!--<field name="position"/>-->
<field name="phone" style="width:40%%"/>
<field name="mobile" style="width:40%%"/>
<field name="user" style="width:40%%"/>
<field name="book_limit" style="width:40%%"/>
</group>
<group col="2" states="cancel,registered,assigned_card" >
<separator string="Registration Details" colspan="4"/>
<field name="registration_date" readonly="1"/>
<field name="validity" widget="selection" attrs="{'readonly':[('state','=','cancel')],'required':[('state','=','registered')]}"/>
<field name="from_id" readonly="1" />
<field name="to" />
</group>
</group> <notebook>
<page string="Remarks" states="cancel,registered,assigned_card">
<field name="notes"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
<!-- Library Registration Tree View -->
<record model="ir.ui.view" id="view_registration_tree_1">
<field name="name">library.registration.tree.1</field>
<field name="model">library.registration</field>
<field name="arch" type="xml">
<tree string="Library Register">
<field name="card_no"/>
<field name="name"/>
<field name="registration_date" />
<field name="state"/>
</tree>
</field>
</record>
</data>
</openerp>

70
library_management/view/report_invoice.xml

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_invoice_library">
<t t-call="report.html_container">
<t t-foreach="docs" t-as="o">
<t t-call="report.external_layout">
<div class="page">
<div class="row">
<div class="col-xs-5 col-xs-offset-7">
<address t-field="o.user"
t-field-options='{"widget": "contact", "fields": ["address", "name"], "no_marker": true}' />
<span t-if="o.user.vat">VAT: <span t-field="o.user.vat"/></span>
</div>
</div>
<h2>
<center>
<span>Invoice</span>
</center>
</h2>
<div class="row mt32 mb32">
<div class="col-xs-2" >
<strong>Invoice Date:</strong>
<span t-esc="timee(o.user)"/>
</div>
</div>
<t t-set="budget" t-value="get_data(o.issue_code)"/>
<table class="table table-condensed">
<thead>
<tr>
<th>Book</th>
<th>Description</th>
<th>Quantity</th>
<th >Unit Price</th>
<th >Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr>
<td><span t-esc="budget['product']"/></td>
<td><span t-esc="budget['descri']"/></td>
<td><span t-esc="budget['quant']"/></td>
<td><span t-esc="budget['price']"/></td>
<td><span t-esc="budget['subtotal']"/></td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Total</strong></td>
<td class="text-right">
<span t-esc="budget['subtotal']"/>
</td>
</tr>
</table>
</div>
</div>
</div>
</t>
</t>
</t>
</template>
</data>
</openerp>

49
library_management/view/user_view.xml

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Registration menu -->
<menuitem
name="Registration" parent="menu_root"
id="menu_registration"
sequence="1"/>
<!-- Registration form Action view -->
<record model="ir.actions.act_window" id="action_registration_form_2">
<field name="name">Registration Form</field>
<field name="res_model">library.registration</field>
<field name="view_type">form</field>
<!--<field name="view_id" ref="view_registration_form_2" />-->
<field name="view_mode">tree,form</field>
</record>
<menuitem
name="Registration Form " parent="menu_registration"
id="menu_registration_form" sequence="1"
action="action_registration_form_2"/>
<!--User Action view -->
<!--<record model="ir.actions.act_window" id="action_user_form">-->
<!--<field name="name">User Information</field>-->
<!--<field name="res_model">res.partner</field>-->
<!--<field name="view_type">form</field>-->
<!--&lt;!&ndash;<field name="view_id" ref="view_registration_form_2" />&ndash;&gt;-->
<!--<field name="view_mode">tree,form</field>-->
<!--</record>-->
<record model="ir.actions.act_window" id="action_user_formm">
<field name="name">Members</field>
<field name="res_model">res.partner</field>
<field name="type">ir.actions.act_window</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('librarian','=','True')]</field>
</record>
<menuitem
name="Members" parent="menu_registration"
id="menu_user_form" sequence="2"
action="action_user_formm"/>
</data>
</openerp>
Loading…
Cancel
Save