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

[IMP] purchase_sale_inter_company: apply customer specific changes and improve with latest changes from v14 #504

Closed

Conversation

yankinmax
Copy link

This PR returns customer specific changes introduced in these commits:

This PR is opened as a replacement of the closed one: #445

Create one SO from PO, if exists -> modify existing
@yankinmax yankinmax force-pushed the enea-purchase_sale_inter_company branch from eddf581 to 594a403 Compare August 28, 2023 09:10
@gurneyalex gurneyalex added the no stale Use this label to prevent the automated stale action from closing this PR/Issue. label Aug 28, 2023
Comment on lines 40 to 48
po_partner = purchase_order.partner_id
# vendor can be a member of group company or it's child
# dest_company will be anyway member of group company
dest_company = (
purchase_order.partner_id.commercial_partner_id.ref_company_ids
po_partner.ref_company_ids or po_partner.parent_id.ref_company_ids
)
intercompany_user = dest_company.intercompany_sale_user_id
if not intercompany_user:
intercompany_user = self.env.user

Choose a reason for hiding this comment

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

These lines may return a res.users recordset as intercompany_user, but at line 70 we have intercompany_user.id which will raise an error if there's more than 1 record. Please fix this.

Comment on lines +58 to +65
# if len(auto_sale_order_id) > 1:
# raise UserError(
# _(
# "You can have only one auto-generated sale order "
# "but following orders were found '%s' "
# )
# % ",".join([order.display_name for order in auto_sale_order_id])
# )

Choose a reason for hiding this comment

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

Why is this commented out?

Copy link
Author

Choose a reason for hiding this comment

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

It's standard OCA flow for this module.
The client refuses it, so I commented for future self to understand.

Comment on lines +53 to +57
auto_sale_order_id = (
self.env["sale.order"]
.sudo()
.search([("auto_purchase_order_id", "=", purchase_order.id)])
)

Choose a reason for hiding this comment

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

This search() may return a sale.order recordset, but at line 67 we have auto_sale_order_id.state which will raise an error if there's more than 1 SO. Please fix this.

Comment on lines +17 to +21
auto_sale_order_id = (
self.env["sale.order"]
.sudo()
.search([("auto_purchase_order_id", "=", purchase_order.id)])
)

Choose a reason for hiding this comment

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

This search() may return a sale.order recordset, but at line 28 we have auto_sale_order_id.display_name which will raise an error if there's more than 1 SO. Please fix this.

Comment on lines +140 to 145
raise UserError(
_(
"There is more than one pricelist for this vendor "
"with the same currency"
)
)

Choose a reason for hiding this comment

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

Why do you raise this error instead of just fetching 1 of the many pricelists?

Copy link
Author

Choose a reason for hiding this comment

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

customer request was to have only one pricelist for vendor company with the same currency
it's a signal to check and remove not needed one

Comment on lines -142 to +220
def _prepare_sale_order_line_data(self, purchase_line, dest_company, sale_order):
def _prepare_sale_order_line_data(self, purchase_line, sale_order):

Choose a reason for hiding this comment

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

Changing a method signature can be disruptive. Have you checked it usage in other modules?

Copy link
Author

Choose a reason for hiding this comment

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

this method (I mean with such parameters) is only used here for this customer

Copy link
Author

Choose a reason for hiding this comment

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

This is the exact change we do in OCA module to have customer's expected workflow.

@yankinmax
Copy link
Author

@SilvioC2C thanks for your review.
I've analysed your suggestions and will update this PR and propose these changes in next release.
AS for the PR itself: we've analysed with @gurneyalex different ways to handle customer needs.
Of course the best would be to create customer specific module and override workflow, but it isn't possible in current OCA state.

@SilvioC2C
Copy link

SilvioC2C commented Nov 24, 2023

@yankinmax OCA modules should not contain customer-specific needs, they should be generic enough to be included in public repos. If these changes are customer-specific, they should be made directly in the customer's project.

Besides, these comments are about bugs that break the execution of Odoo itself, so they should be fixed regardless:

  1. [IMP] purchase_sale_inter_company: apply customer specific changes and improve with latest changes from v14 #504 (comment)
  2. [IMP] purchase_sale_inter_company: apply customer specific changes and improve with latest changes from v14 #504 (comment)
  3. [IMP] purchase_sale_inter_company: apply customer specific changes and improve with latest changes from v14 #504 (comment)

@yankinmax
Copy link
Author

@SilvioC2C I agree with you. It was a difficult decision we've taken with @gurneyalex
We had two options using standard purchase sale intercompany flow or OCA one.
The customer wanted OCA variant, but with his specific needs.
What we could do, we could have customer module with overwritten code. I'll propose that to the BA
Thanks again for your help and impact on these questions

@legalsylvain
Copy link
Contributor

@SilvioC2C, is it ok now ?

@legalsylvain legalsylvain added needs review and removed no stale Use this label to prevent the automated stale action from closing this PR/Issue. labels Dec 17, 2023
@legalsylvain legalsylvain added this to the 15.0 milestone Dec 17, 2023
@SilvioC2C
Copy link

@legalsylvain unfortunately no, there still are bugs in this code and it still includes customer-specific behavior 😅

Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label Apr 28, 2024
@github-actions github-actions bot closed this Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs fixing stale PR/Issue without recent activity, it'll be soon closed automatically.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants