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

[12.0][MIG] account_invoice_line_default_account #1143

Merged

Conversation

SirTakobi
Copy link
Contributor

@SirTakobi SirTakobi commented Apr 21, 2022

Migrating/Adding account_invoice_line_default_account to 12.0.

This poor module has a troubled history: as far as I have found, it was brought from launchpad's 6.1 (unmerged) to 8.0 with #23, then #189, and finally #356 (currently still open).

Then a migration to 10.0 happened in #351 (currently still open).

I tried to put together something like a consistent commit history and this is the result, with a last commit for migrating to 12.0.

Additional notes:

  • I added some tests 🎉

  • There is a fixup commit because I couldn't find where the __openerp__ was removed between [8.0] account_invoice_line_default_account #356 and [10.0] account_invoice_line_default_account #351, I didn't squash it in order not to mix authorships, but I can do it if @jbaudoux agrees

  • About the roadmap:

    • For account.invoice.line._onchange_account_id I already tried substituting write with update but that results in not updating the partner (can be verified with the tests),
    • For account.invoice.line.account_id, currently the module assumes the previous default method is the one defined in account but that might not be True; retrieving the field's default inside the defined method is useless because it has already been changed to the defined method

    If you have any suggestion it is welcome

Looking at the linked PRs and commits, @jbaudoux you might want to have a look :)

NL66278 and others added 6 commits April 21, 2022 09:50
…Therp)

            and Alexandre Fayolle (CampToCamp):
            - No hyphenation in module description
            - Better module name
            - Typo's fixed
            - Streamline access to context dictionary: context.get('key')
(../account-financial-tools-6.1 rev 100.1.2)
(../account-financial-tools-6.1 rev 100.1.3)
(../account-financial-tools-6.1 rev 100.1.4)
…pplier

(../account-financial-tools-6.1 rev 101)
@SirTakobi SirTakobi force-pushed the 12.0-mig-account_invoice_line_default_account branch from 4a08ff6 to 7100a50 Compare April 21, 2022 15:04
Copy link

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

Thanks for adding tests.

Some minor remarks.

I remember when I ported to v10 that lot of code had to be rewritten, that's why I squashed all the old commits. I don't think it is useful to recover all those old commits and I would squash them all into a single commit or at least reduce them a lot.

account_id = fields.Many2one(default=_account_id_default)

@api.onchange('account_id')
def _onchange_account_id(self):

Choose a reason for hiding this comment

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

maybe better to use a different name to not have to call super

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review!
I can see no harm in calling super, actually it looks to me like a common thing to call super when overriding a method; why should this case be treated in a different way?

Choose a reason for hiding this comment

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

Before api.onchange, there could be only a single method called on an onchange. With api.onchange you can have multiple different methods. The conditions are not to test if super has to be called or not but if this method has to be executed. So I find the current implementation hard to read.
Nevertheless it will work. Just a minor remark.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes perfect sense: overriding the method is really needed only when you want to edit the method's behavior, but that does not have to be the way to go with the onchange methods.
I have done this change too, with a bit of explanation in the comments, let me know if it looks better now :)

Choose a reason for hiding this comment

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

Looks clear now

def _onchange_account_id(self):
if not self.account_id or not self.partner_id or self.product_id:
return super(AccountInvoiceLine, self)._onchange_account_id()
if self._context.get('journal_id'):

Choose a reason for hiding this comment

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

self.env.context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, done :)

@rafaelbn
Copy link
Member

/ocabot migration account_invoice_line_default_account

@OCA-git-bot OCA-git-bot added this to the 12.0 milestone Apr 21, 2022
@OCA-git-bot OCA-git-bot mentioned this pull request Apr 21, 2022
30 tasks
@SirTakobi SirTakobi force-pushed the 12.0-mig-account_invoice_line_default_account branch 2 times, most recently from 8a10d2b to fc1935f Compare April 22, 2022 12:44
@SirTakobi SirTakobi force-pushed the 12.0-mig-account_invoice_line_default_account branch from fc1935f to ed04280 Compare April 22, 2022 13:02
[ADD] account_invoice_line_default_account

[IMP] account_invoice_line_default_account: updated with new OCA guidelines

[FIX] pep8, README.rst

[FIX] view_load is deprecated

[FIX] fields.property definition have changed

[FIX] from . import + contributors

[FIX] account_invoice_line_default_account: Adding the partner in the context of invoice line of customer invoice. It's there in standard in supplier invoices but not in customer invoices and it's required by this module

[ADD]account_invoice_line_default_account: default income account on partner similar to default expense account

[ADD] translations fr/nl

[FIX] __openerp__ file

[IMP] look and feel

