ArasOdoo and BOM revs
/src/ArasOdoo.Client/ArasOdoo.Client/ArasOdoo.csunknown
plain_text
a year ago
2.7 kB
0
Indexable
Never
// Check to see if there could be an earlier revision for this BOM and if there could be, check to see if one exists in Odoo // and has a routing associated to it. If it does, include this in the new revision. // Take the current revision and get the previous. A non empty string will indicate the potential of a previous revision. string previousRevision = GetPreviousRevision(bomPayload.revision); var prevBoms = new long[0]; if (previousRevision != "") { // Go see if this BOM exists in Odoo and return the associated Routing so we can attach it to the new revision. OdooDomainFilter filter2 = new OdooDomainFilter(); filter2.And(); filter2.Filter("product_tmpl_id", "=", products[0]); filter2.Filter("code", "=", previousRevision); var reqBom2 = new OdooSearchParameters("mrp.bom", filter2); prevBoms = this.odooRpcClient.Search<long[]>(reqBom2, new OdooPaginationParameters(0, 1)); if (prevBoms.Length != 0) { // Go get the routings for this BOM id. var routingParams = new OdooSearchParameters("mrp.bom", new OdooDomainFilter().Filter("id", "=", prevBoms[0])); var rSearchFields = new OdooFieldParameters(); ---> rSearchFields.Add("routing_id"); // If this is an empty response then we have no routing attached, otherwise we need to get the Routing ID var routingList = this.odooRpcClient.SearchRead<JObject[]>(routingParams, rSearchFields, new OdooPaginationParameters(0, 1)); if (routingList.Length > 0) { var routingData = routingList[0]; var resultType = routingData["routing_id"].Type; if (resultType != JTokenType.Boolean) { var routingRecord = routingData["routing_id"][0]; payload.routing_id = Int32.Parse(routingRecord.ToString()); hasPriorBom = true; // Setting it here because we really only care about a previous revision if it has a routing attached. } } } }