Browse Source

[ADD]Initial Commit

pull/11/merge
SHEREEF PT 8 years ago
parent
commit
9e7c885f1c
  1. 25
      pos_sale_reports/__init__.py
  2. 43
      pos_sale_reports/__openerp__.py
  3. 24
      pos_sale_reports/models/__init__.py
  4. 47
      pos_sale_reports/models/pos_daily_report.py
  5. 2
      pos_sale_reports/reports/__init__.py
  6. 161
      pos_sale_reports/reports/pos_report_parser.py
  7. 2
      pos_sale_reports/security/ir.model.access.csv
  8. BIN
      pos_sale_reports/static/description/banner.jpg
  9. BIN
      pos_sale_reports/static/description/cybro_logo.png
  10. BIN
      pos_sale_reports/static/description/icon.png
  11. 52
      pos_sale_reports/static/description/index.html
  12. BIN
      pos_sale_reports/static/description/report.png
  13. BIN
      pos_sale_reports/static/description/rewiz.png
  14. 40
      pos_sale_reports/views/pos_report_menu.xml
  15. 105
      pos_sale_reports/views/pos_report_template.xml

25
pos_sale_reports/__init__.py

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Sreejith P(<http://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import models
import reports

43
pos_sale_reports/__openerp__.py

@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Sreejith P(<http://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'name': 'POS Daily Report',
'version': '8.0.1.0.0',
'summary': 'POS Daily Sales Report',
'category': 'Point of sale',
'author': 'Cybrosys Techno Solutions',
'company': 'Cybrosys Techno Solutions',
'website': 'http://www.cybrosys.com',
'depends': [
'point_of_sale'
],
'data': [
'views/pos_report_template.xml',
'views/pos_report_menu.xml',
'security/ir.model.access.csv',
],
'license': 'AGPL-3',
'images': ['static/description/banner.jpg'],
'installable': True,
'auto_install': False,
}

24
pos_sale_reports/models/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Sreejith P(<http://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import pos_daily_report

47
pos_sale_reports/models/pos_daily_report.py

@ -0,0 +1,47 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Sreejith P(<http://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp import models, fields
class POSReport(models.TransientModel):
_name = 'pos.report'
date = fields.Datetime(string="Date", required=True)
date_to = fields.Datetime(string="To Date", required=True)
select_company = fields.Many2one('res.company', string='Company', default=lambda self: self.env.user.company_id)
point_of_sale = fields.Many2one('pos.config', string='Point Of Sale')
sales_person = fields.Many2one('res.users', string='Sales Person')
def print_sales_report(self, cr, uid, ids, context=None):
if context is None:
context = {}
data = self.read(cr, uid, ids)[0]
datas = {
'ids': context.get('active_ids'),
'model': 'pos.report',
'form': data,
'name': 'POS Report'
}
datas['form']['active_ids'] = context.get('active_ids', False)
return self.pool['report'].get_action(cr, uid, [], 'pos_sale_reports.report_daily_pos_sales', data=datas,
context=context)

2
pos_sale_reports/reports/__init__.py

@ -0,0 +1,2 @@
import pos_report_parser
# import pos_xls_report

161
pos_sale_reports/reports/pos_report_parser.py

@ -0,0 +1,161 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<http://www.cybrosys.com>).
# Author: Sreejith P(<http://www.cybrosys.com>)
# you can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# It is forbidden to publish, distribute, sublicense, or sell copies
# of the Software or modified copies of the Software.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# GENERAL PUBLIC LICENSE (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from openerp.report import report_sxw
from openerp.osv import osv
from dateutil import parser
import datetime
import pytz
from datetime import datetime
from pytz import timezone
from openerp import SUPERUSER_ID
fmt1 = "%Y-%m-%d"
class POSReportParser(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context=None):
super(POSReportParser, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'get_sale_details': self.get_sale_details,
'get_date': self.get_date,
'get_change_date': self.get_change_date,
})
self.context = context
def get_date(self):
now_utc = datetime.now(timezone('UTC'))
user_list = self.pool.get('res.users').search(self.cr, self.uid,
[('id', '=', SUPERUSER_ID)])
obj1 = self.pool.get('res.users').browse(self.cr, self.uid, user_list, context=None)
tz = pytz.timezone(obj1.partner_id.tz)
now_pacific = now_utc.astimezone(timezone(str(tz)))
current_date = now_pacific.strftime(fmt1)
return current_date
def get_change_date(self, data):
my_date = parser.parse(data['form']['date'])
proper_date_string = my_date.strftime('%d-%m-%Y')
return proper_date_string
def get_sale_details(self, data):
lines = []
if data['form']['sales_person'] and data['form']['point_of_sale']:
pos_orders = self.pool.get('pos.order').search(self.cr, self.uid,
[('date_order', '>=', data['form']['date']),
('date_order', '<=', data['form']['date_to']),
('user_id', '=', data['form']['sales_person'][0]),
('session_id.config_id', '=', data['form']['point_of_sale'][0])])
elif data['form']['point_of_sale']:
pos_orders = self.pool.get('pos.order').search(self.cr, self.uid,
[('date_order', '>=', data['form']['date']),
('date_order', '<=', data['form']['date_to']),
('session_id.config_id', '=', data['form']['point_of_sale'][0])])
elif data['form']['sales_person']:
pos_orders = self.pool.get('pos.order').search(self.cr, self.uid,
[('date_order', '>=', data['form']['date']),
('date_order', '<=', data['form']['date_to']),
('user_id', '=', data['form']['sales_person'][0])])
else:
pos_orders = self.pool.get('pos.order').search(self.cr, self.uid,
[('date_order', '>=', data['form']['date']),
('date_order', '<=', data['form']['date_to'])])
for order in pos_orders:
obj1 = self.pool.get('pos.order').browse(self.cr, self.uid, order, context=None)
if data['form']['select_company'][0] == 1:
order = obj1.name
if obj1.partner_id.name:
partner = obj1.partner_id.name
else:
partner = ""
price = obj1.amount_total
bank_amount = 0
cash_amount = 0
for statements in obj1.statement_ids:
if statements.journal_id.name == "Debt":
debit = debit + statements.amount
continue
if statements.journal_id.type == "bank":
if statements.amount > price:
bank_amount += price
elif statements.amount > 0:
bank_amount += statements.amount
else:
pass
if statements.journal_id.type == "cash":
if statements.amount > price:
cash_amount += price
elif statements.amount > 0:
cash_amount += statements.amount
else:
pass
vals = {
'order': order,
'partner': partner,
'price': price,
'cash': cash_amount,
'bank': bank_amount,
}
lines.append(vals)
elif obj1.company_id.id == data['form']['select_company'][0]:
order = obj1.name
if obj1.partner_id.name:
partner = obj1.partner_id.name
else:
partner = ""
price = obj1.amount_total
bank_amount = 0
cash_amount = 0
for statements in obj1.statement_ids:
if statements.journal_id.type == "bank":
if statements.amount > price:
bank_amount += price
elif statements.amount > 0:
bank_amount += statements.amount
else:
pass
if statements.journal_id.type == "cash":
if statements.amount > price:
cash_amount += price
elif statements.amount > 0:
cash_amount += statements.amount
else:
pass
vals = {
'order': order,
'partner': partner,
'price': price,
'cash': cash_amount,
'bank': bank_amount,
}
lines.append(vals)
return lines
class PrintReport(osv.AbstractModel):
_name = 'report.pos_sale_reports.report_daily_pos_sales'
_inherit = 'report.abstract_report'
_template = 'pos_sale_reports.report_daily_pos_sales'
_wrapped_report_class = POSReportParser

2
pos_sale_reports/security/ir.model.access.csv

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_pos_report,access.pos_.report,model_pos_report,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_pos_report access.pos_.report model_pos_report base.group_user 1 1 1 1

BIN
pos_sale_reports/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
pos_sale_reports/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
pos_sale_reports/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

52
pos_sale_reports/static/description/index.html

@ -0,0 +1,52 @@
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span12">
<h2 class="oe_slogan">POS Daily Report</h2>
<h3 class="oe_slogan">This saves your times in checking the pos daily sales. It gives the report from one touch</h3>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="rewiz.png">
</div>
</div>
<div class="oe_span6">
<p class="oe_mt32">
<p>The app gives a relief to your employee for submitting daily sales reports.</p>
</p>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_span6">
<p class="oe_mt32">
<p>It is a simple and attractive design. It gives details of payments and grand total of Total price and payment methods</p>
</p>
</div>
<div class="oe_span6">
<div class="oe_demo oe_picture oe_screenshot">
<img src="report.png">
</div>
</div>
</div>
</section>
<section class="oe_container oe_dark">
<h2 class="oe_slogan" style="margin-top:20px;" >Need Any Help?</h2>
<div class="oe_slogan" style="margin-top:10px !important;">
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;" href="http://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;"
href="http://www.cybrosys.com/contact/"><i
class="fa fa-phone"></i> Contact Us </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;"
href="http://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
</section>

BIN
pos_sale_reports/static/description/report.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
pos_sale_reports/static/description/rewiz.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

40
pos_sale_reports/views/pos_report_menu.xml

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<openerp>
<data>
<record id="view_daily_sales_report" model="ir.ui.view">
<field name="name">POS Report</field>
<field name="model">pos.report</field>
<field name="arch" type="xml">
<form string="Choose your details">
<group>
<group>
<field name="date"/>
<field name="date_to"/>
</group>
<group>
<field name="point_of_sale" options="{'no_create': True}"/>
<field name="sales_person" options="{'no_create': True}"/>
</group>
</group>
<footer>
<button name="print_sales_report" string="Print Report" type="object" class="oe_highlight"/>
or
<button string="Cancel" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="get_daily_sales_report" model="ir.actions.act_window">
<field name="name">POS Report</field>
<field name="res_model">pos.report</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_daily_sales_report"/>
<field name="target">new</field>
</record>
<menuitem id="pos_daily_report" name="POS Report" parent="point_of_sale.menu_point_rep" action="get_daily_sales_report"
groups="base.group_user"/>
</data>
</openerp>

105
pos_sale_reports/views/pos_report_template.xml

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<report
id="pos_sales_report"
string="Daily Sales Report"
model="pos.order"
report_type="qweb-pdf"
file="pos_sale_reports.report_daily_pos_sales"
name="pos_sale_reports.report_daily_pos_sales"
menu="False"
/>
<template id="report_daily_pos_sales">
<div class="page">
<h3><center><strong>POS Sales Report </strong></center></h3>
<table width="100%" style="padding:40px;height:25px;margin-left:50px;margin-top:35px;border: None solid black;">
<th width="30%"></th>
<th width="30%"></th>
<th width="30%"></th>
<th width="30%"></th>
<tr>
<td style="width:50px;height:25px;margin-left:50px;" >
<span>Company: </span><span t-att-style="style" t-esc="res_company.name"/>
</td>
<td style="width:50px;height:25px;margin-left:50px;" t-if="data['form']['point_of_sale']">
<span t-if="data['form']['point_of_sale']">Point of Sale: </span>
<span t-att-style="style" t-esc="data['form']['point_of_sale'][1]"/>
</td>
</tr>
<tr>
<td style="width:50px;height:25px;margin-left:50px;" align="left">
<span>Date of Report: </span>
<span t-att-style="style" t-esc="get_date()"/>
</td>
<td style="width:50px;height:25px;margin-left:50px;" align="left" t-if="data['form']['sales_person']">
<span t-if="data['form']['sales_person']">Sales Person: </span>
<span t-att-style="style" t-esc="data['form']['sales_person'][1]"/>
</td>
</tr>
</table>
<table class="table table-condensed">
<thead>
<tr >
<th style="text-align:center; background-color:#9b9da0 !important;">SL.NO</th>
<th style="text-align:center; background-color:#9b9da0 !important;">ORDER</th>
<th style="text-align:center; background-color:#9b9da0 !important;">CUSTOMER</th>
<th style="text-align:center; background-color:#9b9da0 !important;">TOTAL</th>
<th style="text-align:center; background-color:#9b9da0 !important;" colspan="3">PAYMENTS</th>
</tr>
<tr style="background-color: #d3d3d3;border-style: solid;">
<th style="background-color:#9b9da0 !important;"></th>
<th style="background-color:#9b9da0 !important;"></th>
<th style="background-color:#9b9da0 !important;"></th>
<th style="background-color:#9b9da0 !important;"></th>
<th style="text-align:center; background-color:#9b9da0 !important;">CASH</th>
<th style="text-align:center; background-color:#9b9da0 !important;" >BANK</th>
</tr>
</thead>
<tbody>
<t t-set="total_daily_sales" t-value='0'></t>
<t t-set="total_cash" t-value='0'></t>
<t t-set="total_bank" t-value='0'></t>
<t t-set="sl_no" t-value='0'></t>
<t t-foreach="get_sale_details(data)" t-as="b">
<tr>
<t t-set="sl_no" t-value="sl_no+1"/>
<td>
<span t-att-style="style" t-esc="sl_no"/>
</td>
<td>
<span t-att-style="style" t-esc="b['order']"/>
</td>
<td>
<span t-att-style="style" t-esc="b['partner']"/>
</td>
<td>
<span t-att-style="style" t-esc="b['price']"/>
</td>
<td>
<span t-att-style="style" t-esc="b['cash']"/>
</td>
<td>
<span t-att-style="style" t-esc="b['bank']"/>
</td>
<t t-set="total_daily_sales" t-value = "total_daily_sales + b['price'] "></t>
<t t-set="total_cash" t-value = "total_cash + b['cash'] "></t>
<t t-set="total_bank" t-value = "total_bank + b['bank'] "></t>
</tr>
</t>
<tr>
<td></td>
<td></td>
<td><strong>Grand total</strong></td>
<td><strong><t t-esc="total_daily_sales"></t></strong></td>
<td><strong><t t-esc="total_cash"></t></strong></td>
<td><strong><t t-esc="total_bank"></t></strong></td>
</tr>
</tbody>
</table>
</div>
</template>
</data>
</openerp>
Loading…
Cancel
Save