diff --git a/pos_mrp_order/README.rst b/pos_mrp_order/README.rst new file mode 100644 index 000000000..1df7306e0 --- /dev/null +++ b/pos_mrp_order/README.rst @@ -0,0 +1,48 @@ +.. image:: https://img.shields.io/badge/licence-AGPL--1-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Make MRP orders from POS v15 +============================ + +* From the POS sale we need to generate MRP orders in the back end with out close the current window. +* Automatically create MRP order form POS sale. +* We can assign which products make MRP order Automatically. + +Configuration +============= +* No additional configurations needed + +Company +------- +* Cybrosys Techno Solutions `__ + +Credits +------- +* Developer: V10 Nikhil Krishnan @ cybrosys, odoo@cybrosys.com + V12 Akshay Babu @cybrosys, odoo@cybrosys.com + V13 Vaishnavi B @cybrosys,Contact: odoo@cybrosys.com + V14 Sagarika B @cybrosys,Contact: odoo@cybrosys.com + V15 Sagarika B @cybrosys,Contact: odoo@cybrosys.com + +Contacts +-------- +* Mail Contact : odoo@cybrosys.com +* Website : https://cybrosys.com + +Bug Tracker +----------- +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Maintainer +========== +.. image:: https://cybrosys.com/images/logo.png + :target: https://cybrosys.com + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit `Our Website `__ + +Further information +=================== +HTML Description: ``__ diff --git a/pos_mrp_order/__init__.py b/pos_mrp_order/__init__.py new file mode 100644 index 000000000..d338c3ba8 --- /dev/null +++ b/pos_mrp_order/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan(odoo@cybrosys.com) +# you can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (AGPL v3) along with this program. +# If not, see . +# +############################################################################## + +from . import models diff --git a/pos_mrp_order/__manifest__.py b/pos_mrp_order/__manifest__.py new file mode 100644 index 000000000..4a100c025 --- /dev/null +++ b/pos_mrp_order/__manifest__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan(odoo@cybrosys.com) +# you can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (AGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'Make MRP orders from POS', + 'version': '15.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': 'https://www.cybrosys.com', + 'category': 'Point of Sale', + 'depends': ['point_of_sale', 'mrp', 'stock'], + 'license': 'AGPL-3', + 'data': [ + 'security/ir.model.access.csv', + 'views/product_view.xml', + ], + 'assets': { + 'point_of_sale.assets': [ + 'pos_mrp_order/static/src/js/models.js', + ], + }, + 'images': ['static/description/banner.png'], + '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..60396c162 --- /dev/null +++ b/pos_mrp_order/models/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan(odoo@cybrosys.com) +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (AGPL v3) along with this program. +# If not, see . +# +############################################################################## + +from . 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..2a8b4aa27 --- /dev/null +++ b/pos_mrp_order/models/point_of_sale_make_mrp.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Nikhil krishnan(odoo@cybrosys.com) +# you can modify it under the terms of the GNU AFFERO +# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. +# +# 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 (AGPL v3) for more details. +# +# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (AGPL v3) along with this program. +# If not, see . +# +############################################################################## + +from odoo import models, fields, api +from odoo.exceptions import ValidationError + + +class MrpProduction(models.Model): + _inherit = 'mrp.production' + + def create_mrp_from_pos(self, products): + product_ids = [] + 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 = [] + 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, + } + mrp_order = self.sudo().create(vals) + list_value = [] + for bom_line in mrp_order.bom_id.bom_line_ids: + list_value.append((0, 0, { + 'raw_material_production_id': mrp_order.id, + 'name': mrp_order.name, + 'product_id': bom_line.product_id.id, + 'product_uom': bom_line.product_uom_id.id, + 'product_uom_qty': bom_line.product_qty * mrp_order.product_qty, + 'picking_type_id': mrp_order.picking_type_id.id, + 'location_id': mrp_order.location_src_id.id, + 'location_dest_id': bom_line.product_id.with_company(self.company_id.id).property_stock_production.id, + 'company_id': mrp_order.company_id.id, + })) + + mrp_order.update({'move_raw_ids':list_value}) + 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_count: + raise ValidationError('Please set Bill of Material for this product.') + + +class ProductProduct(models.Model): + _inherit = 'product.product' + + @api.onchange('to_make_mrp') + def onchange_to_make_mrp(self): + if self.to_make_mrp: + if not self.bom_count: + 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/assets/icons/check.png b/pos_mrp_order/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/check.png differ diff --git a/pos_mrp_order/static/description/assets/icons/chevron.png b/pos_mrp_order/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/chevron.png differ diff --git a/pos_mrp_order/static/description/assets/icons/cogs.png b/pos_mrp_order/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/cogs.png differ diff --git a/pos_mrp_order/static/description/assets/icons/consultation.png b/pos_mrp_order/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/consultation.png differ diff --git a/pos_mrp_order/static/description/assets/icons/ecom-black.png b/pos_mrp_order/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/ecom-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/education-black.png b/pos_mrp_order/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/education-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/hotel-black.png b/pos_mrp_order/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/hotel-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/license.png b/pos_mrp_order/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/license.png differ diff --git a/pos_mrp_order/static/description/assets/icons/lifebuoy.png b/pos_mrp_order/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/lifebuoy.png differ diff --git a/pos_mrp_order/static/description/assets/icons/logo.png b/pos_mrp_order/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/logo.png differ diff --git a/pos_mrp_order/static/description/assets/icons/manufacturing-black.png b/pos_mrp_order/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/manufacturing-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/pos-black.png b/pos_mrp_order/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/pos-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/puzzle.png b/pos_mrp_order/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/puzzle.png differ diff --git a/pos_mrp_order/static/description/assets/icons/restaurant-black.png b/pos_mrp_order/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/restaurant-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/service-black.png b/pos_mrp_order/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/service-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/trading-black.png b/pos_mrp_order/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/trading-black.png differ diff --git a/pos_mrp_order/static/description/assets/icons/training.png b/pos_mrp_order/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/training.png differ diff --git a/pos_mrp_order/static/description/assets/icons/update.png b/pos_mrp_order/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/update.png differ diff --git a/pos_mrp_order/static/description/assets/icons/user.png b/pos_mrp_order/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/user.png differ diff --git a/pos_mrp_order/static/description/assets/icons/wrench.png b/pos_mrp_order/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/pos_mrp_order/static/description/assets/icons/wrench.png differ diff --git a/pos_mrp_order/static/description/assets/modules/1.png b/pos_mrp_order/static/description/assets/modules/1.png new file mode 100644 index 000000000..1217263a6 Binary files /dev/null and b/pos_mrp_order/static/description/assets/modules/1.png differ diff --git a/pos_mrp_order/static/description/assets/modules/2.png b/pos_mrp_order/static/description/assets/modules/2.png new file mode 100644 index 000000000..6f604a403 Binary files /dev/null and b/pos_mrp_order/static/description/assets/modules/2.png differ diff --git a/pos_mrp_order/static/description/assets/modules/3.png b/pos_mrp_order/static/description/assets/modules/3.png new file mode 100644 index 000000000..6f28da108 Binary files /dev/null and b/pos_mrp_order/static/description/assets/modules/3.png differ diff --git a/pos_mrp_order/static/description/assets/modules/4.png b/pos_mrp_order/static/description/assets/modules/4.png new file mode 100644 index 000000000..3afc14722 Binary files /dev/null and b/pos_mrp_order/static/description/assets/modules/4.png differ diff --git a/pos_mrp_order/static/description/assets/modules/5.png b/pos_mrp_order/static/description/assets/modules/5.png new file mode 100644 index 000000000..cea66b05f Binary files /dev/null and b/pos_mrp_order/static/description/assets/modules/5.png differ diff --git a/pos_mrp_order/static/description/assets/modules/6.png b/pos_mrp_order/static/description/assets/modules/6.png new file mode 100644 index 000000000..0c9bb377e Binary files /dev/null and b/pos_mrp_order/static/description/assets/modules/6.png differ diff --git a/pos_mrp_order/static/description/assets/screenshots/hero.png b/pos_mrp_order/static/description/assets/screenshots/hero.png new file mode 100644 index 000000000..e2144a019 Binary files /dev/null and b/pos_mrp_order/static/description/assets/screenshots/hero.png differ diff --git a/pos_mrp_order/static/description/assets/screenshots/mrp1.png b/pos_mrp_order/static/description/assets/screenshots/mrp1.png new file mode 100644 index 000000000..0da6a18d4 Binary files /dev/null and b/pos_mrp_order/static/description/assets/screenshots/mrp1.png differ diff --git a/pos_mrp_order/static/description/assets/screenshots/mrp2.png b/pos_mrp_order/static/description/assets/screenshots/mrp2.png new file mode 100644 index 000000000..a988fe2f0 Binary files /dev/null and b/pos_mrp_order/static/description/assets/screenshots/mrp2.png differ diff --git a/pos_mrp_order/static/description/assets/screenshots/mrp3.png b/pos_mrp_order/static/description/assets/screenshots/mrp3.png new file mode 100644 index 000000000..d53b596bc Binary files /dev/null and b/pos_mrp_order/static/description/assets/screenshots/mrp3.png differ diff --git a/pos_mrp_order/static/description/assets/screenshots/mrp4.png b/pos_mrp_order/static/description/assets/screenshots/mrp4.png new file mode 100644 index 000000000..9b0de31f6 Binary files /dev/null and b/pos_mrp_order/static/description/assets/screenshots/mrp4.png differ diff --git a/pos_mrp_order/static/description/assets/screenshots/mrp5.png b/pos_mrp_order/static/description/assets/screenshots/mrp5.png new file mode 100644 index 000000000..291278efa Binary files /dev/null and b/pos_mrp_order/static/description/assets/screenshots/mrp5.png differ diff --git a/pos_mrp_order/static/description/banner.png b/pos_mrp_order/static/description/banner.png new file mode 100644 index 000000000..20eb5f70c Binary files /dev/null and b/pos_mrp_order/static/description/banner.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..b8950decc 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..e658b2e27 --- /dev/null +++ b/pos_mrp_order/static/description/index.html @@ -0,0 +1,622 @@ +
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+ +
+
+
+
+ +
+
+
+

