Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pos_cash_deposit/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import model
22 changes: 22 additions & 0 deletions pos_cash_deposit/__openerp__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# © 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
'name': "POS Cash Deposit",

'summary': """Cash deposit inside the POS""",
'author': 'ACSONE SA/NV,'
'Odoo Community Association (OCA)',
'website': "http://acsone.eu",
'category': 'Point Of Sale',
'version': '8.0.1.0.0',
'license': 'AGPL-3',
'depends': [
'point_of_sale',
],
'data': [
"view/pos_cash_deposit.xml",
"data/pos_cash_deposit_product.xml",
],
'qweb': ['static/src/xml/pos_cash_deposit.xml'],
}
13 changes: 13 additions & 0 deletions pos_cash_deposit/data/pos_cash_deposit_product.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<record id="pos_cash_deposit_product" model="product.product">
<field name="name">Cash Deposit</field>
<field name="categ_id" ref="product.product_category_all"/>
<field name="type">consu</field>
<field name="sale_ok" eval="0"/>
<field name="purchase_ok" eval="0"/>
<field name="available_in_pos" eval="1"/>
</record>
</data>
</openerp>
5 changes: 5 additions & 0 deletions pos_cash_deposit/model/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# © 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import pos_order
96 changes: 96 additions & 0 deletions pos_cash_deposit/model/pos_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# -*- coding: utf-8 -*-
# © 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp import models, api
import logging

logger = logging.getLogger(__name__)


class pos_order(models.Model):
_inherit = 'pos.order'

@api.multi
def _reconcile_move_account_product(self, move_id, account_id, product_id):
if move_id and account_id and product_id:
move_line_obj = self.env['account.move.line']
move_line_ids = move_line_obj.search([('move_id', '=', move_id),
('account_id', '=',
account_id),
('product_id', '=',
product_id)])
if move_line_ids:
try:
move_line_ids.reconcile(type='manual',
writeoff_acc_id=False,
writeoff_period_id=False,
writeoff_journal_id=False)
except Exception as e:
logger.warning(
'Impossible to reconcile cash deposit items ' + str(e))
return True

@api.multi
def _create_account_move_line(self, session=None, move_id=None):
res = super(pos_order, self)\
._create_account_move_line(session=session, move_id=move_id)
account_move_line_obj = self.env['account.move.line']
cash_deposit_product =\
self.env.ref('pos_cash_deposit.pos_cash_deposit_product')
income_account = False
if cash_deposit_product.property_account_income.id:
income_account = cash_deposit_product\
.property_account_income.id
elif cash_deposit_product.categ_id.property_account_income_categ.id:
income_account = cash_deposit_product.categ_id\
.property_account_income_categ.id
for order in self:
if move_id is None:
move_id = order.move_id.id
for line in order.lines:
if line.product_id.id == cash_deposit_product.id:
name = line.product_id.name
amount = line.price_subtotal
sale_journal_id = order.sale_journal.id
current_company = order.sale_journal.company_id
period = self.env['account.period']\
.with_context(company_id=current_company.id).find()[0]
if line.notice:
name = name + ' (' + line.notice + ')'
partner = order.partner_id and \
self.pool.get("res.partner").\
_find_accounting_partner(order.partner_id) or False
default_values = {
'name': name,
'quantity': line.qty,
'product_id': line.product_id.id,
'tax_code_id': False,
'tax_amount': False,
'date': order.date_order[:10],
'ref': order.name,
'partner_id': partner.id,
'journal_id': sale_journal_id,
'period_id': period.id,
'move_id': move_id,
'company_id': current_company.id,
}
transfert_account_move_values = {
'account_id': income_account,
'credit': ((amount < 0) and - amount) or 0.0,
'debit': ((amount > 0) and amount) or 0.0,
}
transfert_account_move_values.update(default_values)
account_move_line_obj\
.create(transfert_account_move_values)
receivable_account_move_values = {
'account_id': partner.property_account_receivable.id,
'credit': ((amount > 0) and amount) or 0.0,
'debit': ((amount < 0) and - amount) or 0.0,
}
receivable_account_move_values.update(default_values)
account_move_line_obj\
.create(receivable_account_move_values)
self._reconcile_move_account_product(move_id, income_account,
cash_deposit_product.id)
return res
Binary file added pos_cash_deposit/static/src/img/close-customer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions pos_cash_deposit/static/src/js/pos_cash_deposit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
openerp.pos_cash_deposit = function (instance) {
var module = instance.point_of_sale;
pos_cash_deposit_models(instance, module);
pos_cash_deposit_db(instance, module);
pos_cash_deposit_widgets(instance, module);
pos_cash_deposit_screens(instance, module);
};
30 changes: 30 additions & 0 deletions pos_cash_deposit/static/src/js/pos_cash_deposit_db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function pos_cash_deposit_db(instance, module) { //module is instance.point_of_sale
var QWeb = instance.web.qweb;
var _t = instance.web._t;

module.PosDB = module.PosDB.extend({
init: function (options) {
options = options || {};
this._super(options);
var self = this
this.cash_deposit_id = false;
this.cash_deposit_product = false;
new instance.web.Model('ir.model.data').call('get_object_reference', [ 'pos_cash_deposit', 'pos_cash_deposit_product' ]).then(function (ids) {
self.cash_deposit_id = ids[1]
return new instance.web.Model('product.product').query([ 'name', 'list_price', 'price',
'pos_categ_id', 'taxes_id', 'ean13', 'default_code', 'variants', 'to_weight', 'uom_id',
'uos_id', 'uos_coeff', 'mes_type', 'description_sale', 'description', 'product_tmpl_id',
'active' ]).filter([
[ 'id', '=', self.cash_deposit_id ],
[ 'active', '>=', 0 ]
]).context(null).all().then(function (products) {
self.cash_deposit_product = products[0]
}, function (err, event) {
event.preventDefault();
});
},function (err, event) {
event.preventDefault();
});
},
});
}
19 changes: 19 additions & 0 deletions pos_cash_deposit/static/src/js/pos_cash_deposit_models.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function pos_cash_deposit_models(instance, module) { //module is instance.point_of_sale
var QWeb = instance.web.qweb;
var _t = instance.web._t;

var _super_initialize = module.Orderline.prototype.initialize;
var _super_export_as_JSON = module.Orderline.prototype.export_as_JSON;
var _super_addProduct = module.Order.prototype.addProduct;

module.Orderline.prototype.export_as_JSON = function () {
res = _super_export_as_JSON.call(this);
res.notice = this.notice;
return res;
};

module.Orderline.prototype.initialize = function (attr, options) {
this.notice = options.notice;
_super_initialize.call(this, attr, options);
};
}
48 changes: 48 additions & 0 deletions pos_cash_deposit/static/src/js/pos_cash_deposit_screen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
function pos_cash_deposit_screens(instance, module) {
var QWeb = instance.web.qweb;
var _t = instance.web._t;


module.PaymentScreenWidget.include({
validate_order: function (options) {
options = options || {};
var parent = this
var order = this.pos.get('selectedOrder');
var orderLines = order.get('orderLines').models;
var trouve = false;
for (var index in orderLines) {
if (orderLines.hasOwnProperty(index)) {
if (orderLines[index].product.id == this.pos.db.cash_deposit_id) {
options['invoice'] = false;
continue;
}
}
}
this._super(options);
},
is_cash_deposit: function(){
var self = this;
var currentOrder = self.pos.get('selectedOrder');
var orderlines = currentOrder.get('orderLines');
is_cash_deposit = false;
for (i=0; i < orderlines.length && !is_cash_deposit; i++) {
if (orderlines.models[i].product.id == self.pos.db.cash_deposit_id) {
is_cash_deposit = true;
}
}
return is_cash_deposit
},
show: function () {
this._super();
this.pos_widget.action_bar.set_button_disabled('invoice', this.is_cash_deposit());
},
update_payment_summary: function () {
this._super();
var self = this
if (this.pos_widget.action_bar) {
self.pos_widget.action_bar.set_button_disabled('invoice', this.is_cash_deposit());
}
},
});

}
85 changes: 85 additions & 0 deletions pos_cash_deposit/static/src/js/pos_cash_deposit_widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
function pos_cash_deposit_widgets(instance, module) {
var QWeb = instance.web.qweb;
var _t = instance.web._t;

module.PosWidget = module.PosWidget.extend({
build_widgets: function () {
this._super();
this.cash_deposit_popup = new module.CashDepositPopupWidget(this, {});
this.cash_deposit_popup.appendTo(this.$el);
this.cash_deposit_popup.hide();
},
});

module.ProductCategoriesWidget.include({

init: function (parent, options) {
this._super(parent, options);
},

renderElement: function () {
var self = this;
this._super();
$('#cash_deposit').click(function () {
var currentOrder = self.pos.get('selectedOrder');
var cid = currentOrder.get_client() ? currentOrder.get_client().id : 0;
if (cid != null && cid != 0) {
self.pos_widget.screen_selector.current_popup = self.pos_widget.cash_deposit_popup;
self.pos_widget.screen_selector.current_popup.show();
} else {
self.pos_widget.screen_selector.show_popup('error', {
message: _t('You must select a customer in the order tab first !'),
});
}
});
}
});

module.CashDepositPopupWidget = module.PopUpWidget.extend({
template: 'CashDepositPopupWidget',
show: function () {
this._super();
this.renderElement();
var self = this;
self.pos_widget.order_widget.disable_numpad()
this.$('.apply-button').off('click').click(function () {
var amount = $("#amount_deposit", this.$el).val();
amount = amount.replace(',', '.');
amount = parseFloat(amount);
if (isNaN(amount)) {
alert('Please Enter A Correct Amount Number');
} else {
var message = $("#message_deposit", this.$el).val();
self.pos_widget.screen_selector.close_popup();
self.create_cash_deposit(message, amount);
}
});
this.$('.close-button').off('click').click(function () {
self.pos_widget.screen_selector.close_popup();
});
},

hide: function () {
this._super();
var self = this;
self.pos_widget.order_widget.enable_numpad()
},

create_cash_deposit: function (message, amount) {
var self = this;
product = jQuery.extend({}, self.pos.db.cash_deposit_product)
product.price = amount;
product.display_name = _t(product.name) + ' : ' + message;
order = self.pos.get('selectedOrder');
var line = new module.Orderline({}, {
pos: order.pos,
order: order,
product: product,
notice: message
});
var orderLines = order.get('orderLines').models;
order.get('orderLines').add(line);
order.selectLine(order.getLastOrderline());
}
});
}
31 changes: 31 additions & 0 deletions pos_cash_deposit/static/src/xml/pos_cash_deposit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- vim:fdl=1: -->
<templates>

