Browse Source

Mar 6 : [UPDT] Code Updated 'pos_mrp_order'

pull/254/head
AjmalCybro 2 years ago
parent
commit
1f85a979d5
  1. 2
      pos_mrp_order/__manifest__.py
  2. 47
      pos_mrp_order/models/point_of_sale_make_mrp.py
  3. 2
      pos_mrp_order/static/src/js/models.js

2
pos_mrp_order/__manifest__.py

@ -20,7 +20,7 @@
############################################################################## ##############################################################################
{ {
'name': 'Make MRP orders from POS', 'name': 'Make MRP orders from POS',
'version': '15.0.1.0.0', 'version': '15.0.1.1.0',
'summary': """Launch Automatic MRP Orders After Selling Through POS.""", 'summary': """Launch Automatic MRP Orders After Selling Through POS.""",
'description': """Launch automatic MRP orders after selling through POS""", 'description': """Launch automatic MRP orders after selling through POS""",
'author': 'Cybrosys Techno Solutions', 'author': 'Cybrosys Techno Solutions',

47
pos_mrp_order/models/point_of_sale_make_mrp.py

@ -40,12 +40,16 @@ class MrpProduction(models.Model):
product_ids.append(product) product_ids.append(product)
for prod in product_ids: for prod in product_ids:
if prod['qty'] > 0: if prod['qty'] > 0:
product = self.env['product.product'].search([('id', '=', prod['id'])]) product = self.env['product.product'].search(
bom_count = self.env['mrp.bom'].search([('product_tmpl_id', '=', prod['product_tmpl_id'])]) [('id', '=', prod['id'])])
bom_count = self.env['mrp.bom'].search(
[('product_tmpl_id', '=', prod['product_tmpl_id'])])
if bom_count: if bom_count:
bom_temp = self.env['mrp.bom'].search([('product_tmpl_id', '=', prod['product_tmpl_id']), bom_temp = self.env['mrp.bom'].search(
('product_id', '=', False)]) [('product_tmpl_id', '=', prod['product_tmpl_id']),
bom_prod = self.env['mrp.bom'].search([('product_id', '=', prod['id'])]) ('product_id', '=', False)])
bom_prod = self.env['mrp.bom'].search(
[('product_id', '=', prod['id'])])
if bom_prod: if bom_prod:
bom = bom_prod[0] bom = bom_prod[0]
elif bom_temp: elif bom_temp:
@ -55,7 +59,7 @@ class MrpProduction(models.Model):
if bom: if bom:
vals = { vals = {
'origin': 'POS-' + prod['pos_reference'], 'origin': 'POS-' + prod['pos_reference'],
'state': 'confirmed', # 'state': 'confirmed',
'product_id': prod['id'], 'product_id': prod['id'],
'product_tmpl_id': prod['product_tmpl_id'], 'product_tmpl_id': prod['product_tmpl_id'],
'product_uom_id': prod['uom_id'], 'product_uom_id': prod['uom_id'],
@ -71,13 +75,35 @@ class MrpProduction(models.Model):
'product_id': bom_line.product_id.id, 'product_id': bom_line.product_id.id,
'product_uom': bom_line.product_uom_id.id, 'product_uom': bom_line.product_uom_id.id,
'product_uom_qty': bom_line.product_qty * mrp_order.product_qty, '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_id': mrp_order.location_src_id.id,
'location_dest_id': bom_line.product_id.with_company(self.company_id.id).property_stock_production.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, 'company_id': mrp_order.company_id.id,
'state': 'draft',
'quantity_done': 0,
'operation_id': False
})) }))
mrp_order.update({'move_raw_ids':list_value}) finished_vals = {
'product_id': prod['id'],
'product_uom_qty': prod['qty'],
'product_uom': prod['uom_id'],
'name': mrp_order.name,
'date_deadline': mrp_order.date_deadline,
'picking_type_id': mrp_order.picking_type_id.id,
'location_id': mrp_order.location_src_id.id,
'location_dest_id': mrp_order.location_dest_id.id,
'company_id': mrp_order.company_id.id,
'production_id': mrp_order.id,
'warehouse_id': mrp_order.location_dest_id.warehouse_id.id,
'origin': mrp_order.name,
'group_id': mrp_order.procurement_group_id.id,
'propagate_cancel': mrp_order.propagate_cancel,
}
mrp_order.update({'move_raw_ids': list_value,
'move_finished_ids': [
(0, 0, finished_vals)]
})
return True return True
@ -91,7 +117,8 @@ class ProductTemplate(models.Model):
def onchange_to_make_mrp(self): def onchange_to_make_mrp(self):
if self.to_make_mrp: if self.to_make_mrp:
if not self.bom_count: if not self.bom_count:
raise ValidationError('Please set Bill of Material for this product.') raise ValidationError(
'Please set Bill of Material for this product.')
class ProductProduct(models.Model): class ProductProduct(models.Model):

2
pos_mrp_order/static/src/js/models.js

@ -9,6 +9,7 @@ var rpc = require('web.rpc');
var product_index = _.findIndex(existing_models, function (model) { var product_index = _.findIndex(existing_models, function (model) {
return model.model === "product.product"; return model.model === "product.product";
}); });
console.log("product_model", product_model)
var product_model = existing_models[product_index]; var product_model = existing_models[product_index];
product_model.fields.push('to_make_mrp'); product_model.fields.push('to_make_mrp');
@ -40,7 +41,6 @@ var rpc = require('web.rpc');
} }
} }
if (list_product.length) if (list_product.length)
{ {
rpc.query({ rpc.query({

Loading…
Cancel
Save