Skip to content
Permalink
Browse files

⚡️ new customization options

  • Loading branch information...
KolushovAlexandr committed Jul 1, 2019
1 parent cd75d67 commit fb8040fdedaa717cee84234f0190b1e0085d12ec
@@ -1,14 +1,14 @@
# Copyright 2016 Stanislav Krotov <https://it-projects.info/team/ufaks>
# Copyright 2017 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
{
"name": """Restrict out-of-stock POS Orders""",
"name": 'Restrict out-of-stock POS Orders',
'summary': 'Only supervisor can approve POS Order with out-of-stock product',
"category": "Point Of Sale",
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version={ODOO_BRANCH}",
# "live_test_url": "http://apps.it-projects.info/shop/product/DEMO-URL?version=11.0",
"images": [],
"version": "11.0.1.0.1",
"version": "11.0.1.1.0",
"application": False,

"author": "IT-Projects LLC, Ivan Yelizariev",
@@ -1,7 +1,9 @@
.. _changelog:
`1.1.0`
-------

Updates
=======
- **Fix:** Cashier was changed after giving the authorization of the sale
- **New:** Added option 'Ask Managers Permission to proceed order with negative stock products'
- **New:** Added option 'Show Warning on adding out of stock products'

`1.0.1`
-------
@@ -1,7 +1,7 @@
# Copyright 2016 Stanislav Krotov <https://it-projects.info/team/ufaks>
# Copyright 2016 manawi <https://github.com/manawi>
# Copyright 2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).

from odoo import models, fields, api


@@ -15,6 +15,14 @@ def _default_negative_stock_user(self):
negative_order_group_id = fields.Many2one(
'res.groups', string='Negative Order Group', default=_default_negative_stock_user,
help='Group allows to sell products which are out of a stock.')
negative_order_manager_permission = fields.Boolean(
"Managers Permission",
help="Ask Managers Permission to proceed order with negative stock products",
default=True)
negative_order_warning = fields.Boolean(
"Show Warning",
help="Show Warning on adding out of stock products",
default=False)


class PosOrder(models.Model):
@@ -27,5 +35,5 @@ class PosOrder(models.Model):
@api.model
def _order_fields(self, ui_order):
res = super(PosOrder, self)._order_fields(ui_order)
res['negative_stock_user_id'] = ui_order['negative_stock_user_id']
res['negative_stock_user_id'] = ui_order.get('negative_stock_user_id', False)
return res
@@ -1,5 +1,5 @@
/* Copyright 2016 Stanislav Krotov <https://it-projects.info/team/ufaks>
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html). */
odoo.define('pos_product_available_negative.pos', function (require) {
"use strict";
@@ -13,6 +13,9 @@ odoo.define('pos_product_available_negative.pos', function (require) {
validate_order: function(force_validation) {
var self = this;
var _super = this._super;
if (!this.pos.config.negative_order_manager_permission) {
return this._super(force_validation);
}
var order = this.pos.get_order();
var orderlines = order.get_orderlines();
var has_negative_product = false;
@@ -23,7 +26,8 @@ odoo.define('pos_product_available_negative.pos', function (require) {
self.gui.sudo_custom({
'title': _t('Order has out-of-stock product and must be approved by supervisor'),
'special_group': this.pos.config.negative_order_group_id[0],
'arguments': {'ask_untill_correct': true},
'do_not_change_cashier': true,
'product-imgarguments': {'ask_untill_correct': true},
}).done(function(user){
order.negative_stock_user_id = user;
_super.call(self, force_validation);
@@ -41,9 +45,34 @@ odoo.define('pos_product_available_negative.pos', function (require) {
models.Order = models.Order.extend({
export_as_JSON: function () {
var json = _super_order.export_as_JSON.apply(this, arguments);
json.negative_stock_user_id = this.negative_stock_user_id ? this.negative_stock_user_id.id : false;
json.negative_stock_user_id = this.negative_stock_user_id
? this.negative_stock_user_id.id
: false;
return json;
}
});

screens.ProductListWidget.include({
init: function(parent, options) {
var self = this;
this._super(parent,options);
if (!this.pos.config.negative_order_warning) {
return;
}

var click_product_handler_super = this.click_product_handler;
this.click_product_handler = function(){
var product = self.pos.db.get_product_by_id(this.dataset.productId);
if (product.type === 'product' && product.qty_available <= 0) {
var that = this;
return self.gui.show_popup('alert',{
'title': _t('The product is out of stock'),
'body': _t("It's unavailable to add the product"),
});
}
_.bind(click_product_handler_super, this)();
};
},
});

});
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--Copyright 2016 Stanislav Krotov <https://it-projects.info/team/ufaks>
Copyright 2018 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
Copyright 2018-2019 Kolushov Alexandr <https://it-projects.info/team/KolushovAlexandr>
License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).-->
<odoo>

@@ -9,12 +9,32 @@
<field name="model">pos.config</field>
<field name="inherit_id" ref="point_of_sale.pos_config_view_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='journal_ids']/../../.." position="before">
<div class="col-xs-12 col-md-6 o_setting_box" id="payment_methods">
<div class="o_setting_right_pane">
<label for="negative_order_group_id"/>
<div class="content-group mt16">
<field name="negative_order_group_id"/>
<xpath expr="//div[@id='inventory_location']" position="after">
<h2 name="order">Out of Stock Products</h2>
<div class="row mt16 o_settings_container">
<div class="col-xs-12 col-md-6 o_setting_box" id="negative_order_group_id">
<div class="o_setting_right_pane">
<label for="negative_order_group_id"/>
<div class="content-group mt16">
<field name="negative_order_group_id"/>
</div>
</div>
</div>

<div class="col-xs-12 col-md-6 o_setting_box" id="negative_order_manager_permission">
<div class="o_setting_left_pane">
<field name="negative_order_manager_permission"/>
</div>
<div class="o_setting_right_pane">
<label for="negative_order_manager_permission"/>
</div>
</div>
<div class="col-xs-12 col-md-6 o_setting_box" id="negative_order_warning">
<div class="o_setting_left_pane">
<field name="negative_order_warning"/>
</div>
<div class="o_setting_right_pane">
<label for="negative_order_warning"/>
</div>
</div>
</div>

0 comments on commit fb8040f

Please sign in to comment.
You can’t perform that action at this time.