Browse Source

branch cleard

master
cybroodoo 9 years ago
parent
commit
01aa641fbf
  1. 57
      library_management/.gitignore
  2. 4
      library_management/__init__.py
  3. 31
      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
  22. 2
      sale_discount_total/__init__.py
  23. 34
      sale_discount_total/__openerp__.py
  24. 34
      sale_discount_total/__openerp__.py~
  25. 3
      sale_discount_total/models/__init__.py
  26. 2
      sale_discount_total/models/__init__.py~
  27. 75
      sale_discount_total/models/account_invoice.py
  28. 88
      sale_discount_total/models/account_invoice.py~
  29. 93
      sale_discount_total/models/sale.py
  30. 93
      sale_discount_total/models/sale.py~
  31. 102
      sale_discount_total/models/sale_discount_approval.py
  32. 2
      sale_discount_total/report/__init__.py
  33. 22
      sale_discount_total/report/invoice_report.py
  34. 14
      sale_discount_total/report/sale_report.py
  35. BIN
      sale_discount_total/static/description/Disc_appr_conf.png
  36. BIN
      sale_discount_total/static/description/Disc_appr_wrkfl.png
  37. BIN
      sale_discount_total/static/description/Discount_inv_amnt.png
  38. BIN
      sale_discount_total/static/description/Discount_so_perc.png
  39. BIN
      sale_discount_total/static/description/icon.png
  40. 39
      sale_discount_total/static/description/index.html
  41. 35
      sale_discount_total/views/account_invoice_view.xml
  42. 84
      sale_discount_total/views/invoice_report.xml
  43. 87
      sale_discount_total/views/invoice_report.xml~
  44. 28
      sale_discount_total/views/sale_discount_approval_view.xml
  45. 133
      sale_discount_total/views/sale_discount_approval_workflow.xml
  46. 40
      sale_discount_total/views/sale_order_report.xml
  47. 40
      sale_discount_total/views/sale_order_report.xml~
  48. 34
      sale_discount_total/views/sale_view.xml
  49. 34
      sale_discount_total/views/sale_view.xml~
  50. 0
      taxless_accounting/__init__.py
  51. 26
      taxless_accounting/__openerp__.py
  52. 209
      taxless_accounting/account_view.xml
  53. BIN
      taxless_accounting/static/description/check_box.png
  54. BIN
      taxless_accounting/static/description/icon.png
  55. 19
      taxless_accounting/static/description/index.html
  56. BIN
      taxless_accounting/static/description/tax_invoice.png
  57. 0
      taxless_purchase_sale/__init__.py
  58. 26
      taxless_purchase_sale/__openerp__.py
  59. 88
      taxless_purchase_sale/purchase_view.xml
  60. BIN
      taxless_purchase_sale/static/description/check_box.png
  61. BIN
      taxless_purchase_sale/static/description/icon.png
  62. 19
      taxless_purchase_sale/static/description/index.html
  63. BIN
      taxless_purchase_sale/static/description/sale_order.png

57
library_management/.gitignore

@ -1,57 +0,0 @@
# 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

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

31
library_management/__openerp__.py

@ -1,31 +0,0 @@
{
'name': 'Public Library Management ',
'version': '1.0',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'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

@ -1,14 +0,0 @@
<?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

@ -1,772 +0,0 @@
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

@ -1,244 +0,0 @@
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

@ -1,14 +0,0 @@
<?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

@ -1 +0,0 @@
import report_invoice_parser

34
library_management/report/report_invoice_parser.py

@ -1,34 +0,0 @@
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

@ -1,73 +0,0 @@
# -*- 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

@ -1,53 +0,0 @@
<?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

@ -1,29 +0,0 @@
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

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

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

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

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

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

BIN
library_management/static/description/icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

722
library_management/view/library.xml

@ -1,722 +0,0 @@
<?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

@ -1,130 +0,0 @@
<?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

@ -1,70 +0,0 @@
<?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

@ -1,49 +0,0 @@
<?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>

2
sale_discount_total/__init__.py

@ -1,2 +0,0 @@
import models
import report

34
sale_discount_total/__openerp__.py

@ -1,34 +0,0 @@
{
'name': 'Sale Discount for Total Amount',
'version': '1.0',
'category': 'sale',
'sequence': 6,
'summary': "A module meant to provide discount for total amount and Discount limit with approval in sales",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'description': """
Sale Discount for Total Amount
=======================
Module to manage discount for total amount in Sale.
Two Type of Discount,
Discount by a fixed value,
Discount by a percentage...
""",
'depends': ['sale', 'base', 'stock'],
'data': [
'views/sale_view.xml',
'views/account_invoice_view.xml',
'views/invoice_report.xml',
'views/sale_order_report.xml',
'views/sale_discount_approval_view.xml',
'views/sale_discount_approval_workflow.xml'
],
'demo': [
],
'installable': True,
'auto_install': False,
}

34
sale_discount_total/__openerp__.py~

@ -1,34 +0,0 @@
{
'name': 'Sale Discount for Total Amount',
'version': '1.0',
'category': 'sale',
'sequence': 6,
'summary': "extension of default Sale Management module meant to provide discount for total amount",
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'description': """
Sale Discount for Total Amount
=======================
Module to manage discount for total amount in Sale.
Two Type of Discount,
Discount by a fixed value,
Discount by a percentage...
""",
'depends': ['sale', 'base', 'stock'],
'data': [
'views/sale_view.xml',
'views/account_invoice_view.xml',
'views/invoice_report.xml',
'views/sale_order_report.xml',
'views/sale_discount_approval_view.xml',
'views/sale_discount_approval_workflow.xml'
],
'demo': [
],
'installable': True,
'auto_install': False,
}

3
sale_discount_total/models/__init__.py

@ -1,3 +0,0 @@
import account_invoice
import sale
import sale_discount_approval

2
sale_discount_total/models/__init__.py~

@ -1,2 +0,0 @@
import account_invoice
import sale

75
sale_discount_total/models/account_invoice.py

@ -1,75 +0,0 @@
from openerp import api, models, fields
from openerp.osv import osv
import openerp.addons.decimal_precision as dp
class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.one
@api.depends('invoice_line.price_subtotal', 'tax_line.amount')
def _compute_amount(self):
disc = 0.0
for inv in self:
for line in inv.invoice_line:
disc += (line.quantity * line.price_unit) * line.discount / 100
self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line)
self.amount_tax = sum(line.amount for line in self.tax_line)
self.amount_discount = round(disc)
self.amount_total = round(self.amount_untaxed + self.amount_tax)
discount_type = fields.Selection([('percent', 'Percentage'), ('amount', 'Amount')], 'Discount Type', readonly=True,
states={'draft': [('readonly', False)]})
discount_rate = fields.Float('Discount Rate', digits_compute=dp.get_precision('Account'), readonly=True,
states={'draft': [('readonly', False)]})
amount_discount = fields.Float(string='Discount', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount')
amount_untaxed = fields.Float(string='Subtotal', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount', track_visibility='always')
amount_tax = fields.Float(string='Tax', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount')
amount_total = fields.Float(string='Total', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount')
@api.multi
def compute_discount(self, discount):
for inv in self:
val1 = val2 = 0.0
disc_amnt = 0.0
val2 = sum(line.amount for line in self.tax_line)
for line in inv.invoice_line:
val1 += (line.quantity * line.price_unit)
line.discount = discount
disc_amnt += (line.quantity * line.price_unit) * discount / 100
total = val1 + val2 - disc_amnt
self.amount_discount = round(disc_amnt)
self.amount_tax = round(val2)
self.amount_total = round(total)
@api.onchange('discount_type', 'discount_rate')
def supply_rate(self):
for inv in self:
amount = sum(line.price_subtotal for line in self.invoice_line)
tax = sum(line.amount for line in self.tax_line)
if inv.discount_type == 'percent':
self.compute_discount(inv.discount_rate)
else:
total = 0.0
discount = 0.0
for line in inv.invoice_line:
total += (line.quantity * line.price_unit)
if inv.discount_rate != 0:
discount = (inv.discount_rate / total) * 100
self.compute_discount(discount)
@api.model
def _prepare_refund(self, invoice, date=None, period_id=None, description=None, journal_id=None):
res = super(AccountInvoice, self)._prepare_refund(invoice, date, period_id,
description, journal_id)
res.update({
'discount_type': self.discount_type,
'discount_rate': self.discount_rate,
})
return res

88
sale_discount_total/models/account_invoice.py~

@ -1,88 +0,0 @@
from openerp import api, models, fields
from openerp.osv import osv
import openerp.addons.decimal_precision as dp
class AccountInvoice(models.Model):
_inherit = "account.invoice"
@api.one
@api.depends('invoice_line.price_subtotal', 'tax_line.amount')
def _compute_amount(self):
self.amount_untaxed = sum(line.price_subtotal for line in self.invoice_line)
self.amount_tax = sum(line.amount for line in self.tax_line)
if self.discount_type == 'percent':
self.amount_discount = ((self.amount_untaxed + self.amount_tax) * self.discount_rate) / 100
elif self.discount_type == 'amount':
self.amount_discount = self.discount_rate
self.amount_total = self.amount_untaxed + self.amount_tax - self.amount_discount
discount_type = fields.Selection([('percent', 'Percentage'), ('amount', 'Amount')], 'Discount Type', readonly=True,
states={'draft': [('readonly', False)]})
discount_rate = fields.Float('Discount rate', digits_compute=dp.get_precision('Account'), readonly=True,
states={'draft': [('readonly', False)]})
amount_discount = fields.Float(string='Discount', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount')
amount_untaxed = fields.Float(string='Subtotal', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount', track_visibility='always')
amount_tax = fields.Float(string='Tax', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount')
amount_total = fields.Float(string='Total', digits=dp.get_precision('Account'),
readonly=True, compute='_compute_amount')
@api.onchange('discount_type', 'discount_rate')
def compute_discount(self):
for inv in self:
amount = sum(line.price_subtotal for line in self.invoice_line)
tax = sum(line.amount for line in self.tax_line)
if inv.discount_type == 'percent':
if inv.discount_rate == 100:
disc_amnt = amount + tax
else:
disc_amnt = (amount + tax) * inv.discount_rate / 100
total = amount + tax - disc_amnt
self.amount_discount = disc_amnt
self.amount_total = total
else:
total = (amount + tax) - inv.discount_rate
self.amount_discount = inv.discount_rate
self.amount_total = total
@api.model
def _prepare_refund(self, invoice, date=None, period_id=None, description=None, journal_id=None):
res = super(AccountInvoice, self)._prepare_refund(invoice, date, period_id,
description, journal_id)
res.update({
'discount_type': self.discount_type,
'discount_rate': self.discount_rate,
})
return res
class invoice_line(osv.Model):
_inherit = 'account.invoice.line'
def move_line_get(self, cr, uid, invoice_id, context=None):
res = super(invoice_line, self).move_line_get(cr, uid, invoice_id, context=context)
inv = self.pool.get('account.invoice').browse(cr, uid, invoice_id, context=context)
if inv.type in ('out_invoice', 'out_refund') and inv.discount_type:
prop = self.pool.get('ir.property').get(cr, uid, 'property_account_income_categ', 'product.category',
context=context)
prop_id = prop and prop.id or False
account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, inv.fiscal_position or False,
prop_id)
sign = -1
res.append({
'name': 'Discount',
'price_unit': sign * inv.amount_discount,
'quantity': 1,
'price': sign * inv.amount_discount,
'account_id': account_id,
'product_id': False,
'uos_id': False,
'account_analytic_id': False,
'taxes': False,
})
return res

93
sale_discount_total/models/sale.py

@ -1,93 +0,0 @@
from openerp.osv import fields, osv
from openerp import api
import openerp.addons.decimal_precision as dp
class SaleOrder(osv.Model):
_inherit = 'sale.order'
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
cur_obj = self.pool.get('res.currency')
res = {}
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_untaxed': 0.0,
'amount_discount': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
cur = order.pricelist_id.currency_id
val1 = val2 = val3 = 0.0
for line in order.order_line:
val1 += line.price_subtotal
val2 += self._amount_line_tax(cr, uid, line, context=context)
val3 += (line.product_uom_qty * line.price_unit) * line.discount / 100
res[order.id]['amount_untaxed'] = cur_obj.round(cr, uid, cur, val1)
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val2)
res[order.id]['amount_discount'] = cur_obj.round(cr, uid, cur, val3)
res[order.id]['amount_total'] = res[order.id]['amount_untaxed'] + res[order.id]['amount_tax']
return res
def _get_order(self, cr, uid, ids, context=None):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
_columns = {
'discount_type': fields.selection([
('percent', 'Percentage'),
('amount', 'Amount')], 'Discount type'),
'discount_rate': fields.float('Discount Rate', digits_compute=dp.get_precision('Account'),
readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, ),
'amount_discount': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Discount',
multi='sums', store=True, help="The total discount."),
'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'),
string='Untaxed Amount',
multi='sums', store=True, help="The amount without tax.", track_visibility='always'),
'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Taxes',
multi='sums', store=True, help="The tax amount."),
'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total',
multi='sums', store=True, help="The total amount."),
}
_defaults = {
'discount_type': 'percent',
}
@api.multi
def compute_discount(self, discount):
for order in self:
val1 = val2 = 0.0
disc_amnt = 0.0
for line in order.order_line:
val1 += (line.product_uom_qty * line.price_unit)
line.discount = discount
val2 += self._amount_line_tax(line)
disc_amnt += (line.product_uom_qty * line.price_unit * line.discount)/100
total = val1 + val2 - disc_amnt
self.currency_id = order.pricelist_id.currency_id
self.amount_discount = round(disc_amnt)
self.amount_tax = round(val2)
self.amount_total = round(total)
@api.onchange('discount_type', 'discount_rate')
def supply_rate(self):
for order in self:
if order.discount_type == 'percent':
self.compute_discount(order.discount_rate)
else:
total = 0.0
for line in order.order_line:
total += (line.product_uom_qty * line.price_unit)
discount = (order.discount_rate / total) * 100
self.compute_discount(discount)
def _prepare_invoice(self, cr, uid, order, lines, context=None):
invoice_vals = super(SaleOrder, self)._prepare_invoice(cr, uid, order, lines, context=context)
invoice_vals.update({
'discount_type': order.discount_type,
'discount_rate': order.discount_rate
})
return invoice_vals

93
sale_discount_total/models/sale.py~

@ -1,93 +0,0 @@
from openerp.osv import fields, osv
from openerp import api
import openerp.addons.decimal_precision as dp
class SaleOrder(osv.Model):
_inherit = 'sale.order'
def _amount_all(self, cr, uid, ids, field_name, arg, context=None):
cur_obj = self.pool.get('res.currency')
res = {}
for order in self.browse(cr, uid, ids, context=context):
res[order.id] = {
'amount_untaxed': 0.0,
'amount_discount': 0.0,
'amount_tax': 0.0,
'amount_total': 0.0,
}
cur = order.pricelist_id.currency_id
val1 = val2 = val3 = 0.0
for line in order.order_line:
val1 += line.price_subtotal
val2 += self._amount_line_tax(cr, uid, line, context=context)
val3 += (line.product_uom_qty * line.price_unit) * line.discount / 100
res[order.id]['amount_untaxed'] = round(cur_obj.round(cr, uid, cur, val1))
res[order.id]['amount_tax'] = round(cur_obj.round(cr, uid, cur, val2))
res[order.id]['amount_discount'] = round(cur_obj.round(cr, uid, cur, val3))
res[order.id]['amount_total'] = round(res[order.id]['amount_untaxed'] + res[order.id]['amount_tax'])
return res
def _get_order(self, cr, uid, ids, context=None):
result = {}
for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
result[line.order_id.id] = True
return result.keys()
_columns = {
'discount_type': fields.selection([
('percent', 'Percentage'),
('amount', 'Amount')], 'Discount type'),
'discount_rate': fields.float('Discount Rate', digits_compute=dp.get_precision('Account'),
readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, ),
'amount_discount': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Discount',
multi='sums', store=True, help="The total discount."),
'amount_untaxed': fields.function(_amount_all, digits_compute=dp.get_precision('Account'),
string='Untaxed Amount',
multi='sums', store=True, help="The amount without tax.", track_visibility='always'),
'amount_tax': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Taxes',
multi='sums', store=True, help="The tax amount."),
'amount_total': fields.function(_amount_all, digits_compute=dp.get_precision('Account'), string='Total',
multi='sums', store=True, help="The total amount."),
}
_defaults = {
'discount_type': 'percent',
}
@api.multi
def compute_discount(self, discount):
for order in self:
val1 = val2 = 0.0
disc_amnt = 0.0
for line in order.order_line:
val1 += (line.product_uom_qty * line.price_unit)
line.discount = discount
val2 += self._amount_line_tax(line)
disc_amnt += (line.product_uom_qty * line.price_unit * line.discount)/100
total = val1 + val2 - disc_amnt
self.currency_id = order.pricelist_id.currency_id
self.amount_discount = round(disc_amnt)
self.amount_tax = round(val2)
self.amount_total = round(total)
@api.onchange('discount_type', 'discount_rate')
def supply_rate(self):
for order in self:
if order.discount_type == 'percent':
self.compute_discount(order.discount_rate)
else:
total = 0.0
for line in order.order_line:
total += (line.product_uom_qty * line.price_unit)
discount = (order.discount_rate / total) * 100
self.compute_discount(discount)
def _prepare_invoice(self, cr, uid, order, lines, context=None):
invoice_vals = super(SaleOrder, self)._prepare_invoice(cr, uid, order, lines, context=context)
invoice_vals.update({
'discount_type': order.discount_type,
'discount_rate': order.discount_rate
})
return invoice_vals

