← Back to team overview

banking-addons-drivers team mailing list archive

Attachements instead of dedicated models ?

 

    Dear banking addons community friends,

During a review of the PR https://github.com/OCA/bank-payment/pull/76, we started a discussion about the necessity of the models "banking.export.sdd" (in account_banking_sepa_direct_debit) and "banking.export.sepa" (in account_banking_sepa_credit_transfer) and other such models that store the file for the bank that is generated by the module. An alternative would be to use an attachement on the payment.order model to store the file for the bank. The advantage for using attachements:
1) it avoids a lot of code
2) when the user is on the form view of a payment order, we can immediately see if there is an attachement or not, and then he can access it without problems (with the current solution, he has to click on "More > SEPA Credit Transfer files" to see if there is a file attached or not)

Maybe the current solution has some advantages, but I don't know them...

When I initially developped the SEPA modules, I created the models banking.export.sdd and banking.export.sepa only because I followed the implementation of the existing modules of the banking addons (I remember I was already quite surprised of this implementation compared to using attachements)

Pedro and Stéphane also support moving to attachements. Stefan, what is your opinion on this ?

Of course, updating the code to use attachements is easy... but writing the migration script is less easy ! :)

P.S. : If we decide to move to attachements, a possibility would be to have an object "payment.order.file" that has "_inherits = {'ir.attachment': 'attachment_id'}", like in the module base_delivery_carrier_label :
https://github.com/OCA/carrier-delivery/blob/8.0/__unported__/base_delivery_carrier_label/stock.py#L437
Such an implementation would have 2 advantages:
1) we can search on "payment.order.file" and we are sure to get bank files (because, if we search on ir.attachements, we may have some attachements that have been manually added by the user to the payment order and have nothing to do with a bank file). 2) we can add some fields on payment.order.file without "polluting" the model ir.attachements

Regards,

Alexis




Follow ups