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

[14.0][IMP] stock_location_last_inventory_date: Make last_inventory_date storeable #2222

Open
wants to merge 1 commit into
base: 14.0
Choose a base branch
from

Conversation

mt-software-de
Copy link
Contributor

@mt-software-de mt-software-de commented Dec 17, 2024

I wanted to make this field searchable. At first i tried to create a search method for it, but it was not nice to implement, since the location of stock.inventory is used. Storing the date is easier. Therefor i changed the computation to use stock.inventory.line instead of stock.inventory , because this record contains a direct link to a location.

@mt-software-de mt-software-de changed the title [IMP] stock_location_last_inventory_date: Make last_inventory_data storeable [14.0][IMP] stock_location_last_inventory_date: Make last_inventory_data storeable Dec 17, 2024
@mt-software-de mt-software-de changed the title [14.0][IMP] stock_location_last_inventory_date: Make last_inventory_data storeable [14.0][IMP] stock_location_last_inventory_date: Make last_inventory_date storeable Dec 17, 2024
@mt-software-de mt-software-de force-pushed the 14-imp-stock_location_last_inventory_date branch from f07a99c to dbe1f5b Compare December 17, 2024 09:41
@mt-software-de
Copy link
Contributor Author

@hailangvn @sebalix @simahawk
Could you maybe review this one, since you did the migration for it?
#1261

@mt-software-de
Copy link
Contributor Author

cc @i-vyshnevska @jbaudoux

Copy link
Contributor

@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.

You can make an inventory of a location without making any inventory line. I would have not changed that concept.
In newer versions, it's updating the date when the inventory is posted. You could go that way and make a migration script of the initialization of the field.

last_inventory_dates = [
line.inventory_id.date
for line in location.inventory_line_ids
if line.state == "done"
Copy link
Contributor

Choose a reason for hiding this comment

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

can move to fields definition done_inventory_line_ids as a domain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The last_inventory_date will be now set on action_done.
But still i am using the locations set on stock.inventory.line.
You can also create a stock.inventory without setting location_ids.
The lines should be created by _action_start
(https://github.com/odoo/odoo/blob/cc0060e889603eb2e47fa44a8a22a70d7d784185/addons/stock/models/stock_inventory.py#L170).
If the lines aren't created, then they should be created manually.

This is then now the same as it is in newer versions. stock.inventory.line is removed and just stock.quant is used.
In v14 the method _get_inventory_lines_values
(https://github.com/odoo/odoo/blob/cc0060e889603eb2e47fa44a8a22a70d7d784185/addons/stock/models/stock_inventory.py#L297)
is getting the data from stock.quant.

@mt-software-de mt-software-de force-pushed the 14-imp-stock_location_last_inventory_date branch from dbe1f5b to dcdb125 Compare December 17, 2024 15:18
@mt-software-de mt-software-de force-pushed the 14-imp-stock_location_last_inventory_date branch from dcdb125 to 0e0121d Compare December 18, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants