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][ADD] stock_inventory #1512

Merged

Conversation

DavidJForgeFlow
Copy link
Contributor

This module allows to group Inventory Adjustments and have a group traceability (like before 15.0).

@ForgeFlow

@rousseldenis
Copy link
Contributor

@DavidJForgeFlow Thanks for this. @pedrobaeza I think you could look at it following what we discussed on OCA days.

@pedrobaeza pedrobaeza added this to the 15.0 milestone Oct 21, 2022
@pedrobaeza
Copy link
Member

Yeah, I see.

David, please name the module stock_inventory_adjustment (without s and I suppose you wanted to say "grouped inventory", but I think that having "inventory adjustment" in the name is enough.

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from efa3d6f to 1a4afb0 Compare October 24, 2022 13:22
@DavidJForgeFlow DavidJForgeFlow changed the title [15.0][ADD] stock_group_inventory_adjustments [15.0][ADD] stock_inventory_adjustment Oct 24, 2022
@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from 1a4afb0 to ffb8b68 Compare October 24, 2022 13:24
@DavidJForgeFlow
Copy link
Contributor Author

Yeah, I see.

David, please name the module stock_inventory_adjustment (without s and I suppose you wanted to say "grouped inventory", but I think that having "inventory adjustment" in the name is enough.

All references changed. Also changed the model name to stock.inventory, is it ok like this?

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from ffb8b68 to 73fd325 Compare October 24, 2022 14:39
@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch 3 times, most recently from 99e4ba0 to 79649c6 Compare October 27, 2022 13:34
@DavidJForgeFlow DavidJForgeFlow changed the title [15.0][ADD] stock_inventory_adjustment [15.0][ADD] stock_inventory Oct 27, 2022
@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch 2 times, most recently from c223ffe to 9ad7b96 Compare October 28, 2022 08:02
Copy link

@GuillemCForgeFlow GuillemCForgeFlow left a comment

Choose a reason for hiding this comment

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

LGTM! 🔝 👍

@DavidJForgeFlow DavidJForgeFlow requested review from pedrobaeza and rousseldenis and removed request for pedrobaeza November 8, 2022 11:20
Copy link

@CasVissers-360ERP CasVissers-360ERP left a comment

Choose a reason for hiding this comment

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

Functional review

("manual", "Manual Selection"),
("category", "Product Category"),
("one", "One Product"),
("lot", "Lot Serial Number"),

Choose a reason for hiding this comment

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

String = "Lot" would be cleaner here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would say Lot/Serial Number to use Odoo naming

Copy link
Contributor

Choose a reason for hiding this comment

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

@DavidJForgeFlow Maybe an 'owner' management too ?

Choose a reason for hiding this comment

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

I agree with Lot/Serial Number

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 what do you mean with 'owner'? Add a responsible field?
The other changes are done, thanks!

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 Author

Choose a reason for hiding this comment

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

Done, thank you!


lot_ids = fields.Many2many(
"stock.production.lot",
string="Lot/Serial Number",

Choose a reason for hiding this comment

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

String = "Lots" would be cleaner here?

Choose a reason for hiding this comment

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

Edit: Lot/Serial Numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done thanks!


def action_state_to_in_progress(self):
active_rec = self.env["stock.inventory"].search([("state", "=", "in_progress")])
if active_rec:

Choose a reason for hiding this comment

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

Should we extend this? Checking if there are counts with same product or same lots or same locations? Counting two locations at the same time should be possible?

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 don't think so because you can only do an Adjustment at a time, so repeated counts are "imposible" (unless something magic happens).

def action_state_to_done(self):
self.state = "done"
for quant in self.stock_quant_ids:
quant.to_do = True

Choose a reason for hiding this comment

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

It is still a manual action to confirm the quant count?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, confirming a count is still manual.

Choose a reason for hiding this comment

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

Ok, this is very confusing? Should we at least give a warning to the user that the count(s) still needs to be confirmed? Setting a group to done for me means that the count is confirmed.

Choose a reason for hiding this comment

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

What if a quant is being mutated which is currently in a stock adjustment which is not done yet, should we not block this? Same like not allowing 2 counts? Overall I have a sense the module is confusing now. Why do we add a state to stock_inventory if nothing is being done / blocked or checked? If it is simply a group of quants, then we can create a group without a workflow?

self.state = "in_progress"
if self.product_selection == "all":
for location in self._origin.location_ids:
self.stock_quant_ids = self.env["stock.quant"].search(
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have put all domains in individual methods in order to allow override

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks!


def action_state_to_done(self):
self.state = "done"
for quant in self.stock_quant_ids:
Copy link
Contributor

Choose a reason for hiding this comment

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

Better :

Suggested change
for quant in self.stock_quant_ids:
self.stock_quant_ids.update({"to_do": True})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

_order = "date desc, id desc"

name = fields.Char(
required=True, default="Inventory ", string="Inventory Reference"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
required=True, default="Inventory ", string="Inventory Reference"
required=True, default="Inventory", string="Inventory Reference"

("manual", "Manual Selection"),
("category", "Product Category"),
("one", "One Product"),
("lot", "Lot Serial Number"),
Copy link
Contributor

Choose a reason for hiding this comment

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


def _get_all_quants(self, locations):
return self.env["stock.quant"].search(
[
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could put domains retrievals in separate methods to easy possible inheritance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All the different type of Inventory Adjustments are computed in different methods, what do you mean with putting the domains retrievals in separate methods?

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch 2 times, most recently from 31e650e to 9285897 Compare December 14, 2022 11:30
Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

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

Works Good!

Just a minor thing that needs to be fixed:

  • Create an inventory adjustment for one product only.
  • Start the adjustment
  • Change the quantity and click on Apply
  • The stock move line is successfully linked
  • Go to the stock.inventory again and then to the adjustments, remove the filter "Todo".
  • Change the quantity again to a new one and click on apply.
  • Issue: A new quant is successfully created but it is not linked to the inventory adjustment, that is, from the button Stock move lines I can only see one of the stock moves lines

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from 9285897 to d440ff7 Compare December 22, 2022 13:54
@DavidJForgeFlow
Copy link
Contributor Author

Works Good!

Just a minor thing that needs to be fixed:

* Create an inventory adjustment for one product only.

* Start the adjustment

* Change the quantity and click on Apply

* The stock move line is successfully linked

* Go to the stock.inventory again and then to the adjustments, remove the filter "Todo".

* Change the quantity again to a new one and click on apply.

* Issue: A new quant is successfully created but it is not linked to the inventory adjustment, that is, from the button Stock move lines I can only see one of the stock moves lines

Thank you Aaron, this is already fixed!

The code is now better to inherit because of some change of how domains work, thanks to @GuillemCForgeFlow and @rousseldenis for the idea.

Also, added the possiblilty of doing two Adjustments on two different Locations at the same time.

@GuillemCForgeFlow
Copy link

Thanks for the work @DavidJForgeFlow 👍 !

Copy link
Contributor

@AaronHForgeFlow AaronHForgeFlow left a comment

Choose a reason for hiding this comment

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

Functional review LGTM!

@CasVissers-360ERP
Copy link

@AaronHForgeFlow If you did a functional approval I am really curious about feedback on my questions. For me this module currently makes no sense. It is just a group of quants and could better be called stock_quant_group.

@AaronHForgeFlow
Copy link
Contributor

Hi @CasVissers-360ERP It is called stock_inventory in order to respect what it was in standard in previous versions, otherwise the migration will get more complex.

I guess the main discussion regards this comment:

What if a quant is being mutated which is currently in a stock adjustment which is not done yet, should we not block this? Same like not allowing 2 counts? Overall I have a sense the module is confusing now. Why do we add a state to stock_inventory if nothing is being done / blocked or checked? If it is simply a group of quants, then we can create a group without a workflow?

I think that if the quant is altered while the inventory adjustment is done then there is no inconsistencies in the database in this case, because Odoo will internally handle this. It may be confusing for users that quants did a change while they were doing the adjustments. In that case maybe it is necessary to avoid the modification of the quant until the inventory adjustment is completed. But that can be done on a separate module I think. I think there was also a module for that in this repo.

@CasVissers-360ERP
Copy link

@AaronHForgeFlow

You only answered one of my concerns? My main concern: Why do we add a state to stock_inventory if nothing is being done / blocked or checked? In addition it is not an inventory / inventory count. An inventory count start which blocking the location, counting the stock, and adjusting the stock level accordingly. I miss the whole idea of creating a count in Odoo (group of counts). But if there is no logic in the group/inventory I feel like it will be very confusing for the end-user. I have a hard time understanding the benefits as well.

If the goal of this module is to simply create a group of quants, just remove the state and rename the module.

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from d440ff7 to e9d627d Compare December 23, 2022 08:37
@AaronHForgeFlow
Copy link
Contributor

Hi @CasVissers-360ERP , I am just saying that the module works as my customer needs. They just need a document that records and keep a history of the changes on inventory. They are not worried about that restriction because the lifecycle of an inventory adjustment is too short for them and that kind of "issues" are not relevant. Nothing is blocked the quant in this module but it can be blocked on a module that depends on this one. Perhaps that feature can be included here, I am not against that.

@CasVissers-360ERP
Copy link

@AaronHForgeFlow Well maybe the module is not generic/mature enough to be on OCA module?

@AaronHForgeFlow
Copy link
Contributor

@CasVissers-360ERP I think it is very generic module, it recovers the standard inventory adjustments feature form previous versions and that is proved to be generic enough. The only thing that may be missing is the locking on the quant that is being inspected. It is ok to me to implement that restriction on this module, but I will not block this PR because of that. Would you be fine with this PR if it implements that restriction?

Those discussions are good for the quality of the module so I am glad you commented and I hope more people joins to the discussion here.

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from e9d627d to 73cf905 Compare December 23, 2022 13:59
Copy link

@ventor-dev ventor-dev left a comment

Choose a reason for hiding this comment

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

Great work! Customers still need this functionality to be able to group inventories for individual products into single big document. That is much better for Warehouse manager to review it later
Not sure I understand why Odoo removed it.

@DavidJForgeFlow thank you for the work! Hope it will be merged soon into OCA. Approved from my side

@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from 73cf905 to 2c27d01 Compare December 27, 2022 08:48
@CasVissers-360ERP
Copy link

@AaronHForgeFlow I don't agree with this " it recovers the standard inventory adjustments "

A big thing missing is:
https://github.com/odoo/odoo/blob/e9a7283ea33a5e122afa53f73f717ed45ce9874d/addons/stock/models/stock_inventory.py#L131

But since everybody else seems to approve this PR I think it's best for me to exit the discussion.

[15.0][IMP] stock_inventory: add product selection and fixup
@DavidJForgeFlow DavidJForgeFlow force-pushed the 15.0-add-stock_group_inventory_adjustments branch from 2c27d01 to c4a3719 Compare January 24, 2023 11:33
@LoisRForgeFlow
Copy link
Contributor

Obviously this can receive improvements and changes, but since I think it is a common requirement for customers coming from previous Odoo versions, let's at least cover the gap with this (I guess better this than nothing).

Thanks to all participants! Do not hesitate to open PRs to include improvements and changes once this gets merged.

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 15.0-ocabot-merge-pr-1512-by-LoisRForgeFlow-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 4cf65f1 into OCA:15.0 Jan 24, 2023
@OCA-git-bot
Copy link
Contributor

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

@MiquelRForgeFlow MiquelRForgeFlow deleted the 15.0-add-stock_group_inventory_adjustments branch January 24, 2023 11:51
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.

9 participants