diff --git a/warehouse_stock_restrictions/__init__.py b/warehouse_stock_restrictions/__init__.py new file mode 100644 index 0000000..8815323 --- /dev/null +++ b/warehouse_stock_restrictions/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +from . import stock \ No newline at end of file diff --git a/warehouse_stock_restrictions/__manifest__.py b/warehouse_stock_restrictions/__manifest__.py new file mode 100644 index 0000000..034cf1c --- /dev/null +++ b/warehouse_stock_restrictions/__manifest__.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Copyright © 2016 Techspawn Solutions. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': "Warehouse Restrictions", + + 'summary': """ + Warehouse restrictions on users, Stock Location Restrictions. This module will restrict warehouse/stock locations on users.""", + + 'description': """ + This Module Restricts the User from Accessing Warehouse and Process Stock Moves other than allowed to Warehouses and Stock Locations. + """, + + 'author': "Techspawn Solutions", + 'website': "http://www.techspawn.com", + 'license':'OPL-1', + 'category': 'Warehouse', + 'version': '0.2', + 'images': ['static/description/WarehouseRestrictions.gif'], + 'depends': ['base', 'stock'], + + 'data': [ + + 'users_view.xml', + 'security/security.xml', + # 'security/ir.model.access.csv', + ], + + +} diff --git a/warehouse_stock_restrictions/doc/index.rst b/warehouse_stock_restrictions/doc/index.rst new file mode 100755 index 0000000..14f4bf9 --- /dev/null +++ b/warehouse_stock_restrictions/doc/index.rst @@ -0,0 +1,15 @@ +Warehouse Restriction +======================== +- This module will add Warehouse and Stock Location Restriction on Users + +Installation +============ +- Install the module normally like other modules. + +Configuration +============= +- Add Default Warehouse Opertions and Allowed Stock Locations and you are ready to go. + +Note +==== +- This restrictions are created using rule and access rights, so it will have no effect on the Adminstrator. \ No newline at end of file diff --git a/warehouse_stock_restrictions/security/ir.model.access.csv b/warehouse_stock_restrictions/security/ir.model.access.csv new file mode 100644 index 0000000..1b79128 --- /dev/null +++ b/warehouse_stock_restrictions/security/ir.model.access.csv @@ -0,0 +1,4 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_stock_picking_type_restricted_user,access_stock_picking_type_restricted_user,stock.model_stock_picking_type,base.group_system,1,1,1,0 + + diff --git a/warehouse_stock_restrictions/security/security.xml b/warehouse_stock_restrictions/security/security.xml new file mode 100644 index 0000000..23a119b --- /dev/null +++ b/warehouse_stock_restrictions/security/security.xml @@ -0,0 +1,21 @@ + + + + + + Resrict Stock warehouses + + + + Filter Stock Picking Type Allowed new + + + [('id','in', [ p.id for p in user.default_picking_type_ids ])] + + + + + + + + \ No newline at end of file diff --git a/warehouse_stock_restrictions/static/description/Linkedin-icon.png b/warehouse_stock_restrictions/static/description/Linkedin-icon.png new file mode 100644 index 0000000..226367a Binary files /dev/null and b/warehouse_stock_restrictions/static/description/Linkedin-icon.png differ diff --git a/warehouse_stock_restrictions/static/description/WarehouseRestrictions.gif b/warehouse_stock_restrictions/static/description/WarehouseRestrictions.gif new file mode 100644 index 0000000..aa0feb3 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/WarehouseRestrictions.gif differ diff --git a/warehouse_stock_restrictions/static/description/WarehouseRestrictions.jpg b/warehouse_stock_restrictions/static/description/WarehouseRestrictions.jpg new file mode 100644 index 0000000..5d80460 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/WarehouseRestrictions.jpg differ diff --git a/warehouse_stock_restrictions/static/description/check.png b/warehouse_stock_restrictions/static/description/check.png new file mode 100644 index 0000000..d1f398e Binary files /dev/null and b/warehouse_stock_restrictions/static/description/check.png differ diff --git a/warehouse_stock_restrictions/static/description/facebook-icon.png b/warehouse_stock_restrictions/static/description/facebook-icon.png new file mode 100644 index 0000000..c737563 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/facebook-icon.png differ diff --git a/warehouse_stock_restrictions/static/description/features/check.png b/warehouse_stock_restrictions/static/description/features/check.png new file mode 100644 index 0000000..d1f398e Binary files /dev/null and b/warehouse_stock_restrictions/static/description/features/check.png differ diff --git a/warehouse_stock_restrictions/static/description/icon.png b/warehouse_stock_restrictions/static/description/icon.png new file mode 100644 index 0000000..2194ec1 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/icon.png differ diff --git a/warehouse_stock_restrictions/static/description/iconnew.png b/warehouse_stock_restrictions/static/description/iconnew.png new file mode 100644 index 0000000..b2b389d Binary files /dev/null and b/warehouse_stock_restrictions/static/description/iconnew.png differ diff --git a/warehouse_stock_restrictions/static/description/index.html b/warehouse_stock_restrictions/static/description/index.html new file mode 100644 index 0000000..5ca5b4b --- /dev/null +++ b/warehouse_stock_restrictions/static/description/index.html @@ -0,0 +1,551 @@ + +
+
+
+ + +
+ + + +
+
+
+
+ + +
+
+
+ +
+
+