+ Make MRP Orders from POS

+

+ Launch automatic MRP orders after selling through POS +

+ +
+
+ + + + +
+
+

+ Overview +

+
+ +
+

+ The module automatically launches MRP orders from Point of Sale.

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Automatic MRP Orders form POS Sale.

+

+ Automatically create MRP order form POS sale.

+
+
+
+
+ +
+
+

+ Assign products for which automatic MRP to be created +

+

+ We have to assign the products for which MRP order gets created Automatically.

+
+
+
+
+ +
+
+

+ Identify POS generated MRP orders easily

+

+ Identify the MRP orders easily generated from POS.

+
+
+ +
+ +
+
+

+ Screenshots +

+
+
+

+ Enable MRP order creation from POS

+

+ How to enable MRP order creation from POS.

+ +
+
+

+ Create MRP Order. Warning is Shown if the Product does not Have a Bill of Material

+

+ 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.

+ +
+ +
+

+ Bill of Material

+

+ 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. +

+ +
+ +
+

+ Find out the MRP orders that is created by POS

+

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

+ +
+ +
+ +
+
+

Suggested Products

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

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

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

Need Help?

+
+
+
+ + +
+ +
+ +
+ +
+ WhatsApp +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file 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..19d3c800f --- /dev/null +++ b/pos_mrp_order/static/src/js/models.js @@ -0,0 +1,79 @@ +odoo.define('pos_mrp_order.models_mrp_order', function (require) { +"use strict"; +var models = require('point_of_sale.models'); +const PaymentScreen = require('point_of_sale.PaymentScreen'); +const Registries = require('point_of_sale.Registries'); +var rpc = require('web.rpc'); + + var existing_models = models.PosModel.prototype.models; + var product_index = _.findIndex(existing_models, function (model) { + return model.model === "product.product"; + }); + var product_model = existing_models[product_index]; + + product_model.fields.push('to_make_mrp'); + + const MRPPaymentScreen = (PaymentScreen) => + class extends PaymentScreen { + constructor() { + super(...arguments); + } + createMRP(){ + const order = this.currentOrder; + var order_line = order.orderlines.models; + var due = order.get_due(); + for (var i in order_line) + { + var list_product = [] + if (order_line[i].product.to_make_mrp) + { + if (order_line[i].quantity>0) + { + 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) + { + rpc.query({ + model: 'mrp.production', + method: 'create_mrp_from_pos', + args: [1,list_product], + }); + } + } + } + async validateOrder(isForceValidate) { + if(this.env.pos.config.cash_rounding) { + if(!this.env.pos.get_order().check_paymentlines_rounding()) { + this.showPopup('ErrorPopup', { + title: this.env._t('Rounding error in payment lines'), + body: this.env._t("The amount of your payment lines must be rounded to validate the transaction."), + }); + return; + } + } + if (await this._isOrderValid(isForceValidate)) { + // remove pending payments before finalizing the validation + for (let line of this.paymentLines) { + if (!line.is_done()) this.currentOrder.remove_paymentline(line); + } + await this._finalizeValidation(); + } + this.createMRP(); + } + }; + + Registries.Component.extend(PaymentScreen, MRPPaymentScreen); + + return MRPPaymentScreen; + +}); 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 + + + + + + + +