Commit Graph
13 Commits
Author SHA1 Message Date
debu-odoo f02b21771c [IMP] stock: add revert inventory adjustment feature
Purpose of the task is to be able to click on inventory adjustment
history and do a reverse adjustment by using `Revert Inventory` action.

`Revert Inventory` action is available in Inventory Adjustments > History
and Product Moves > select some lines > actions dropdown. This
method creates a new move that reverts the quantity (including negative
values) with prefix `[reverted]`.

TaskID - 2859490

closes odoo/odoo#95720

Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-09-21 01:29:49 +02:00
Touati Djamel (otd) 30f3f8d816 [FIX] stock: use inventory adjustment name as a reference
Steps to reproduce the bug:
- Create a storable product “Test”
- Go to inventory > Operations > Inventory Adjustments
- Add a new line > Choose the “Test” product > Qty = 1*
- Select this line > Click on the “Apply” button
- You have the possibility to enter an “Inventory Reference / Reason”
- Go To reporting > stock moves

Problem:
The reference is “Product Quantity Updated” instead of the inventory adjustment name.

In the "action_apply" function, we give the name in the context: https://github.com/odoo/odoo/blob/15.0/addons/stock/wizard/stock_inventory_adjustment_name.py#L27

So that it is then used when creating the `stock.move`: https://github.com/odoo/odoo/blob/15.0/addons/stock/models/stock_quant.py#L800

But the context is destroyed here because we give a dict instead of a key :  https://github.com/odoo/odoo/blob/15.0/addons/stock/models/stock_quant.py#L296

Solution:
Remove the context override because it was done here: #83884
with the explanation that it's due to the write being called too many times here:
https://github.com/odoo/odoo/blob/8b155b695823dfa954464ad0d5dd07445ece2471/addons/stock/models/stock_quant.py#L244-L248

but then this later PR: #84771 deletes the same problem lines.

opw-2762169

closes odoo/odoo#85961

X-original-commit: eac6ca0db043fe59cf83988e6b000e700350930f
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-03-07 18:22:21 +00:00
Adrien Widart 8a6ff86324 [FIX] stock: prevent useless SML creation in inventory mode
Some useless SMLs are generated when editing the on hand quantity in
inventory mode

To reproduce the issue:
1. Create a storable product P
2. Update its on hand quantity to 100
3. Inventory > Reporting > Inventory Report
4. On the line for P, update to quantity to 75
5. Inventory > Reporting > Product Moves, search for P

Error: There are two SMLs with a quantity equal to zero

Calling `action_apply_inventory` from the `write` is useless since the
method is already called in the inversed method of
`inventory_quantity_auto_apply`

OPW-2739833

closes odoo/odoo#85152

X-original-commit: c2164fba4a9049115a6a46de28a90fc779fb9eee
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-02-22 17:11:09 +00:00
Adrien Widart 1ae9a47683 [FIX] stock: update qty in inventory report mode
It is currently not possible to update the quantity of a product from
the inventory report

To reproduce the issue:
1. Create a storable product P
2. Update its on hand quantity to 100
3. Inventory > Reporting > Inventory Report
4. On the line for P, update to quantity to 75

Error: The quantity becomes 0 instead of 75

When setting the quantity from the inventory report, the client calls
the `write` method with the context key `inventory_report_mode` defined
and equal to `True`
This `write` leads to `_set_inventory_quantity` which triggers
`action_apply_inventory` (without disabling the context key!):
https://github.com/odoo/odoo/blob/8b155b695823dfa954464ad0d5dd07445ece2471/addons/stock/models/stock_quant.py#L150-L158
At the end of the inventory update, it resets the field
`inventory_quantity` to 0:
https://github.com/odoo/odoo/blob/8b155b695823dfa954464ad0d5dd07445ece2471/addons/stock/models/stock_quant.py#L592
To do so, the `write` method is called again and here is the issue:
https://github.com/odoo/odoo/blob/8b155b695823dfa954464ad0d5dd07445ece2471/addons/stock/models/stock_quant.py#L244-L248
Once `inventory_quantity` is updated, since `inventory_report_mode` is
still in the context and equal to `True`, `action_apply_inventory` is
called again. Then, when applying again the inventory, it will consider
the value of `inventory_quantity` (i.e., `0`) to define the new
quantity.

OPW-2737437
OPW-2746201

closes odoo/odoo#84002

X-original-commit: 6500e99cbfda44ebd1931acd657e86841ac2342a
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-02-04 17:56:43 +00:00
William Henrotin 6a23b9bcd6 [REF] *stock*: rename model stock.production.lot into stock.lot
Task: 2648449
Part-of: odoo/odoo#80434
2021-12-07 16:20:05 +00:00
Arnold Moyaux bdcb3d192b [REF] stock: move stock.inventory feature into stock.quant
This commit removes stock.inventory(.line) and moves its general
functionality into stock.quant. Some features are lost during this
switch as well.

