Transfer material against job card not working in V12?

If in Work Order is enabled ‘transfer_material_against_job_card’ then on trying to Submit ‘Job Card’ error about ‘transferred_qty’:

image
The error is coming from:

_File “/home/frappe/frappe-bench/apps/erpnext/erpnext/manufacturing/doctype/job_card/job_card.py”, line 115, 
in set_transferred_qty_
_self.db_set(“transferred_qty”, self.transferred_qty)._

as self.transferred_qty is 0 because there are no ‘Stock Entries’ associated with this ‘Job Card’ yet.
job_card.py:

What’s interesting that buttons to create such ‘Stock Entries’ are only shown if ‘Job Card’ is submitted (status = 1).
job_card.js:

Shoudn’t transactions (Material Transfer & Stock Entries) be made before Job Card is submitted or I am missing some logic?

Using V12:
image

1 Like

@Bench_stop, we were recently facing the same issue as well.

It’s happening, as the error suggests, because the transferred_qty field is set in the database to require a valid float value. If we modify it and allow null values there, it breaks in a couple other places as well.

We couldn’t figure out the right way to solve this problem and we had to find a fix urgently, so we used a workaround for now, which is to uncheck the “Transfer Material against Job Card” box, and do the Stock Entries against the Work Order directly instead.

Hope that helps you.

@RohanB thanks for idea.
-I guess you had to edit doctype of ‘Stock Entry’ as well, as field ‘job_card’ is read only in it. What means you can’t set it by yourself by manually creating ‘Stock Entries’.

Form this piece of code (at job_card.py) you can read that transferred_qty is calculated from ‘Stock Entries’ with specific Job Order’:


So if you have not set ‘Job Card’s’ name in ‘Stock Entry’, then wrong value of transferred_qty in ‘Job Card’ will be calculated.

If I understand correctly the flow of new manufacturing process, then I have already fixed this one for myself.
I made the post to get some response from Erpnext team…

To fix:

  1. Show button ‘Material Transfers’ (that will lead to ‘Stock Entry’) in ‘Job Card’ before submit:
    job_card.js:
    -change to ‘frm.doc.docstatus==0’

  2. When you press button ‘Material Transfer’ in ‘Job Card’ then system automatically prefills the information from Job Card to Stock Entry and then docstatus of Job Card shouldn’t be 1 (‘submitted’) but 0, so this line should have to be “docstatus”: [“=”, 0]
    job_card.py:

P.S. Does somebody know - is there some written documentation about new manufacturing process? Otherwise we have to spend a lot of time just by chasing idea of what this and this code could mean as logic in Erpnext gets more and more sophisticated (what is good, of course)

@Bench_stop

We have fixed this issue, can you please pull the latest update and check

Hi @rohit_w, can you please link to the update/PR for this fix?