102
sale_discount_total/models/sale_discount_approval.py

@ -1,102 +0,0 @@
from openerp import api, models, fields
from openerp.osv import fields, osv
from openerp import SUPERUSER_ID
##############################################################sale settings##############################################################
class Sale_config_settings(osv.TransientModel):
_inherit = 'sale.config.settings'
_columns = {
'limit_discount': fields.integer('Discount limit requires approval %', required=True,
help="Discount after which approval of sale is required."),
'module_sale_discount_approval': fields.boolean("Force two levels of approvals",
help='Provide a double validation mechanism for sale exceeding minimum discount.\n'
),
}
_defaults = {
'limit_discount': 40,
}
def get_default_limit_discount(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
limit_discount = ir_values.get_default(cr, uid, 'sale.config.settings', 'limit_discount')
return {
'limit_discount': limit_discount,
}
def set_limit_discount(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
wizard = self.browse(cr, uid, ids)[0]
if wizard.limit_discount:
limit_discount = wizard.limit_discount
ir_values.set_default(cr, SUPERUSER_ID, 'sale.config.settings', 'limit_discount', limit_discount)
def get_default_module_sale_discount_approval(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
module_sale_discount_approval = ir_values.get_default(cr, uid, 'sale.config.settings',
'module_sale_discount_approval')
return {
'module_sale_discount_approval': module_sale_discount_approval == 'True',
}
def set_module_sale_discount_approval(self, cr, uid, ids, context=None):
ir_values = self.pool.get('ir.values')
wizard = self.browse(cr, uid, ids)[0]
if wizard.module_sale_discount_approval:
module_sale_discount_approval = 'True'
else:
module_sale_discount_approval = 'False'
ir_values.set_default(cr, SUPERUSER_ID, 'sale.config.settings', 'module_sale_discount_approval',
module_sale_discount_approval)
#######################################################sale order workflow##############################################################
class SaleInherit(osv.Model):
_inherit = 'sale.order'
_columns = {
'state': fields.selection([('draft', 'Draft Quotation'),
('sent', 'Quotation Sent'),
('cancel', 'Cancelled'),
('waiting_date', 'Waiting Schedule'),
('waitingapproval', 'Waiting Approval'),
('progress', 'Sales Order'),
('manual', 'Sale to Invoice'),
('shipping_except', 'Shipping Exception'),
('invoice_except', 'Invoice Exception'),
('done', 'Done')], required=True, track_visibility='onchange'),
}
def action_button_confirm(self, cr, uid, ids, context=None):
discnt = 0.0
no_line = 0.0
line_dicnt = 0.0
prod_price = 0.0
conf = self.pool.get('ir.values')
sale_obj = self.browse(cr, uid, ids, context)
double_valid = conf.get_default(cr, uid, 'sale.config.settings', 'module_sale_discount_approval')
if double_valid == 'True':
min_disct = conf.get_default(cr, uid, 'sale.config.settings', 'limit_discount')
for line in sale_obj.order_line:
no_line += 1
discnt += line.discount
discnt = (discnt / no_line)
if discnt >= min_disct:
assert len(ids) == 1, 'This option should only be used for a single id at a time.'
self.signal_workflow(cr, uid, ids, 'order_toapprov')
return True
else:
return super(SaleInherit, self).action_button_confirm(cr, uid, ids, context)
else:
return super(SaleInherit, self).action_button_confirm(cr, uid, ids, context)
####################################### workflow functions#############################################################################
@api.one
def wait_approval(self):
self.state = 'waitingapproval'
return True

2
sale_discount_total/report/__init__.py

@ -1,2 +0,0 @@
import sale_report
import invoice_report

22
sale_discount_total/report/invoice_report.py

@ -1,22 +0,0 @@
from openerp.osv import fields, osv
class DiscountInvoiceReport(osv.osv):
_inherit = 'account.invoice.report'
_columns = {
'discount': fields.float('Discount', readonly=True),
}
def _select(self):
res = super(DiscountInvoiceReport,self)._select()
select_str = res + """, sub.discount / cr.rate as discount """
return select_str
def _sub_select(self):
res = super(DiscountInvoiceReport,self)._sub_select()
select_str = res + """,SUM(CASE
WHEN ai.type::text = ANY (ARRAY['out_refund'::character varying::text, 'in_invoice'::character varying::text])
THEN - ((ail.quantity / u.factor * u2.factor) * ail.price_unit * (ail.discount) / 100.0)
ELSE ((ail.quantity / u.factor * u2.factor) * ail.price_unit * (ail.discount) / 100.0) END) as discount"""
return select_str

14
sale_discount_total/report/sale_report.py

@ -1,14 +0,0 @@
from openerp.osv import fields, osv
class DiscountSaleReport(osv.osv):
_inherit = 'sale.report'
_columns = {
'discount': fields.float('Discount', readonly=True),
}
def _select(self):
res = super(DiscountSaleReport,self)._select()
select_str = res+""",sum(l.product_uom_qty * cr.rate * l.price_unit * (l.discount) / 100.0) as discount"""
return select_str

BIN
sale_discount_total/static/description/Disc_appr_conf.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

BIN
sale_discount_total/static/description/Disc_appr_wrkfl.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

BIN
sale_discount_total/static/description/Discount_inv_amnt.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

BIN
sale_discount_total/static/description/Discount_so_perc.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

BIN
sale_discount_total/static/description/icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

39
sale_discount_total/static/description/index.html

@ -1,39 +0,0 @@
<section class="oe_container">
<div class="oe_row">
<h2 class="oe_slogan">Discount On Sale</h2>
<!--<h3 class="oe_slogan">It Fits Your Sales Approach</h3>-->
<div>
<p>
This module allows you to mention discount on Total of sale order and Total of Customer Invoice in two ways
</p>
<hr>
<p>
1. As percentage<br>
Select 'Percentage' from Discount type and give discount percentage as Discount rate.
System will update the value of Discount and Total
</p>
<div class="oe_row_img oe_centered oe_mt32">
<img class="oe_picture oe_screenshot" src="Discount_so_perc.png">
</div>
<hr>
<p>
2. As amount<br>
Select 'Amount' from Discount type and give discount amount as Discount rate.
System will update the value of Discount and Total
</p>
<div class="oe_row_img oe_centered oe_mt32">
<img class="oe_picture oe_screenshot" src="Discount_inv_amnt.png">
</div>
<hr>
<p>
And the module also allows you to set a limit for total discount in percentage. Exceeding this limit
will require approval.
</p>
<div class="oe_row_img oe_centered oe_mt32">
<img class="oe_picture oe_screenshot" src="Disc_appr_conf.png"><hr>
<img class="oe_picture oe_screenshot" src="Disc_appr_wrkfl.png">
</div>
</div>
</div>
</section>

35
sale_discount_total/views/account_invoice_view.xml

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="discount_account_invoice_view_form1" model="ir.ui.view">
<field name="name">discount.account.invoice</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@class='oe_subtotal_footer oe_right']" position="replace">
<group col="4">
<group name="discount">
<field name="discount_type"/>
<field name="discount_rate"/>
</group>
<group class="oe_subtotal_footer oe_right">
<field name="amount_untaxed" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="amount_discount" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<div>
<label for="amount_tax"/>
<button name="button_reset_taxes" states="draft,proforma2"
string="(update)" class="oe_link oe_edit_only"
type="object" help="Recompute taxes and total"/>
</div>
<field name="amount_tax" nolabel="1" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="amount_total" class="oe_subtotal_footer_separator" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="residual" groups="account.group_account_user" widget="monetary" options="{'currency_field': 'currency_id'}"/>
<field name="reconciled" invisible="1"/>
</group>
</group>
</xpath>
</field>
</record>
</data>
</openerp>

84
sale_discount_total/views/invoice_report.xml

@ -1,84 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//table" position="replace">
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th>Quantity</th>
<th class="text-right">Unit Price</th>
<!--<span t-if="o.amount_discount">-->
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
<!--</span>-->
<th class="text-right">Taxes</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td><span t-field="l.name"/></td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<!--<span t-if="o.amount_discount">-->
<td class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
<!--</span>-->
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
</xpath>
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<t t-if="o.type=='out_invoice' or o.type=='out_refund'">-->
<!--<t t-if="o.discount_rate">-->
<tr>
<td>Discount</td>
<td class="text-right">
<span t-field="o.amount_discount" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
<!--</t>-->
</t>
</xpath>
<!--<xpath expr="//div[@class='col-xs-4 pull-right']" position="before">-->
<!--<t t-if="o.type=='out_invoice' or o.type=='out_refund'">-->
<!--<div class="col-xs-4">-->
<!--<t t-if="o.discount_rate">-->
<!--<table class="table table-condensed">-->
<!--<tr class="border-black">-->
<!--<td>Discount Type</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_type"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>Discount rate</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_rate"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr class="border-black"></tr>-->
<!--</table>-->
<!--</t>-->
<!--</div>-->
<!--</t>-->
<!--</xpath>-->
</template>
</data>
</openerp>

87
sale_discount_total/views/invoice_report.xml~

@ -1,87 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_invoice_document" inherit_id="account.report_invoice_document">
<xpath expr="//table" position="replace">
<table class="table table-condensed">
<thead>
<tr>
<th>Description</th>
<th>Quantity</th>
<th class="text-right">Unit Price</th>
<!--<span t-foreach="o.invoice_line" t-as="l">-->
<!--<span t-if="l.discount">-->
<span t-if="o.amount_discount">
<th class="text-right" groups="sale.group_discount_per_so_line">Discount (%)</th>
</span>
<!--</span>-->
<th class="text-right">Taxes</th>
<th class="text-right">Amount</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td><span t-field="l.name"/></td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<span t-if="o.amount_discount">
<td class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="l.discount"/>
</td>
</span>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal"
t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</tbody>
</table>
</xpath>
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<!--<t t-if="o.type=='out_invoice' or o.type=='out_refund'">-->
<t t-if="o.discount_rate">
<tr>
<td>Discount</td>
<td class="text-right">
<span t-field="o.amount_discount" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</t>
<!--</t>-->
</xpath>
<!--<xpath expr="//div[@class='col-xs-4 pull-right']" position="before">-->
<!--<t t-if="o.type=='out_invoice' or o.type=='out_refund'">-->
<!--<div class="col-xs-4">-->
<!--<t t-if="o.discount_rate">-->
<!--<table class="table table-condensed">-->
<!--<tr class="border-black">-->
<!--<td>Discount Type</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_type"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>Discount rate</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_rate"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr class="border-black"></tr>-->
<!--</table>-->
<!--</t>-->
<!--</div>-->
<!--</t>-->
<!--</xpath>-->
</template>
</data>
</openerp>

28
sale_discount_total/views/sale_discount_approval_view.xml

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="view_double_sale_configuration" model="ir.ui.view">
<field name="name">Sale Application</field>
<field name="model">sale.config.settings</field>
<field name="inherit_id" ref="sale.view_sales_config"/>
<field name="arch" type="xml">
<xpath expr="//div[@name='Sale Features']" position="inside">
<div>
<div name="module_sale_discount_approval">
<field name="module_sale_discount_approval" class="oe_inline"/>
<label for="module_sale_discount_approval"/>
<span class="oe_separate-from-text">
<label for="limit_discount"/>
<field name="limit_discount" attrs="{'required': [('module_sale_discount_approval','=',True)]}" class="oe_inline"/>
</span>
</div>
</div>
</xpath>
</field>
</record>
</data>
</openerp>

133
sale_discount_total/views/sale_discount_approval_workflow.xml

@ -1,133 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="sale_inherit_wkfform_view" model="ir.ui.view">
<field name="name">sale.order.workflow.inherit</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<!-- Statusbar widget should also contain the new status -->
<field name="state" position="replace">
<field name="state" widget="statusbar" statusbar_visible="draft,sent,progress,done" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>
</field>
<field name="state" position="before">
<!-- buttonz -->
<button string="Approve Order" type="workflow" name="order_confirm" states="waitingapproval" class="oe_highlight" groups="base.group_sale_manager"/>
</field>
<xpath expr="//button[@name='action_cancel']" position="attributes">
<attribute name ="states">waitingapproval,manual,progress</attribute>
</xpath>
<xpath expr="//button[@name='action_cancel']" position="attributes">
<attribute name ="states">waitingapproval,manual,progress</attribute>
</xpath>
</field>
</record>
<!--activity-->
<record id="act_approve" model="workflow.activity">
<field name="wkf_id" ref="sale.wkf_sale"/>
<field name="name">Waiting Approval</field>
<field name="kind">function</field>
<field name="action">wait_approval()</field>
</record>
<!--end of activity-->
<!--transitions-->
<record model="workflow.transition" id="sale.trans_draft_router">
<field name="act_from" ref="sale.act_draft"/>
<field name="act_to" ref="act_approve"/>
<field name="signal">order_toapprov</field>
</record>
<record id="sale_trans_draft_router" model="workflow.transition">
<field name="act_from" ref="sale.act_draft"/>
<field name="act_to" ref="sale.act_router"/>
<field name="signal">order_confirm</field>
</record>
<record id="sale_trans_approvd" model="workflow.transition">
<field name="act_from" ref="act_approve"/>
<field name="act_to" ref="sale.act_router"/>
<field name="signal">order_confirm</field>
</record>
<!--end of transition-->
<!--sale transition inherit-->
<record id="sale.trans_draft_sent" model="workflow.transition">
<field name="act_from" ref="sale.act_draft"/>
<field name="act_to" ref="sale.act_sent"/>
<field name="signal">quotation_sent</field>
</record>
<record id="sale.trans_draft_cancel" model="workflow.transition">
<field name="act_from" ref="sale.act_draft"/>
<field name="act_to" ref="sale.act_cancel"/>
<field name="signal">cancel</field>
</record>
<record id="sale.trans_sent_router" model="workflow.transition">
<field name="act_from" ref="sale.act_sent"/>
<field name="act_to" ref="sale.act_router"/>
<field name="signal">order_confirm</field>
</record>
<record id="sale.trans_sent_cancel" model="workflow.transition">
<field name="act_from" ref="sale.act_sent"/>
<field name="act_to" ref="sale.act_cancel"/>
<field name="signal">cancel</field>
</record>
<record id="sale.trans_router_wait_invoice" model="workflow.transition">
<field name="act_from" ref="sale.act_router"/>
<field name="act_to" ref="sale.act_wait_invoice"/>
</record>
<record id="sale.trans_wait_invoice_all_lines_invoiced" model="workflow.transition">
<field name="act_from" ref="sale.act_wait_invoice"/>
<field name="act_to" ref="sale.act_invoice_end"/>
<field name="signal">all_lines</field>
</record>
<record id="sale.trans_wait_invoice_cancel2" model="workflow.transition">
<field name="act_from" ref="sale.act_wait_invoice"/>
<field name="act_to" ref="sale.act_cancel2"/>
<field name="signal">cancel</field>
</record>
<record id="sale.trans_wait_invoice_invoice_manual" model="workflow.transition">
<field name="act_from" ref="sale.act_wait_invoice"/>
<field name="act_to" ref="sale.act_invoice"/>
<field name="signal">manual_invoice</field>
</record>
<record id="sale.trans_invoice_invoice_end" model="workflow.transition">
<field name="act_from" ref="sale.act_invoice"/>
<field name="act_to" ref="sale.act_invoice_end"/>
<field name="signal">subflow.paid</field>
</record>
<record id="sale.trans_invoice_invoice_except" model="workflow.transition">
<field name="act_from" ref="sale.act_invoice"/>
<field name="act_to" ref="sale.act_invoice_except"/>
<field name="signal">subflow.cancel</field>
</record>
<record id="sale.trans_invoice_except_invoice" model="workflow.transition">
<field name="act_from" ref="sale.act_invoice_except"/>
<field name="act_to" ref="sale.act_invoice"/>
<field name="signal">invoice_recreate</field>
</record>
<record id="sale.trans_invoice_except_invoice_end" model="workflow.transition">
<field name="act_from" ref="sale.act_invoice_except"/>
<field name="act_to" ref="sale.act_invoice_end"/>
<field name="signal">invoice_corrected</field>
</record>
<record id="sale.trans_invoice_except_invoice_cancel" model="workflow.transition">
<field name="act_from" ref="sale.act_invoice_except"/>
<field name="act_to" ref="sale.act_invoice_cancel"/>
<field name="signal">invoice_cancel</field>
</record>
<record id="sale.trans_invoice_end_done" model="workflow.transition">
<field name="act_from" ref="sale.act_invoice_end"/>
<field name="act_to" ref="sale.act_done"/>
</record>
<!--end of sale transitions-->
</data>
</openerp>

40
sale_discount_total/views/sale_order_report.xml

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_sale_order_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<!--<t t-if="o.discount_rate">-->
<tr>
<td>Discount</td>
<td class="text-right">
<span t-field="o.amount_discount" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
<!--</t>-->
</xpath>
<!--<xpath expr="//div[@class='col-xs-4 pull-right']" position="before">-->
<!--<div class="col-xs-4">-->
<!--<t t-if="o.discount_rate">-->
<!--<table class="table table-condensed">-->
<!--<tr class="border-black">-->
<!--<td>Discount Type</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_type"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>Discount Rate</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_rate"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr class="border-black"></tr>-->
<!--</table>-->
<!--</t>-->
<!--</div>-->
<!--</xpath>-->
</template>
</data>
</openerp>

40
sale_discount_total/views/sale_order_report.xml~

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="report_sale_order_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//div[@class='col-xs-4 pull-right']/table/tr[2]" position="after">
<t t-if="o.discount_rate">
<tr>
<td>Discount</td>
<td class="text-right">
<span t-field="o.amount_discount" t-field-options='{"widget": "monetary", "display_currency": "o.currency_id"}'/>
</td>
</tr>
</t>
</xpath>
<!--<xpath expr="//div[@class='col-xs-4 pull-right']" position="before">-->
<!--<div class="col-xs-4">-->
<!--<t t-if="o.discount_rate">-->
<!--<table class="table table-condensed">-->
<!--<tr class="border-black">-->
<!--<td>Discount Type</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_type"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr>-->
<!--<td>Discount Rate</td>-->
<!--<td class="text-right">-->
<!--<span t-field="o.discount_rate"/>-->
<!--</td>-->
<!--</tr>-->
<!--<tr class="border-black"></tr>-->
<!--</table>-->
<!--</t>-->
<!--</div>-->
<!--</xpath>-->
</template>
</data>
</openerp>

34
sale_discount_total/views/sale_view.xml

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="discount_sale_view_form" model="ir.ui.view">
<field name="name">discount.sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='sale_total']" position="replace">
<group col="4">
<group name="discount" colspan="2">
<field name="discount_type"/>
<field name="discount_rate"/>
</group>
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
<field name="amount_untaxed" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="amount_discount" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="amount_tax" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<div class="oe_subtotal_footer_separator oe_inline">
<label for="amount_total" />
<button name="button_dummy"
states="draft,sent" string="(update)" type="object" class="oe_edit_only oe_link"/>
</div>
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</group>
</group>
</xpath>
<xpath expr="//button[@string='Create Invoice']" position="attributes">
<attribute name="context">{'discount_type':discount_type,'discount_rate':discount_rate,'amount_discount':amount_discount}</attribute>
</xpath>
</field>
</record>
</data>
</openerp>

34
sale_discount_total/views/sale_view.xml~

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="discount_sale_view_form" model="ir.ui.view">
<field name="name">discount.sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='sale_total']" position="replace">
<group col="4">
<group name="discount">
<field name="discount_type"/>
<field name="discount_rate"/>
</group>
<group class="oe_subtotal_footer oe_right" colspan="2" name="sale_total">
<field name="amount_untaxed" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="amount_discount" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<field name="amount_tax" widget='monetary' options="{'currency_field': 'currency_id'}"/>
<div class="oe_subtotal_footer_separator oe_inline">
<label for="amount_total" />
<button name="button_dummy"
states="draft,sent" string="(update)" type="object" class="oe_edit_only oe_link"/>
</div>
<field name="amount_total" nolabel="1" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/>
</group>
</group>
</xpath>
<xpath expr="//button[@string='Create Invoice']" position="attributes">
<attribute name="context">{'discount_type':discount_type,'discount_rate':discount_rate,'amount_discount':amount_discount}</attribute>
</xpath>
</field>
</record>
</data>
</openerp>