[FIX] pep8
account_invoice_line_default_account: search based on xmlid as name is translatable
[FIX] pylint
@SirTakobi SirTakobi force-pushed the 12.0-mig-account_invoice_line_default_account branch from ed04280 to f5d3e2f Compare April 22, 2022 13:12
@SirTakobi
Copy link
Contributor Author

SirTakobi commented Apr 22, 2022

I remember when I ported to v10 that lot of code had to be rewritten, that's why I squashed all the old commits. I don't think it is useful to recover all those old commits and I would squash them all into a single commit or at least reduce them a lot.

@jbaudoux I squashed most of the commits, and added the __openerp__.py removal in 10.0 migration, let me know if it looks better now.
Just as reference, I have kept the previous history in https://github.com/SirTakobi/account-invoicing/tree/12.0-mig-account_invoice_line_default_account-bkp

Can you update your review? Github is not allowing me to re-request you to do it

/ocabot migration account_invoice_line_default_account

@rafaelbn thanks, I'm sorry I forgot to do those things

@SirTakobi SirTakobi marked this pull request as ready for review April 22, 2022 13:29
@SirTakobi SirTakobi force-pushed the 12.0-mig-account_invoice_line_default_account branch from f5d3e2f to 28c8e70 Compare April 22, 2022 13:39
@@ -16,6 +16,9 @@
'data': ['views/account_invoice_view.xml',
'views/report_invoice.xml'],
'depends': ['account'],
'excludes': [

Choose a reason for hiding this comment

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

Why the 2 modules cannot work together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote it in the commit message:

This module is not compatible with account_invoice_line_sequence because them both add to the context of invoice lines in invoice form view

Copy link

@jbaudoux jbaudoux left a comment

Choose a reason for hiding this comment

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

LGTM

.travis.yml Outdated
- TESTS="1" ODOO_REPO="OCA/OCB" EXCLUDE="account_invoice_line_default_account"
- TESTS="1" ODOO_REPO="OCA/OCB" EXCLUDE="account_invoice_line_sequence"
- TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" EXCLUDE="account_invoice_line_default_account"
- TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1" EXCLUDE="account_invoice_line_sequence"
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Runboat currently does not support conflicting addons, see sbidoul/runboat#36

Copy link
Member

@eLBati eLBati left a comment

Choose a reason for hiding this comment

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

Proposing SirTakobi#1 to avoid basing on context and thus incompatibilities

@SirTakobi
Copy link
Contributor Author

Proposing SirTakobi#1 to avoid basing on context and thus incompatibilities

@eLBati there are some things that do not really convince me in SirTakobi#1.

Instead of working on the linked PR, can we go on with the merge of this migration alone? Since we already have enough approvals, this module might finally be merged for the first time! 😄
Then you will be able to propose that PR directly to 12.0.
Unless you think there is something in this PR that might be blocking for the merge.

@SirTakobi SirTakobi requested a review from eLBati May 4, 2022 07:35
@SirTakobi
Copy link
Contributor Author

@OCA/accounting-maintainers can this be merged or do I have to change something? Thanks!

@eLBati
Copy link
Member

eLBati commented May 11, 2022

Unless you think there is something in this PR that might be blocking for the merge

Uhm yes, this SirTakobi#1

SirTakobi and others added 4 commits May 17, 2022 17:07
This module is not compatible with account_invoice_line_sequence because them both add to the context of invoice lines in invoice form view
…which is always executed while adding invoice lines
@SirTakobi SirTakobi force-pushed the 12.0-mig-account_invoice_line_default_account branch from 5750f24 to cec3b69 Compare May 17, 2022 15:07
@SirTakobi
Copy link
Contributor Author

Unless you think there is something in this PR that might be blocking for the merge

Uhm yes, this SirTakobi#1

Now that you explained those changes, I merged them :)

Just for future reference, my doubts were about choosing the onchange on product_id field specifically, but we clarified that that onchange is called on any line creation from UI; so the onchange can do the job that was previously (when onchanges were not called on line creation) performed from the line's view using the context.

@SirTakobi
Copy link
Contributor Author

@eLBati can you update your review now? Thanks!

Copy link
Member

@eLBati eLBati left a comment

Choose a reason for hiding this comment

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

Thanks

@SirTakobi
Copy link
Contributor Author

@OCA/accounting-maintainers can this be merged? There are a few happy reviewers already 😄

@SirTakobi
Copy link
Contributor Author

@OCA/accounting-maintainers can this be merged? Thanks!

1 similar comment
@SirTakobi
Copy link
Contributor Author

@OCA/accounting-maintainers can this be merged? Thanks!

@sergiocorato
Copy link
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 12.0-ocabot-merge-pr-1143-by-sergiocorato-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit d7c8d7f into OCA:12.0 Jul 13, 2022
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 395f875. Thanks a lot for contributing to OCA. ❤️

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.

7 participants