diff --git a/pos_mrp_order/README.rst b/pos_mrp_order/README.rst new file mode 100644 index 000000000..5ce2ef0da --- /dev/null +++ b/pos_mrp_order/README.rst @@ -0,0 +1,13 @@ +Make MRP orders from POS v10 +============================ +From the POS sale we need to generate MRP orders in the back end with out close the current window. + +Features +======== + +* Automatically create MRP order form POS sale. +* We can assign which products make MRP order Automatically. + +Credits +======= +Nikhil Krishnan @ cybrosys, nikhil@cybrosys.in \ No newline at end of file diff --git a/pos_mrp_order/__init__.py b/pos_mrp_order/__init__.py new file mode 100644 index 000000000..db6e2e68e --- /dev/null +++ b/pos_mrp_order/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan() +# 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 . +# +############################################################################## + +import models diff --git a/pos_mrp_order/__manifest__.py b/pos_mrp_order/__manifest__.py new file mode 100644 index 000000000..c7fd3993c --- /dev/null +++ b/pos_mrp_order/__manifest__.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan() +# 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 . +# +############################################################################## + +{ + 'name': 'Make MRP orders from POS', + 'version': '10.0.1.0.0', + 'summary': """Launch Automatic MRP Orders After Selling Through POS.""", + 'description': """Launch automatic MRP orders after selling through POS""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'http://www.cybrosys.com', + 'category': 'Sales Management', + 'depends': ['point_of_sale', 'mrp', 'stock'], + 'license': 'LGPL-3', + 'data': [ + 'security/ir.model.access.csv', + 'views/product_view.xml', + 'views/pos_template.xml', + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'installable': True, + 'auto_install': False, +} diff --git a/pos_mrp_order/models/__init__.py b/pos_mrp_order/models/__init__.py new file mode 100644 index 000000000..1bdbc390c --- /dev/null +++ b/pos_mrp_order/models/__init__.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan() +# 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 . +# +############################################################################## + +import point_of_sale_make_mrp + diff --git a/pos_mrp_order/models/point_of_sale_make_mrp.py b/pos_mrp_order/models/point_of_sale_make_mrp.py new file mode 100644 index 000000000..69af27c59 --- /dev/null +++ b/pos_mrp_order/models/point_of_sale_make_mrp.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan() +# 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 . +# +############################################################################## + +from odoo import models, fields, api +from odoo.exceptions import Warning + + +class MrpProduction(models.Model): + _inherit = 'mrp.production' + + @api.multi + def create_mrp_from_pos(self, products): + product_ids = [] + print "products", products + if products: + for product in products: + flag = 1 + if product_ids: + for product_id in product_ids: + if product_id['id'] == product['id']: + product_id['qty'] += product['qty'] + flag = 0 + if flag: + product_ids.append(product) + for prod in product_ids: + if prod['qty'] > 0: + product = self.env['product.product'].search([('id', '=', prod['id'])]) + bom_count = self.env['mrp.bom'].search([('product_tmpl_id', '=', prod['product_tmpl_id'])]) + if bom_count: + bom_temp = self.env['mrp.bom'].search([('product_tmpl_id', '=', prod['product_tmpl_id']), + ('product_id', '=', False)]) + bom_prod = self.env['mrp.bom'].search([('product_id', '=', prod['id'])]) + if bom_prod: + bom = bom_prod[0] + elif bom_temp: + bom = bom_temp[0] + else: + bom = [] + print "This product variants have no exact BOM" + if bom: + vals = { + 'origin': 'POS-' + prod['pos_reference'], + 'state': 'confirmed', + 'product_id': prod['id'], + 'product_tmpl_id': prod['product_tmpl_id'], + 'product_uom_id': prod['uom_id'], + 'product_qty': prod['qty'], + 'bom_id': bom.id, + } + self.sudo().create(vals) + return True + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + to_make_mrp = fields.Boolean(string='To Create MRP Order', + help="Check if the product should be make mrp order") + + @api.onchange('to_make_mrp') + def onchange_to_make_mrp(self): + if self.to_make_mrp: + if not self.bom_temp: + raise Warning('Please set Bill of Material for this product.') diff --git a/pos_mrp_order/security/ir.model.access.csv b/pos_mrp_order/security/ir.model.access.csv new file mode 100644 index 000000000..db938e13a --- /dev/null +++ b/pos_mrp_order/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_mrp_production_pos_user,mrp.production.pos.user,mrp.model_mrp_production,point_of_sale.group_pos_user,1,1,1,0 +access_mrp_bom_pos_user,mrp.bom.pos.user,mrp.model_mrp_bom,point_of_sale.group_pos_user,1,0,0,0 \ No newline at end of file diff --git a/pos_mrp_order/static/description/BoM.png b/pos_mrp_order/static/description/BoM.png new file mode 100644 index 000000000..8e9ed170c Binary files /dev/null and b/pos_mrp_order/static/description/BoM.png differ diff --git a/pos_mrp_order/static/description/MRP order.png b/pos_mrp_order/static/description/MRP order.png new file mode 100644 index 000000000..0147a4adc Binary files /dev/null and b/pos_mrp_order/static/description/MRP order.png differ diff --git a/pos_mrp_order/static/description/POS view.png b/pos_mrp_order/static/description/POS view.png new file mode 100644 index 000000000..816247bc0 Binary files /dev/null and b/pos_mrp_order/static/description/POS view.png differ diff --git a/pos_mrp_order/static/description/Product form.png b/pos_mrp_order/static/description/Product form.png new file mode 100644 index 000000000..5627150fb Binary files /dev/null and b/pos_mrp_order/static/description/Product form.png differ diff --git a/pos_mrp_order/static/description/banner.jpg b/pos_mrp_order/static/description/banner.jpg new file mode 100644 index 000000000..e31ee4ebe Binary files /dev/null and b/pos_mrp_order/static/description/banner.jpg differ diff --git a/pos_mrp_order/static/description/cybro_logo.png b/pos_mrp_order/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/pos_mrp_order/static/description/cybro_logo.png differ diff --git a/pos_mrp_order/static/description/icon.png b/pos_mrp_order/static/description/icon.png new file mode 100644 index 000000000..ea63a87f1 Binary files /dev/null and b/pos_mrp_order/static/description/icon.png differ diff --git a/pos_mrp_order/static/description/index.html b/pos_mrp_order/static/description/index.html new file mode 100644 index 000000000..1bda7eac9 --- /dev/null +++ b/pos_mrp_order/static/description/index.html @@ -0,0 +1,151 @@ +
+
+

Make MRP orders from POS

+

Launch automatic MRP orders after selling through POS.

+

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+

Features:

+
    +
  •    Automatically create MRP order form POS sale.
  • +
  •    We have to assign the products for which MRP order gets created Automatically.
  • +
  •    Identify the MRP orders easily generated from POS.
  • +
+
+
+
+ +
+
+

How enable MRP order creation from POS

+
+
+
+ +
+
+
+

+ There is a heading 'Point of Sale' under sales tab in the product form. Enable + 'To create MRP order' and make sure that this product has a bill of material, + else system will generate a warning. If you forget to set the BOM, then MRP order + does not get created. +

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

What are the points to be noted when set the BoM

+
+
+
+ +
+
+
+

+ Every product needs minimum one BoM, then only MRP order gets created at the time of POS sale.

+

+ If you do not enable the Product Variants, then you can set a BoM with a product and its components. +

+

+ If you enable the Product Variants (Products can have several attributes, defining + variants (Example: size, color...)) then the BoM form will contain extra field Product Variant. +

+

+

    +
  • If you set a BoM for a product template, then you will be able to get that BoM for all + the variants.
  • +
+
    +
  • If you set a BoM for a particular Product variants, then that BoM is counted only for + that variant.
  • +
+
    +
  • So other variants’ BoM is counted as zero. MRP Order is created only when the BoM + is available.
  • +
+

+
+ +
+
+
+ +
+
+

Point Of Sale

+
+

+

    +
  • Select the products for sale.
  • +
+
    +
  • Make the payments and validate it.
  • +
+
    +
  • Check Manufacturing orders
  • +
+

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

Manufacturing Order

+
+
+
+ +
+
+
+

+ From the "Source", we can easily find out the MRP orders that is created by POS. +

+
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/pos_mrp_order/static/description/warning.png b/pos_mrp_order/static/description/warning.png new file mode 100644 index 000000000..5988d50b5 Binary files /dev/null and b/pos_mrp_order/static/description/warning.png differ diff --git a/pos_mrp_order/static/src/js/models.js b/pos_mrp_order/static/src/js/models.js new file mode 100644 index 000000000..6d41c04a0 --- /dev/null +++ b/pos_mrp_order/static/src/js/models.js @@ -0,0 +1,53 @@ +odoo.define('pos_mrp_order.models_mrp_order', function (require) { +"use strict"; +var pos_model = require('point_of_sale.models'); +var pos_screens = require('point_of_sale.screens'); +var models = pos_model.PosModel.prototype.models; +var Model = require('web.DataModel'); + + +for(var i=0; i0) + { + var product_dict = { + 'id': order_line[i].product.id, + 'qty': order_line[i].quantity, + 'product_tmpl_id': order_line[i].product.product_tmpl_id, + 'pos_reference': order.name, + 'uom_id': order_line[i].product.uom_id[0], + }; + list_product.push(product_dict); + } + + } + } + if (list_product.length) + { + new Model("mrp.production") + .call("create_mrp_from_pos", [1, list_product]) + } + } + + }, + + }); +}); diff --git a/pos_mrp_order/views/pos_template.xml b/pos_mrp_order/views/pos_template.xml new file mode 100644 index 000000000..e228cf0a6 --- /dev/null +++ b/pos_mrp_order/views/pos_template.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/pos_mrp_order/views/product_view.xml b/pos_mrp_order/views/product_view.xml new file mode 100644 index 000000000..d57f7d45d --- /dev/null +++ b/pos_mrp_order/views/product_view.xml @@ -0,0 +1,13 @@ + + + + product.template.form.inherit + product.template + + + + + + + +