0
taxless_accounting/__init__.py

26
taxless_accounting/__openerp__.py

@ -1,26 +0,0 @@
{
'name': 'Taxless Accounting',
'version': '1.0',
'category': 'Accounting',
'sequence': 6,
'summary': 'Lets hide Tax from Accounting',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'description': """
=======================
""",
'depends': ['account','base','account_voucher'],
'data': [
'account_view.xml',
],
'demo': [
],
'installable': True,
'auto_install': False,
}

209
taxless_accounting/account_view.xml

@ -1,209 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="make_visible" model="res.groups">
<field name="name">Tax Visible</field>
</record>
</data>
<data>
<!--customer invoice-->
<record id="account_invoice_vinherit_form" model="ir.ui.view">
<field name="name">tax.account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<!--<label for="amount_tax" position="replace">-->
<!--</label>-->
<xpath expr="//label[@for='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='invoice_line']/tree/field[@name='invoice_line_tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='tax_line']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--supplier invoice-->
<record id="invoice_supplier_inherit_view" model="ir.ui.view">
<field name="name">discount.account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line']/tree/field[@name='invoice_line_tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<!--<label for="amount_tax" position="replace">-->
<!--</label>-->
<xpath expr="//label[@for='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='tax_line']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--account customer refund form-->
<record id="account_invoice_refund_inherit_form" model="ir.ui.view">
<field name="name">sale_account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line']/tree/field[@name='invoice_line_tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--account supplier refund form-->
<record id="account_invoice_refund_inherit_form" model="ir.ui.view">
<field name="name">sale_account.invoice.form</field>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_supplier_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='invoice_line']/tree/field[@name='invoice_line_tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='tax_line']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--customer receipts-->
<record id="customer_account_voucher_inherited_view" model="ir.ui.view">
<field name="name">customer_account_voucher_inherit_view</field>
<field name="model">account.voucher</field>
<field name="inherit_id" ref="account_voucher.view_sale_receipt_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='tax_amount']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--supplier receipts-->
<record id="supplier_account_voucher_inherited_view" model="ir.ui.view">
<field name="name">supplier_account_voucher_inherit_view</field>
<field name="model">account.voucher</field>
<field name="inherit_id" ref="account_voucher.view_purchase_receipt_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='tax_amount']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--journal entries-->
<record id="account_move_inherited_view" model="ir.ui.view">
<field name="name">account_move_voucher_inherit_view</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='line_id']/tree/field[@name='tax_code_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='line_id']/tree/field[@name='tax_amount']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<menuitem
id="account.account_template_taxes"
name="Taxes"
parent="account.account_template_folder"
groups="make_visible"
sequence="2"/>
<menuitem
id="account.menu_tax_report"
name="Taxes"
groups="make_visible"
parent="account.menu_finance_generic_reporting"
sequence="3"/>
<menuitem
action="account.action_tax_form"
id="account.menu_action_tax_form"
parent="account.next_id_27"
groups="make_visible"/>
<menuitem
name="Taxes Report"
parent="account.menu_tax_report"
groups="make_visible"
action="account.action_account_vat_declaration"
id="account.menu_account_vat_declaration"
icon="STOCK_PRINT"/>
<menuitem
action="account.action_tax_code_list"
id="account.menu_action_tax_code_list"
parent="account.next_id_27"
sequence="12"
groups="make_visible"/>
<menuitem
icon="STOCK_INDENT"
action="account.action_account_tax_chart"
id="account.menu_action_tax_code_tree"
parent="account.menu_finance_charts"
groups="make_visible"
sequence="12"/>
<menuitem
action="account.action_account_tax_template_form"
id="account.menu_action_account_tax_template_form"
parent="account.account_template_taxes"
groups="make_visible"
sequence="13"/>
<menuitem
action="account.action_account_tax_code_template_form"
id="account.menu_action_account_tax_code_template_form"
parent="account.account_template_taxes"
groups="make_visible"
sequence="14"/>
<menuitem
id="account.next_id_27"
name="Taxes"
parent="account.menu_finance_configuration"
groups="make_visible"
sequence="20"/>
<menuitem
action="account.action_account_fiscal_position_template_form"
id="account.menu_action_account_fiscal_position_form_template"
parent="account.account_template_taxes"
groups="make_visible"
sequence="20"/>
<menuitem
action="account.action_account_fiscal_position_form"
id="account.menu_action_account_fiscal_position_form"
parent="account.next_id_27"
groups="make_visible"
sequence="20"/>
</data>
</openerp>

BIN
taxless_accounting/static/description/check_box.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

BIN
taxless_accounting/static/description/icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

19
taxless_accounting/static/description/index.html

@ -1,19 +0,0 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Hide Tax From Accounting </h2>
<div class="oe_span6">
<p class="oe_mt32">
Hides tax related fields and menus from accounting
</p>
<p>
This hiding happens in user level. If you check this option hidden things will become visible for that user
</p>
<hr>
</div>
<div class="oe_row_img oe_centered oe_mt32">
<img class="oe_picture oe_screenshot" src="check_box.png"><hr>
<img class="oe_picture oe_screenshot" src="tax_invoice.png">
</div>
</div>
</section>

BIN
taxless_accounting/static/description/tax_invoice.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

0
taxless_purchase_sale/__init__.py

26
taxless_purchase_sale/__openerp__.py

@ -1,26 +0,0 @@
{
'name': 'Taxless Sale & Purchase',
'version': '1.0',
'category': 'Purchase',
'sequence': 7,
'summary': 'hide Tax from Sales and Purchases',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'description': """
=======================
""",
'depends': ['base', 'sale', 'purchase', 'taxless_accounting'],
'data': [
'purchase_view.xml'
],
'demo': [
],
'installable': True,
'auto_install': False,
}

88
taxless_purchase_sale/purchase_view.xml

@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!--purchase Order -->
<record id="purchase_inherit_form" model="ir.ui.view">
<field name="name">taxless.purchase.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='amount_untaxed']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='taxes_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--sale Order-->
<record id="sale_inherit_form" model="ir.ui.view">
<field name="name">taxless.sale.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='order_line']/form/group/group/field[@name='tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='order_line']/tree/field[@name='tax_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='amount_untaxed']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='amount_tax']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--products template-->
<record id="product_inherit_form" model="ir.ui.view">
<field name="name">taxhide.product.form</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='taxes_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='supplier_taxes_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
<!--products product-->
<record id="product_product_inherit_form" model="ir.ui.view">
<field name="name">taxhide..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='taxes_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
<xpath expr="//field[@name='supplier_taxes_id']" position="attributes">
<attribute name="groups">taxless_accounting.make_visible</attribute>
</xpath>
</field>
</record>
</data>
</openerp>

BIN
taxless_purchase_sale/static/description/check_box.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

BIN
taxless_purchase_sale/static/description/icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

19
taxless_purchase_sale/static/description/index.html

@ -1,19 +0,0 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Hide Tax From Sales and Purchases </h2>
<div class="oe_span6">
<p class="oe_mt32">
Hides tax related fields and menus from Sales and Purchases
</p>
<p>
This hiding happens in user level. If you check this option hidden things will become visible for that user
</p>
<hr>
</div>
<div class="oe_row_img oe_centered oe_mt32">
<img class="oe_picture oe_screenshot" src="check_box.png"><hr>
<img class="oe_picture oe_screenshot" src="sale_order.png">
</div>
</div>
</section>

BIN
taxless_purchase_sale/static/description/sale_order.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Loading…
Cancel
Save