Invoice image / PDF

How would one go about implementing a mandatory field that contains original invoice file?
Normal attachments are too fragile for that purpose: can be easily deleted, and it’s easy to forget to upload.

1 Like

Well. There’s “attach” data type in customization; I’ve added an invoice_file field, set it to mandatory and will see how this works over the week.

OK, let me talk to myself some more. This more-or-less works. However cannot set the field to mandatory, because attachments require document to be saved, and document cannot be saved, because mandatory requirement for the field is not satisfied… Ideas? :slight_smile:

There are two options here.

You need to make a hook which validates on save event of the doc:

  1. To check whether there is at-least one attachment in the doctype.
  2. Second make a file field, and when submitting make sure you have file uploaded in that field.

let me know if this makes sense

Regards,

Parth Joshi

It makes sense, but looks like a maintenance nightmare; this conundrum also exposes a flaw. I think that there really should be an additional ‘Mandatory on submit’ flag for a field, so a doc can be saved as a draft without it, but cannot be submitted. Are there any more use cases like this?

1 Like

Yes if there are no any additional checks, mandatory should work. There is mandatory option in edit doctype for the field. You are looking for “Mandatory on Submit” feature ?

Just a thought: you could also make a check box which is mandatory. This check box can only be filled, when file is already in the invoice_field.

Yes, I believe Mandatory should be either left as is or changed to Mandatory on Save, and there should be another option called Mandatory on SUbmit.
There is already a poorly named ‘Allow on Submit’ option; maybe while at it, it could be renamed to Editable after Submit’

Wojosc: I suppose that’s an acceptable workaround if nobody implements the above. Thanks.