+ Warehouse Restriction +

+

By Techspawn Solutions +

+ +

Warehouse and Stock Location Restriction on Users + +

+
+
+ +
+
+
+ +
+
+ + +
+ +
+
+
+
+
+ +
+
+

Restrict Warehouse operations for User

+
+
+
+
+
+
+ +
+
+

Restrict User to use specific Locations

+
+
+
+
+ +
+
+
+
+ +
+
+

Restrict the user to other warehouses

+
+
+
+
+
+
+ +
+
+

On selecting Restrict Location optionadmin can add allowed Stock Location for the User

+
+
+
+
+ + +
+ +
+ + +
+
+ +
+
+ + +
+
+ + + +
+

Contact & Support

+

Expert Ideas and ERP Solution To Help You Grow

+

+ Get expert help and assistance related to the new Odoo features and all ERP Related solutions at one place. + We offer solutions regardless the size of a business, contact us through e-mail at sales@techspawn.com + and get professional help that you want to build your business better. + In case of any question regarding please reach out to us on support@techspawn.com +

+
+
+
+
+
+
+
+ +
+
+ + +
+ +
+
diff --git a/warehouse_stock_restrictions/static/description/logo.png b/warehouse_stock_restrictions/static/description/logo.png new file mode 100644 index 0000000..80f30d5 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/logo.png differ diff --git a/warehouse_stock_restrictions/static/description/main.png b/warehouse_stock_restrictions/static/description/main.png new file mode 100644 index 0000000..5d80460 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/main.png differ diff --git a/warehouse_stock_restrictions/static/description/pr1.png b/warehouse_stock_restrictions/static/description/pr1.png new file mode 100644 index 0000000..bb26f33 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/pr1.png differ diff --git a/warehouse_stock_restrictions/static/description/pr2.png b/warehouse_stock_restrictions/static/description/pr2.png new file mode 100644 index 0000000..8c8a8d7 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/pr2.png differ diff --git a/warehouse_stock_restrictions/static/description/pr3.png b/warehouse_stock_restrictions/static/description/pr3.png new file mode 100644 index 0000000..c32090d Binary files /dev/null and b/warehouse_stock_restrictions/static/description/pr3.png differ diff --git a/warehouse_stock_restrictions/static/description/pr4.png b/warehouse_stock_restrictions/static/description/pr4.png new file mode 100644 index 0000000..7612f63 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/pr4.png differ diff --git a/warehouse_stock_restrictions/static/description/productimage/WearhouseRestrictions.gif b/warehouse_stock_restrictions/static/description/productimage/WearhouseRestrictions.gif new file mode 100644 index 0000000..aa0feb3 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/productimage/WearhouseRestrictions.gif differ diff --git a/warehouse_stock_restrictions/static/description/productimage/office365.gif b/warehouse_stock_restrictions/static/description/productimage/office365.gif new file mode 100644 index 0000000..72f39f5 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/productimage/office365.gif differ diff --git a/warehouse_stock_restrictions/static/description/productimage/productr.gif b/warehouse_stock_restrictions/static/description/productimage/productr.gif new file mode 100644 index 0000000..a0fcdd4 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/productimage/productr.gif differ diff --git a/warehouse_stock_restrictions/static/description/productimage/quickb.gif b/warehouse_stock_restrictions/static/description/productimage/quickb.gif new file mode 100644 index 0000000..4176d8d Binary files /dev/null and b/warehouse_stock_restrictions/static/description/productimage/quickb.gif differ diff --git a/warehouse_stock_restrictions/static/description/productimage/sale.gif b/warehouse_stock_restrictions/static/description/productimage/sale.gif new file mode 100644 index 0000000..c46178b Binary files /dev/null and b/warehouse_stock_restrictions/static/description/productimage/sale.gif differ diff --git a/warehouse_stock_restrictions/static/description/productimage/shopify.gif b/warehouse_stock_restrictions/static/description/productimage/shopify.gif new file mode 100644 index 0000000..d0532f7 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/productimage/shopify.gif differ diff --git a/warehouse_stock_restrictions/static/description/set_group.png b/warehouse_stock_restrictions/static/description/set_group.png new file mode 100644 index 0000000..950f217 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/set_group.png differ diff --git a/warehouse_stock_restrictions/static/description/skype.png b/warehouse_stock_restrictions/static/description/skype.png new file mode 100644 index 0000000..f5ba7c1 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/skype.png differ diff --git a/warehouse_stock_restrictions/static/description/user1.png b/warehouse_stock_restrictions/static/description/user1.png new file mode 100644 index 0000000..af0a700 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/user1.png differ diff --git a/warehouse_stock_restrictions/static/description/user2.png b/warehouse_stock_restrictions/static/description/user2.png new file mode 100644 index 0000000..7ab2e55 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/user2.png differ diff --git a/warehouse_stock_restrictions/static/description/user3.png b/warehouse_stock_restrictions/static/description/user3.png new file mode 100644 index 0000000..fe51c1e Binary files /dev/null and b/warehouse_stock_restrictions/static/description/user3.png differ diff --git a/warehouse_stock_restrictions/static/description/user4.png b/warehouse_stock_restrictions/static/description/user4.png new file mode 100644 index 0000000..a96f01b Binary files /dev/null and b/warehouse_stock_restrictions/static/description/user4.png differ diff --git a/warehouse_stock_restrictions/static/description/user5.png b/warehouse_stock_restrictions/static/description/user5.png new file mode 100644 index 0000000..bd19afd Binary files /dev/null and b/warehouse_stock_restrictions/static/description/user5.png differ diff --git a/warehouse_stock_restrictions/static/description/user6.png b/warehouse_stock_restrictions/static/description/user6.png new file mode 100644 index 0000000..ba07ebf Binary files /dev/null and b/warehouse_stock_restrictions/static/description/user6.png differ diff --git a/warehouse_stock_restrictions/static/description/warehouse.png b/warehouse_stock_restrictions/static/description/warehouse.png new file mode 100644 index 0000000..ce7aeb0 Binary files /dev/null and b/warehouse_stock_restrictions/static/description/warehouse.png differ diff --git a/warehouse_stock_restrictions/static/description/warehouse0.png b/warehouse_stock_restrictions/static/description/warehouse0.png new file mode 100644 index 0000000..dc31c7d Binary files /dev/null and b/warehouse_stock_restrictions/static/description/warehouse0.png differ diff --git a/warehouse_stock_restrictions/static/description/warehouse1.png b/warehouse_stock_restrictions/static/description/warehouse1.png new file mode 100644 index 0000000..ad1810f Binary files /dev/null and b/warehouse_stock_restrictions/static/description/warehouse1.png differ diff --git a/warehouse_stock_restrictions/static/description/warehouse2.png b/warehouse_stock_restrictions/static/description/warehouse2.png new file mode 100644 index 0000000..20e143f Binary files /dev/null and b/warehouse_stock_restrictions/static/description/warehouse2.png differ diff --git a/warehouse_stock_restrictions/stock.py b/warehouse_stock_restrictions/stock.py new file mode 100644 index 0000000..69d0a0a --- /dev/null +++ b/warehouse_stock_restrictions/stock.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +from openerp import models, fields, api, _ +from openerp.exceptions import Warning + +class ResUsers(models.Model): + _inherit = 'res.users' + + restrict_locations = fields.Boolean('Restrict Location') + + stock_location_ids = fields.Many2many( + 'stock.location', + 'location_security_stock_location_users', + 'user_id', + 'location_id', + 'Stock Locations') + + default_picking_type_ids = fields.Many2many( + 'stock.picking.type', 'stock_picking_type_users_rel', + 'user_id', 'picking_type_id', string='Default Warehouse Operations') + + +class stock_move(models.Model): + _inherit = 'stock.move' + + @api.one + @api.constrains('state', 'location_id', 'location_dest_id') + def check_user_location_rights(self): + if self.state == 'draft': + return True + user_locations = self.env.user.stock_location_ids + print(user_locations) + print("Checking access %s" %self.env.user.default_picking_type_ids) + if self.env.user.restrict_locations: + message = _( + 'Invalid Location. You cannot process this move since you do ' + 'not control the location "%s". ' + 'Please contact your Adminstrator.') + if self.location_id not in user_locations: + raise Warning(message % self.location_id.name) + elif self.location_dest_id not in user_locations: + raise Warning(message % self.location_dest_id.name) + + diff --git a/warehouse_stock_restrictions/users_view.xml b/warehouse_stock_restrictions/users_view.xml new file mode 100644 index 0000000..52590b0 --- /dev/null +++ b/warehouse_stock_restrictions/users_view.xml @@ -0,0 +1,35 @@ + + + + + usability.default_warehouse.res.users.form + res.users + + + + + + + + + + + + location_security.users.form + res.users + + + + + + + + + + + + + + + +