Browse Source

[ADD] Initial Commit

pull/81/head
SHEREEF PT 8 years ago
parent
commit
ad93a33afb
  1. 36
      pos_sales_orders/README.rst
  2. 23
      pos_sales_orders/__init__.py
  3. 39
      pos_sales_orders/__openerp__.py
  4. 24
      pos_sales_orders/models/__init__.py
  5. 36
      pos_sales_orders/models/models.py
  6. BIN
      pos_sales_orders/static/description/banner.jpg
  7. BIN
      pos_sales_orders/static/description/cybro_logo.png
  8. BIN
      pos_sales_orders/static/description/icon.png
  9. 90
      pos_sales_orders/static/description/index.html
  10. BIN
      pos_sales_orders/static/description/pos_so_01.png
  11. BIN
      pos_sales_orders/static/description/pos_so_02.png
  12. BIN
      pos_sales_orders/static/description/pos_so_03.png
  13. BIN
      pos_sales_orders/static/description/pos_so_04.png
  14. BIN
      pos_sales_orders/static/description/pos_so_05.png
  15. BIN
      pos_sales_orders/static/description/pos_so_06.png
  16. 45
      pos_sales_orders/static/src/css/pos_so.css
  17. 151
      pos_sales_orders/static/src/js/pos_so.js
  18. 53
      pos_sales_orders/static/src/xml/pos_so.xml
  19. 11
      pos_sales_orders/views/pos_so_templates.xml
  20. 15
      pos_sales_orders/views/so_pos_ref.xml

36
pos_sales_orders/README.rst

@ -0,0 +1,36 @@
======================
Sale Order From POS V9
======================
This module allow to create Sale Orders from POS.
Installation
============
Just select it from available modules to install it, there is no need to extra installations.
Configuration
=============
Nothing to configure.
Features
========
* 'Create Sale Order' button in POS.
* Create sale orders directly from POS.
Usage
=====
* We cannot create sale order if there is no customer selected or no order lines added.
* Otherwise it will raise an alert popup with invalid order line/ invalid customer.
* On confirming SO creation with invalid order date, display an error message.
* On confirming Order Creation, create quotation with order lines and it shows popup with sale order reference.
Credits
=======
Developer: Aswani pc @ cybrosys