Feature Additions:
- New single list view for inventory adjustments (no more multiple
  inventory adjustment records to keep track of!)
- Improved cyclic counts (annual inventory day setting) + next inventory
  dates are immediately viewable in view (vs auto-generated inventories
  based only on location)
- Specific quants (i.e. counts) can be assigned to users for more
  flexibility (vs only able to restrict by location + product
  combinations)
- Counts can be requested (i.e. bulk assigned to user/for a specific
  inventory date)

Feature Removals:
- Can no longer look at previous inventory adjustments linked to a
  specific record. Each quant has a history button to show inventory
  related moves. [relevant account moves are also now harder to see via
  stock as well]

Other changes:
- Bulk of changes were for demo/test
- Some changes were done to ensure "Update Quantity"/"Inventory Report"
  views still mainly function the same as before with the exception of a
  new column added to support updating quant quantities in these views.

Task: 2440026
ENT PR: odoo/enterprise#17329
Upgrade PR: odoo/upgrade#2326

closes odoo/odoo#68409

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-02 11:51:38 +00:00
Tiffany Chang (tic) 83a43af4cb [IMP] mrp,stock: improve duplicate SN warnings
Add and improve onchange warnings when a duplicate SN is used in
following cases: inventory, picking (any type), manufacturing, scrap,
and "Update Quantity" (i.e. directly edit quants from product form).

Improvement includes:
- include location where the existing SN is
- auto-correct source location when appropriate (e.g. trying to scrap a
  SN in the wrong location)

The goal of this is to prevent but not restrict duplicate SNs so users
can have some flexibility (especially if a dupe SN occurs because of an
error such as doing pick-pack-ship out of order.)

closes odoo/odoo#61287

Task: 1924758
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-02-10 09:52:37 +00:00
Raphael Collet 1398b6b44c [IMP] tests: deprecate SavepointCase
closes odoo/odoo#62031

Related: odoo/enterprise#14872
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-11-24 13:23:32 +00:00
Thibault Delavallée 1404af789c [REF] various: use helper to create tests users
PURPOSE

Lessen use of mail-specific calls and variables

SPECIFICATIONS

Use mail_new_test_user tool in tests, lessening use of mail-specific context
keys in tests.

LINKS

Task ID-2326281 (context keys use cleaning)
PR odoo/odoo#56631
PR odoo/enterprise#12707

X-original-commit: 910559c092dc7dfa00b91339a5423e16cd4668e1
2020-08-28 07:59:23 +00:00
Hetashree Chauhan 49fb56a8d3 [IMP] stock: pass tests without demo data for file test_inventory.
pass all test cases without any demo data.
If a user has not installed any demo data, then also test cases must not be break.

task-2024202
closes : https://github.com/odoo/odoo/pull/34258
2019-07-11 13:12:09 +00:00
Hetashree Chauhan 5262be0a43 [IMP] stock: pass tests without demo data for file test_quant_inventory_mode.
pass all test cases without any demo data.
If a user has not installed any demo data, then also test cases must not be break.

task-2024202
closes : https://github.com/odoo/odoo/pull/34258
2019-07-11 13:12:09 +00:00
Raphael Collet b7fd679a6c [FIX] *: sudo() -> with_user() 2019-07-04 11:32:22 +00:00
svs-odooandsle-odoo da33eb36b8 [IMP] stock: editable quants
Made some changes in stock.quant model to allow user to modify product
quantity easier.

To allow the edition of quant without opening more permissions on the
model, we switch to sudo in create mode and write if the conditions are
met (special key in context + access rights on the current user + write
on a specific field).
Also, we have two list views for the quant:
    - The old list view who still readonly.
    - A new list view where user can create new quant or edit quantity
    of existing ones

We display the second one if user is a stock manager.
For existing quants, user can modify counted quantity (which will modify
product quantity). User can also create new quant, in this case:
    - The quant is really a new one (ex.: new product/location
    association) so will simply create a new quant.
    - A corresponding quant already exist, so will modify the existing
    quant instead of create a new one.

When an user creates a new quant, the model will check each time a
non-quantity field (product, location, SN/LN, package or owner) is
modified to see if corresponding quant exists. In this case, it'll get
the quant ID and will update reserved and on hand quantities.
If user didn't change the inventory quantity, it'll be updated too.

On product form view, the 'Update quantity' button was removed as user
can now simply modify quant with 'On Hand' stat button.

Task #1935921

Co-authored-by: sle-odoo <sle@odoo.com>
2019-05-29 13:59:01 +00:00