Stock Picking Model Part 1

How to create Goods Issue (GI)?

  1. Get the running number.

//Stock.picking:model
//default_get:action
//[["number"]]:Put in the fields that you needed to read/get
//context:put in the scope
//pick_type:outgoing stock
//journal_id:stock journal id
//This is to get the running number of the GI.

GI_res = rpc_execute ("stock.picking","default_get", [["number"]], {context:{pick_type:"out", journal_id:14}});  

2. Assigned to a variable.


//Object GI_no is the running number of GI

var GI_no=GI_res.number; 

3. Declare GI_vals with mandatory fields


//Insert the fields that you wanted to have in the Good Issue
//Make sure the field name is correct
//insert the GI_no into field-"number"

var GI_vals = {
       journal_id:journal_id,
       invoice_id:inv_id,
       date:date,
       contact_id:contact_id,
       number:GI_no,
       type:"out",
       lines:[],
};

4. Insert the stock that you wanted to issue into the lines


//GI_lines:product information
//["create",o]: array function that will create the line in the GI

_.forEach(GI_lines,o=>
{GI_vals.lines.push(["create",o]);  
});

5. Create the GI


//Pick_id: This is the ID of the created GI which is default return from the rpc_execute

var pick_id= await rpc_execute ("stock.picking", "create", [GI_vals], {context:{}});

6. Complete the GI


//The GI will be posted according to the "pick_id"

await rpc_execute("stock.picking","set_done",[[pick_id]]);

How to void / delete Goods Issue (GI)?

  1. First, get GI id

var GI_ID=res[0].id;

2. TO-DRAFT


await rpc_execute("stock.picking","to_draft",[[GI_ID]]);

3. TO-VOID / DELETE

  • VOID : The GI will be voided but the transaction will be kept.

await rpc_execute("stock.picking","void",[[GI_ID]]);
  • DELETE: The GI will be deleted. No records will be found.

await rpc_execute("stock.picking","delete",[[GI_ID]]);

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.