Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG][11.0] donation_direct_debit #53

Merged
merged 1 commit into from
Jun 15, 2019
Merged

[MIG][11.0] donation_direct_debit #53

merged 1 commit into from
Jun 15, 2019

Conversation

tbaden
Copy link
Member

@tbaden tbaden commented Apr 30, 2019

No description provided.

@tbaden tbaden mentioned this pull request Apr 30, 2019
7 tasks
@tbaden tbaden changed the title [MIG][11.0] donation_direct_debit [MIG][11.0][WIP] donation_direct_debit Apr 30, 2019
@coveralls
Copy link

coveralls commented Apr 30, 2019

Coverage Status

Coverage increased (+0.9%) to 85.863% when pulling 6bbe79d on tbaden:11.0-mig-donation-direct-debit into 9f0c518 on OCA:11.0.

@pedrobaeza pedrobaeza added this to the 11.0 milestone Apr 30, 2019
@tbaden
Copy link
Member Author

tbaden commented Apr 30, 2019

@pedrobaeza is there a reason why the runbot status is skipped?
seems like branch 11.0 and 12.0 builds are all skipped.

@pedrobaeza
Copy link
Member

pedrobaeza commented May 1, 2019

Travis was not correct. Fixed in 161e5c2

Please rebase

@oca-clabot
Copy link

Hey @tbaden, thank you for your Pull Request.

It looks like some users haven't signed our Contributor License Agreement, yet.
You can read and sign our full Contributor License Agreement here: http://odoo-community.org/page/cla
Here is a list of the users:

Appreciation of efforts,
OCA CLAbot

@tbaden
Copy link
Member Author

tbaden commented May 1, 2019

cla bot can be ignored, I somehow killed my gitconfig

@tbaden
Copy link
Member Author

tbaden commented May 1, 2019

@pedrobaeza thanks for the support, all green

@tbaden tbaden changed the title [MIG][11.0][WIP] donation_direct_debit [MIG][11.0] donation_direct_debit May 1, 2019
Copy link

@yucer yucer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a good practice to add the translation files without translations ? Or is that needed for some translation engine ?

It though it was better not to add them.

Copy link

@yucer yucer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some little coding suggestions...

self.partner_id.customer_payment_mode_id.
payment_method_id.mandate_required
):
mandates = self.env['account.banking.mandate'].search([
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that taking the first record during an onchange of another field is to allow the user to select one.
In this case an order clause (for example by create_date desc) can make the result more predictable.

Also the search domains used in these use cases normally collide with restrictions on the field during the user selection. Are you we sure that mandate_id field doesn't need a domain restriction ?

I mean, when changing the partner, the first valid Mandate for that partner is selected, under certain conditions. After that the user can change it, until the state done is reached. In that moment can the user select a non-valid Mandante ? Or one of the other partner ?

If the answer is now, then it is better to move the search terms to a domain clause in the mandate_id field.

('partner_id', '=', self.commercial_partner_id.id),
])
if mandates:
self.mandate_id = mandates[0]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a limit=1 clause in the previous search, explicit code for to get the first Record in the RecordSet is not needed.

('payment_mode_id', '=', donation.payment_mode_id.id),
])
msg = False
if payorders:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same thing here... No need to take the first payorder, the search can have a limit=1 clause.

an existing draft Direct Debit pay order'''
res = super(DonationDonation, self).validate()
apoo = self.env['account.payment.order']
for donation in self:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be aware that the super method works over a RecordSet and interrupt the validation process when it finds an invalid donation. That mean that the others (valids or not) would not be processed in this code.

What about to define a protected method in the donation.donation model for extension, for example _after_validate(..), and call it inside the loop of its validate()?

That would only be needed if the method should process all the valid donations and not all at once. If ALL the donations needs to be valid at once, then this way is ok.

return res

def done2cancel(self):
for donation in self:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code:

        for donation in self:
            if donation.move_id:
                donation_mv_line_ids = [
                    l.id for l in donation.move_id.line_ids]

can be optimized to:

        for donation in self.filtered('move_id'):
             donation_mv_line_ids = donation.mapped('move_id.line_ids').ids

"which is linked to a payment line in a "
"direct debit order. Remove it from the "
"following direct debit order: %s.")
% plines[0].order_id.name)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about if there are more plines ? Those doesn't need to be removed ? If it is sure that no more plines would result from the query, then maybe just limit=1 is needed in the query.

Using limit=1 when needed also helps with performance. :-)

If there can be more than one, then an order clause would make it more predictable.

@tbaden
Copy link
Member Author

tbaden commented May 17, 2019

@yucer thanks for these suggestions.
@pedrobaeza is it part of the migration to do these improvements or should I open another PR for improvements, when this is migrated?

@pedrobaeza
Copy link
Member

@tbaden your call: you decide if you want to make that improvements or only the migration here.

@tbaden
Copy link
Member Author

tbaden commented May 17, 2019

@yucer I would like to make to migration first, so that people can use the module and afterwards create a PR for your improvements and maybe additional. I'll add you in the new PR if you like.
availability over improvements.

@yucer
Copy link

yucer commented May 17, 2019

Sorry, I didn't note it was a migration.

@tbaden
Copy link
Member Author

tbaden commented May 19, 2019

@yucer does this migration get your approvement?

@yucer
Copy link

yucer commented May 24, 2019

@yucer does this migration get your approvement?

Yes. I suppose for the migration is OK. And the coverage is good.

Copy link
Contributor

@benbrich benbrich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional LGT!

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@pedrobaeza pedrobaeza merged commit 229b984 into OCA:11.0 Jun 15, 2019
@alexis-via
Copy link
Contributor

ARG, this migration didn't keep commit history!!!
When I'll migrate donation_direct_debit to v14, I'll use 10.0 as starting point.

alexis-via added a commit to akretion/donation that referenced this pull request Aug 12, 2021
The migration is made from v10 because I figured out that commit history
was lost during the v11 migration, cf OCA#53
Improve chatter message to add a link to the payment order
Don't give rights on account.payment.order or account.payment.line to
donation user because rights on payment orders should be very
restricted. Use sudo() to create the payment order & line in the code.
alexis-via added a commit to akretion/donation that referenced this pull request Oct 23, 2021
The migration is made from v10 because I figured out that commit history
was lost during the v11 migration, cf OCA#53
Improve chatter message to add a link to the payment order
Don't give rights on account.payment.order or account.payment.line to
donation user because rights on payment orders should be very
restricted. Use sudo() to create the payment order & line in the code.
alexis-via added a commit to akretion/donation that referenced this pull request May 1, 2023
The migration is made from v10 because I figured out that commit history
was lost during the v11 migration, cf OCA#53
Improve chatter message to add a link to the payment order
Don't give rights on account.payment.order or account.payment.line to
donation user because rights on payment orders should be very
restricted. Use sudo() to create the payment order & line in the code.
alexis-via added a commit to akretion/donation that referenced this pull request May 15, 2023
The migration is made from v10 because I figured out that commit history
was lost during the v11 migration, cf OCA#53
Improve chatter message to add a link to the payment order
Don't give rights on account.payment.order or account.payment.line to
donation user because rights on payment orders should be very
restricted. Use sudo() to create the payment order & line in the code.
esteveblanch pushed a commit to esteveblanch/donation that referenced this pull request Aug 18, 2024
The migration is made from v10 because I figured out that commit history
was lost during the v11 migration, cf OCA#53
Improve chatter message to add a link to the payment order
Don't give rights on account.payment.order or account.payment.line to
donation user because rights on payment orders should be very
restricted. Use sudo() to create the payment order & line in the code.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants