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

[15.0][IMP]stock_cycle_count: several improvements #1997

Merged

Conversation

ArnauCForgeFlow
Copy link
Contributor

@ArnauCForgeFlow ArnauCForgeFlow commented Apr 17, 2024

Depends on: #1995

This PR include the following improvements, se commits for more details.

@ArnauCForgeFlow ArnauCForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch 3 times, most recently from 44d4221 to 4c963c0 Compare April 24, 2024 11:14
@ArnauCForgeFlow ArnauCForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch 4 times, most recently from ee770b8 to e51735b Compare April 29, 2024 14:42
@ArnauCForgeFlow ArnauCForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch 2 times, most recently from ff64074 to 09edb8a Compare May 2, 2024 15:18
@@ -76,6 +62,27 @@ def _domain_cycle_count_candidate(self):
("location_id", "in", self.location_ids.ids),
]

def _calculate_inventory_accuracy(self):
for inv in self:
sml = self.env["stock.move.line"].search(
Copy link
Contributor

Choose a reason for hiding this comment

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

Mmmh, IMHO this has to be refined has multiple searches will be done...

@ArnauCForgeFlow ArnauCForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch 6 times, most recently from 09c6757 to be2ca4a Compare May 9, 2024 13:30
@JoanSForgeFlow JoanSForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch from be2ca4a to 28c1195 Compare May 10, 2024 08:01
inv.action_state_to_in_progress()
try:
inv.action_state_to_in_progress()
except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it a too broad Exception ?

Moreover, shouldn't we manage the exception in a more elegant manner than 'just' logging ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @rousseldenis

You might be right. I implemented it this way because we don't want the cron job to stop running due to a validation error from a location that already has an inventory adjustment in progress.

Do you have any suggestions for a better approach?

Thanks.

@JoanSForgeFlow JoanSForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch 2 times, most recently from 3983318 to 6906e79 Compare June 25, 2024 10:55
@ArnauCForgeFlow ArnauCForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch from 347ea05 to 2e5b1f0 Compare June 27, 2024 11:14
@JoanSForgeFlow JoanSForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch from 3235706 to bd1e6a6 Compare September 18, 2024 09:45
@LoisRForgeFlow LoisRForgeFlow changed the title [15.0][IMP]stock_cycle_count: add auto complete and begin adjustments in cron [15.0][IMP]stock_cycle_count: several improvements Sep 18, 2024
@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). 🤖

stock_inventory_records = self.mapped("stock_adjustment_ids")
for record in stock_inventory_records:
if record.responsible_id.id != vals["responsible_id"]:
record.with_context(no_propagate=True).write(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like such code. Don't you have another mean to avoid this ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not modifying stock_inventory to change the responsible_id fields to computed field (stored/readonly=False) and override the compute here ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@JoanSForgeFlow JoanSForgeFlow Oct 22, 2024

Choose a reason for hiding this comment

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

@rousseldenis, we agree with your proposal and have applied it.
Thank you

@JoanSForgeFlow JoanSForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch from 5a042b4 to b8fd2aa Compare October 22, 2024 14:15
@LoisRForgeFlow
Copy link
Contributor

@rousseldenis friendly reminder here, can you update your last review? @JoanSForgeFlow has attended your request

],
order="create_date asc",
).filtered(
lambda x: not x.company_id.id
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't it correspond to normal record rule ?

Copy link
Contributor

Choose a reason for hiding this comment

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

In other words, is the filtered necessary ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rousseldenis You are correct, since we are searching for stock move lines by location, and the locations already belong to a company, it is not needed this filter. I'll make the change.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

@rousseldenis @ArnauCForgeFlow it is not the normal record rule, it is filtering based on the quant company, the normal record rules filters based on the users companies, we cannot rely on the user having the proper companies.

That been said, I think instead of filtering, it can be done with a domain that includes a couple of company_id clauses.

@JoanSForgeFlow JoanSForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch 2 times, most recently from ec684b0 to 34d68ad Compare November 21, 2024 12:03
@JoanSForgeFlow JoanSForgeFlow force-pushed the 15.0-imp-stock_cycle_count-user_and_date branch from 34d68ad to 2c9ecf6 Compare November 21, 2024 13:59
@ArnauCForgeFlow
Copy link
Contributor Author

Hey @rousseldenis just a friendly reminder, could you please update your review?

@LoisRForgeFlow
Copy link
Contributor

Let's move forward

/ocabot merge major

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 15.0-ocabot-merge-pr-1997-by-LoisRForgeFlow-bump-major, awaiting test results.

@OCA-git-bot
Copy link
Contributor

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

@OCA-git-bot OCA-git-bot merged commit 62df53a into OCA:15.0 Dec 3, 2024
5 of 7 checks passed
@LoisRForgeFlow LoisRForgeFlow deleted the 15.0-imp-stock_cycle_count-user_and_date branch December 3, 2024 09:16
@LoisRForgeFlow
Copy link
Contributor

@ArnauCForgeFlow can you update the 16.0 fwport (#2169) to be fully aligned with this one?

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.

5 participants