After finishing the process of database data collection and exporting to an xml file, I need to add a Hash value. The purpose of this hash value is to digitally sign a document created. For example, every time an invoice is posted, a hash value must be created and saved so it can be included in the SAFT reporting file.
So, I suppose it will be a function field, so I can call a method and calculate the hash value from the invoice data. Until here it’s all right . However, I’m struggling to create the column in the database and then create a new hash value when an invoice is posted.
I think the best is to generate the hash of the exported xml file. This will ensure an unique hash for each generated file. You can generate a md5 hash of the file by using a python method.
Yes. It looks interesting and more efficient, because it will be just one digital signature for all file. However, certain documents reported in the SAFT file need a hash value with a digital signature. One of the examples is the invoices, which requires that each invoice reported must be signed through SHA1 with an RSA asymmetric algorithm. The hash value will be calculated from a string with values taken from the invoice to be signed, such as invoice number, invoice date, gross total.
I’m using something similar to this to sign each invoice with state equal to posted.
You have to extend the post process of the invoice. Look in invoice.py from the account_invoice module. There you will find a workflow transition that is posting invoices. At that moment also an invoice number is added. You have to extend that functionality with your hashing.
Why not just creating a readonly Char field and store the hash into it? I assume the hash is created once.
We once discussed using horodating in the French mailing list (sorry, it is in French).
The subject was ‘Loi de finance 2016 (suite)’ in the late 2017 timeframe.
This is separate but potentially simultaneous with digital signing of the invoice itself.