You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

54 lines
1.7 KiB

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 rpc = require('web.rpc');
for(var i=0; i<models.length; i++){
var model=models[i];
if(model.model === 'product.product'){
model.fields.push('to_make_mrp');
}
}
pos_screens.PaymentScreenWidget.include({
validate_order: function(force_validation) {
var self = this
this._super(force_validation);
var order = self.pos.get_order();
var order_line = order.orderlines.models;
var list_product = []
var due = order.get_due();
for (var i in order_line)
{
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],
});
}
}
},
});
});