<!-- ACSONE - ADRIEN PEIFFER -->

<t t-extend="PosWidget" t-operation="replace">
<t t-jquery=".order-selector" t-operation="append">
<span id="cash_deposit" class="order-button">Cash Deposit</span>
</t>
</t>
<t t-name="CashDepositPopupWidget">
<div class="modal-dialog">
<div class="popup">
<p class="message">Cash Deposit</p>
Message : <input id="message_deposit" type="text"></input>
<br />
Amount : <input id="amount_deposit" type="text"></input>
<div class="footer">
<div class="button apply-button">
Apply
</div>
<div class="button close-button">
Close
</div>
</div>
</div>
</div>
</t>

</templates>
15 changes: 15 additions & 0 deletions pos_cash_deposit/view/pos_cash_deposit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- Include JS file for the custom view to select domain from filters -->
<template id="assets_backend" name="filter_selection" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/pos_cash_deposit/static/src/js/pos_cash_deposit.js"></script>
<script type="text/javascript" src="/pos_cash_deposit/static/src/js/pos_cash_deposit_models.js"></script>
<script type="text/javascript" src="/pos_cash_deposit/static/src/js/pos_cash_deposit_widget.js"></script>
<script type="text/javascript" src="/pos_cash_deposit/static/src/js/pos_cash_deposit_screen.js"></script>
<script type="text/javascript" src="/pos_cash_deposit/static/src/js/pos_cash_deposit_db.js"></script>
</xpath>
</template>
</data>
</openerp>
3 changes: 3 additions & 0 deletions pos_pay_invoice/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# © 2015 ACSONE SA/NV (<http://acsone.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
Loading