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

[16.0][port][account_invoice_inter_company] attach pdf #766

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

bguillot
Copy link
Contributor

@bguillot bguillot commented Feb 3, 2025

Hello,

This is a port of #283 to add the invoice pdf in both companies

Copy link
Member

@victoralmau victoralmau left a comment

Choose a reason for hiding this comment

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

I think it would be more appropriate to make the copy() of the ir.attachment of the source invoice indicating the res_id of the destination invoice reducing and simplifying the code. What do you think?

@bguillot
Copy link
Contributor Author

bguillot commented Feb 3, 2025

Hello, I think the pdf is not always generated in the other company, and in case of several attachments, how to know which one to take ?
It's safer to generate the right attachment.

@bguillot bguillot force-pushed the 16-port-attach-pdf branch 2 times, most recently from 293dcc2 to 7050f70 Compare February 3, 2025 13:36
Copy link
Contributor

@florian-dacosta florian-dacosta left a comment

Choose a reason for hiding this comment

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

LGTM
I also think it is safer to generate the report.
AFAIK, at this stage, it is probable that the pdf does not exist yet on the customer invoice.

@bguillot bguillot requested a review from victoralmau February 4, 2025 09:10
@victoralmau
Copy link
Member

Ping @pedrobaeza

@pedrobaeza pedrobaeza added this to the 16.0 milestone Feb 5, 2025
account_invoice_inter_company/models/account_move.py Outdated Show resolved Hide resolved
supplier_invoice = self.auto_invoice_id
if not supplier_invoice:
supplier_invoice = self.search([("auto_invoice_id", "=", self.id)], limit=1)
report = self.env.ref("account.account_invoices").with_company(self.company_id)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
report = self.env.ref("account.account_invoices").with_company(self.company_id)
report = self.env.ref("account.account_invoices").with_company(supplier_invoice.company_id)

Copy link
Contributor

@florian-dacosta florian-dacosta Feb 5, 2025

Choose a reason for hiding this comment

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

I think we really want the customer invoice's pdf here (to attach it on the supplier invoice).
Why would we generate the pdf of customer invoice (which is self) using the supplier invoice's company ?
Maybe the with_company is kind of useless since the current company should already be self.company_id, but I don't understand why we would want to use the supplier one.

Copy link
Member

Choose a reason for hiding this comment

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

OK, right. I have mixed things, but I think this would help if self is the supplier invoice, as it's the target of the action to do (attach there the customer invoice), and it's also advised to add docstrings. Let's not block this anyway.

Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

/ocabot merge patch

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-766-by-pedrobaeza-bump-patch, awaiting test results.

@pedrobaeza
Copy link
Member

And the commit messages are horrible too...

Please next time stick to guidelines:

https://github.com/OCA/odoo-community.org/blob/master/website/Contribution/CONTRIBUTING.rst#commit-message

@OCA-git-bot OCA-git-bot merged commit 173e4d8 into OCA:16.0 Feb 5, 2025
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at e91a86b. 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.

6 participants