← Back to team overview

banking-addons-drivers team mailing list archive

Re: Attachements instead of dedicated models ?

 

By the way, I just discovered that the object that stores the XML file (banking.export.sepa and banking.export.sdd) do NOT have a field company_id + an ir.rule, so it is a real problem in a multi-company setup. With the current code base in multi-company setup, there is even a crash in account_banking_sepa_credit_transfer/models/account_banking_sepa.py line 36 when you have 2 banking.export.sepa in 2 different companies (self.payment_order_ids is null because the payment orders are in a different company, so it crashes on self.payment_order_ids[0]).

So that's another reason why we really need to move to attachements.

Alexis

Le 2014-12-17 10:45, Alexis de Lattre a écrit :
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


References