23
pos_sales_orders/__init__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Aswani P C(<https://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 . import models

39
pos_sales_orders/__openerp__.py

@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Aswani P C(<https://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': "Sale Order From POS",
'version': '9.0.1.0.0',
'summary': """Sale Orders From POS""",
'description': """This module allows to create sale orders from POS.""",
'author': "Cybrosys Techno Solutions",
'company': "Cybrosys Techno Solutions",
'website': "https://www.cybrosys.com",
'category': 'Point of Sale',
'depends': ['base', 'point_of_sale'],
'data': ['views/pos_so_templates.xml', 'views/so_pos_ref.xml'],
'qweb': ['static/src/xml/pos_so.xml'],
'images': ['static/description/banner.jpg'],
'license': 'AGPL-3',
'installable': True,
'auto_install': False,
}

24
pos_sales_orders/models/__init__.py

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Aswani P C(<https://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 . import models

36
pos_sales_orders/models/models.py

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
# Copyright (C) 2015-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Aswani P C(<https://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 PosSaleOrder(models.Model):
_inherit = 'sale.order'
from_pos = fields.Boolean(string="Created From POS", default=False)
def create_from_ui(self, cr, uid, orders, context=None):
order_id = self.create(cr, uid, orders, context=context)
order_ref = self.browse(cr, uid, order_id, context=context).name
return order_ref

BIN
pos_sales_orders/static/description/banner.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

BIN
pos_sales_orders/static/description/cybro_logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
pos_sales_orders/static/description/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

90
pos_sales_orders/static/description/index.html

@ -0,0 +1,90 @@
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h2 class="oe_slogan">Sale Order From POS</h2>
<h3 class="oe_slogan">Create Sale Orders from POS</h3>
<h4 class="oe_slogan"><a href="https://www.cybrosys.com">Cybrosys Technologies</a></h4>
<div>
<h4><p>Features</p></h4>
<div>
<span style="color:green;"> &#9745; </span>'Create Sale Order' button in POS.<br/>
<span style="color:green;"> &#9745; </span>Create sale orders directly from POS.<br/>
</div>
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<div class="oe_demo oe_picture oe_screenshot">
<img src="pos_so_01.png">
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<p>We cannot create sale order if there is no customer selected or no order lines added. Otherwise it will raise an alert popup with invalid order line/ invalid customer.</p>
<div class="oe_demo oe_picture oe_screenshot">
<img src="pos_so_02.png">
</div>
<div class="oe_demo oe_picture oe_screenshot">
<img src="pos_so_03.png">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Order Creation popup with confirm button & order date</h3>
<p>On Confirming Order Creation, create Quotation with orderlines and it shows popup with sale order reference.</p>
<div class="oe_demo oe_picture oe_screenshot">
<img src="pos_so_04.png">
</div>
</div>
</section>
<section class="oe_container oe_dark">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Sale Order Reference</h3>
<div class="oe_demo oe_picture oe_screenshot">
<img src="pos_so_05.png">
</div>
</div>
</section>
<section class="oe_container">
<div class="oe_row oe_spaced">
<h3 class="oe_slogan">Created Sale Order</h3>
<div class="oe_demo oe_picture oe_screenshot">
<img src="pos_so_06.png">
</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;">
<div>
<a class="btn btn-primary btn-lg mt8"
style="color: #FFFFFF !important;border-radius: 0;" href="https://www.cybrosys.com"><i
class="fa fa-envelope"></i> Email </a> <a
class="btn btn-primary btn-lg mt8" style="color: #FFFFFF !important;border-radius: 0;"
href="https://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;border-radius: 0;"
href="https://www.cybrosys.com/odoo-customization-and-installation/"><i
class="fa fa-check-square"></i> Request Customization </a>
</div>
<br>
<img src="cybro_logo.png" style="width: 190px; margin-bottom: 20px;" class="center-block">
<div>
<a href="https://twitter.com/cybrosys" target="_blank"><i class="fa fa-2x fa-twitter" style="color:white;background: #00a0d1;width:35px;"></i></a></td>
<a href="https://www.linkedin.com/company/cybrosys-technologies-pvt-ltd" target="_blank"><i class="fa fa-2x fa-linkedin" style="color:white;background: #31a3d6;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://www.facebook.com/cybrosystechnologies" target="_blank"><i class="fa fa-2x fa-facebook" style="color:white;background: #3b5998;width:35px;padding-left: 8px;"></i></a></td>
<a href="https://plus.google.com/106641282743045431892/about" target="_blank"><i class="fa fa-2x fa-google-plus" style="color:white;background: #c53c2c;width:35px;padding-left: 3px;"></i></a></td>
<a href="https://in.pinterest.com/cybrosys" target="_blank"><i class="fa fa-2x fa-pinterest" style="color:white;background: #ac0f18;width:35px;padding-left: 3px;"></i></a></td>
</div>
</div>
</section>

BIN
pos_sales_orders/static/description/pos_so_01.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

BIN
pos_sales_orders/static/description/pos_so_02.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 KiB

BIN
pos_sales_orders/static/description/pos_so_03.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

BIN
pos_sales_orders/static/description/pos_so_04.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

BIN
pos_sales_orders/static/description/pos_so_05.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 KiB

BIN
pos_sales_orders/static/description/pos_so_06.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

45
pos_sales_orders/static/src/css/pos_so.css

@ -0,0 +1,45 @@
.sale_order_button {
display: inline-block;
margin-left:5px;
width: 405px;
height: 40px;
text-align: center;
color: #555555;
border-color: #bfbfbf;
}
.sale_order_button p {
position: absolute;
left: 80px;
top: 0px;
}
.pos-so-cart{
position: absolute;
left: 30px;
top: 13px;
margin-right: 8px;
font-size: 18px;
background: rgba(255, 255, 255, 0.5);
line-height: 30px;
width: 30px;
border-radius: 100%;
}
.sale_order_button:hover {
background: #efefef;
}
.sale_order_button:active {
background: black;
border-color: black;
color: white;
}
.alert_msg{
color:red;
}
.popup_so_ref{
height: 150px !important;
}

151
pos_sales_orders/static/src/js/pos_so.js

@ -0,0 +1,151 @@
odoo.define('point_of_sale.pos_sales_orders', function (require) {
"use strict";
var screens = require('point_of_sale.screens');
var gui = require('point_of_sale.gui');
var Model = require('web.DataModel');
var core = require('web.core');
var PopupWidget = require('point_of_sale.popups');
var ProductListWidget = screens.ProductListWidget;
var QWeb = core.qweb;
var _t = core._t;
var SaleOrderButton = screens.ActionButtonWidget.extend({
template: 'SaleOrderButton',
button_click: function(){
var order_lines = this.pos.get_order().get_orderlines();
var flag_negative = false;
for (var line in order_lines){
if (order_lines[line].quantity < 0){
flag_negative = true;
}
}
if(this.pos.get_order().get_orderlines().length > 0 && this.pos.get_client() && flag_negative == false && this.pos.get_order().get_total_with_tax()>0){
this.gui.show_popup('pos_so');
}
else if(flag_negative == true){
this.gui.show_popup('alert',{
'title': _t('Alert: Invalid Order'),
'body': _t('Negative Quantity is Not Allowed'),
});
}
else if(this.pos.get_order().get_orderlines().length == 0 || this.pos.get_order().get_total_with_tax() <=0){
this.gui.show_popup('alert',{
'title': _t('Alert: Invalid Order'),
'body': _t('Please Add Some Order Lines'),
});
}
else{
this.gui.show_popup('alert',{
'title': _t('Alert: Invalid Customer'),
'body': _t('Please Select Customer'),
});
}
},
});
screens.define_action_button({
'name': 'pos_sale_order',
'widget': SaleOrderButton,
});
var SaleOrderPopupWidget = PopupWidget.extend({
template: 'SaleOrderPopupWidget',
events: _.extend({}, PopupWidget.prototype.events,{
"keyup .order_date" : "date_validate",
}),
show: function(options){
options = options || {};
var self = this;
this._super(options);
this.renderElement();
},
date_validate: function(){
var v = $(".order_date").val();
if (v.match(/^\d{4}$/) !== null) {
$(".order_date").val(v + '/');
}
else if (v.match(/^\d{4}\/\d{2}$/) !== null) {
$(".order_date").val(v + '/');
}
},
click_confirm: function(){
var self = this;
var sale_order = {};
var today = new Date().toJSON().slice(0,10);
var order = this.pos.get_order();
var order_lines = this.pos.get_order().get_orderlines();
var order_date = this.$('.order_date').val();
var valid_date = true;
var validatePattern = /^(\d{4})([/|-])(\d{1,2})([/|-])(\d{1,2})$/;
if (order_date){
var dateValues = order_date.match(validatePattern);
if (dateValues == null){
valid_date = false;
}
else{
var orderYear = dateValues[1];
var orderMonth = dateValues[3];
var orderDate = dateValues[5];
if ((orderMonth < 1) || (orderMonth > 12)) {
valid_date = false;
}
else if ((orderDate < 1) || (orderDate> 31)) {
valid_date = false;
}
else if ((orderMonth==4 || orderMonth==6 || orderMonth==9 || orderMonth==11) && orderDate ==31) {
valid_date = false;
}
else if (orderMonth == 2){
var isleap = (orderYear % 4 == 0 && (orderYear % 100 != 0 || orderYear % 400 == 0));
if (orderDate> 29 || (orderDate ==29 && !isleap)){
valid_date = false;
}
}
var dates = [orderYear,orderMonth,orderDate];
order_date = dates.join('-');
}
}
sale_order.order_line = [];
$('.alert_msg').text("");
if (order_date && order_date < today || valid_date==false){
$('.alert_msg').text("Please Select Valid Order Date!");
}
else{
$('.alert_msg').text("");
for (var line in order_lines){
if (order_lines[line].quantity>0)
{
var sale_order_line = [0,false,{product_id:null,product_uom_qty:0}]
sale_order_line[2].product_id = order_lines[line].product.id;
sale_order_line[2].product_uom_qty = order_lines[line].quantity;
sale_order.order_line.push(sale_order_line);
}
}
sale_order.partner_id = this.pos.get_client().id;
if (order_date){
sale_order.validity_date = order_date;
}
sale_order.from_pos = true;
var saleOrderModel = new Model('sale.order');
saleOrderModel.call('create_from_ui',[sale_order]).then(function(order_ref){
self.gui.close_popup();
self.pos.delete_current_order();
self.gui.show_popup('pos_so_ref',{
'body': _t('Sale Order Ref : ')+ order_ref ,
});
});
}
}
});
gui.define_popup({name:'pos_so', widget: SaleOrderPopupWidget});
var SaleRefPopupWidget = PopupWidget.extend({
template: 'SaleRefPopupWidget',
});
gui.define_popup({name:'pos_so_ref', widget: SaleRefPopupWidget});
});

53
pos_sales_orders/static/src/xml/pos_so.xml

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8"?>
<template id="template" xml:space="preserve">
<t t-name="SaleOrderButton">
<div class="row">
<button class="sale_order_button">
<i class="fa fa-shopping-cart pos-so-cart"/>
<p>Create Sale Order</p>
</button>
</div>
</t>
<t t-name="SaleOrderPopupWidget">
<div class="modal-dialog">
<div class="popup popup-sale-order">
<p class="title"><t t-esc=" widget.options.title || 'Create Sale Order' " /></p>
<p class="body">Select Delivery Date
<br/>
<br/>
<input type="text" name="order_date" class="order_date" placeholder="yyyy/mm/dd" maxlength="10"/>
<br/>
<br/>
<span class="alert_msg"/>
</p>
<div class="footer">
<div class="button confirm">
Create Order
</div>
<div class="button cancel">
Close
</div>
</div>
</div>
</div>
</t>
<t t-name="SaleRefPopupWidget">
<div class="modal-dialog">
<div class="popup popup_so_ref">
<p class="body"><t t-esc="widget.options.body || '' "/></p>
<div class="footer">
<div class="button cancel">
OK
</div>
</div>
</div>
</div>
</t>
</template>

11
pos_sales_orders/views/pos_so_templates.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<template id="pos_sale_order_template" inherit_id="point_of_sale.assets">
<xpath expr="." position="inside">
<link rel="stylesheet" href="/pos_sales_orders/static/src/css/pos_so.css" />
<script type="text/javascript" src="/pos_sales_orders/static/src/js/pos_so.js"/>
</xpath>
</template>
</data>
</openerp>

15
pos_sales_orders/views/so_pos_ref.xml

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="sale_order_pos_view_form" model="ir.ui.view">
<field name="name">sale.order.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale.view_order_form"/>
<field name="arch" type="xml">
<field name="validity_date" position="before">
<field name="from_pos" readonly="1"/>
</field>
</field>
</record>
</data>
</openerp>
Loading…
Cancel
Save