Commit Graph
25 Commits
Author SHA1 Message Date
William Henrotin cd9833e4ad [REF] *stock*: rename location destination fields
The stock convention on location name is always to name the destination
`location_dest_id`. It was not the
case on the stock rule model

Task: 2648449
Part-of: odoo/odoo#80434
2021-12-07 16:20:06 +00:00
William Henrotin c146c7d16f [REF] *stock*: rename model stock.location.route into stock.route
Task: 2648449
Part-of: odoo/odoo#80434
2021-12-07 16:20:06 +00:00
William Henrotin 3a1473c75c [REF] *stock*: rename move_lines into move_ids in stock.picking
closes odoo/odoo#78732

Task: 2673000
Related: odoo/enterprise#21815
Related: odoo/upgrade#2956
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2021-10-27 15:48:51 +00:00
Rémy Voet (ryv) b33983d532 [REF] stock*,mrp*: clean setUp vs setUpClass
In a lot of test class, we use `setUp` instead of
`setUpClass`. `setUp` is execute for each test method and `setUpClass`
will be execute only once by Class (and use savepoint + rollback).

Then change setUp into setUpClass reduce the time to make all tests
and avoid to repeat this error for the future.

closes odoo/odoo#78082

Related: odoo/enterprise#21563
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-10-13 18:24:16 +00:00
Rémy Voet (ryv) 48f6b350a7 [REF] stock: clean onchange of stock.move
Clean onchange of `stock.move`: make it private and move in the
right place.
Also remove the action_assign_partner unused method

task-2373638
2021-01-05 08:32:05 +00:00
Rémy Voet (ryv) 515b9a78e6 [REF] stock,mrp: make picking_type_id compute store in stock.move
In order to have always a picking_type_id on a stock move (and
consistent with his parent model), make it compute store.
Then clean the call of picking_type_id without change the behavior
(/!\ `move.picking_id.picking_type_id != move.picking_type_id` because
of mrp). Fix some test where the location(_dest) was unset in moves.

Also:
- Clean the mess in the create of `stock.picking` about that
and add a onchange to keep location(_dest) consistent with moves.
- The move `description_picking` is set when the `picking_type_id`
change, not only at the create method.

task-2373638
2021-01-05 08:32:05 +00:00
Nicolas Martinelli 624079e283 [FIX] stock: do not set deadline with fixed procurement group
- Set the Delivery in 2 steps in the warehouse
- Create a 'wave' route:
  - Sequence: 5
  - Apply on Product Categories
  - Rules:
    - Action: Pull From
    - Operation Type: San Francisco: Pick
    - Source Location: WH/Stock/Chairs
    - Destination Location: WH/Output
    - Supply Method: Take From Stock
    - Propagation of Procurement Group: Fixed
    - Fixed Procurement Group: Chairs
- Create a 'Chairs' product category, apply the wave route
- Create a 'Chair' product:
  - Category: Chairs
  - Storable
- Make some stock in WH/Stock/Chairs
- Create a SO for 1 Unit of Chair, confirm
  => a picking from WH/Stock/Chairs to WH/Output is created
- Create a SO for 2 Units of Chair, confirm
  => the 2 units are added to the previous picking

However, the 2 stock moves are not merged.

It happens because `date_deadline` prevents the grouping.

opw-2390630

closes odoo/odoo#62983

X-original-commit: c4505b704489db7ef47dd9a201def536a99d03f3
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-12-07 18:00:12 +00:00
Tiffany Chang (tic) e6255e09b8 [IMP] mrp(_subcontracting), stock: MO reserve and replenish automatically
This commit does 3 things:

1. When 'action_confirm' is triggered in a manufacturing order, any
   'move_raw_ids' (components) that are unable to be fully reserved
   when `action_assign` is triggered will be checked for an automatic
   reordering rule (RR). If a rule exists it will be auto-triggered.
   This includes subcontractor manufacturing orders. Relevant test
   updated to match this.
2. When a MO is completed, auto check if there are corresponding
   confirmed stock moves that can be populated by the completed products
   and trigger their 'action_assign' to reserve the completed products.
3. If a new move line is added to an already confirmed MO, then do same
   auto-RR check/trigger. (note will occur for pickings without extra
   code since `stock_picking.action_confirm` is triggered again in this
   case.)

This reuses similar logic as odoo/odoo#52433 from task 2244230.
Originally this was done in the `action_assign`, but has been moved to
`action_confirm` so as to imitate the now archived MTO process with RR.
Overlapping logic has been moved into stock_move for easier reusability.
Note that this now means editing existing moves' `product_uom_qty` (i.e.
Demand) will not have a flow to auto-trigger their RR.

Subcontracting test updated to match + new mrp test added for this new
feature.

closes odoo/odoo#57334

Task: 2322496
X-original-commit: 2688cd1bae489b1dec8862f4de727ac20514844c
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-09-09 09:21:55 +00:00
Rémy Voet (ryv) 57f805f71e [IMP] stock*,mrp*: Dates Refactor
- The deadline of MO generated via procurements is calculated differently.
Now, it doesn't take anymore in account the manufacturing_lead
of the company (Security Lead Time of MO). The computation of planned date remains unchanged.
- The date_expected fields was duplicated with the date fields
except when the move was done. Merge both fields.
The only information lost is: we can't know what was the
scheduled date before processing move (`state` == done).
Indeed, the date becomes the actual move processing datetime.
- The `date` in `stock.picking` field contained the time of
(purchase) order `date_order` (`purchase.order`).
This field is was wrongly used in the kanban view where we
expected to see date_planned instead. Also, the `_order` used
this date instead of date_planned too.
- The `delay_alert` is activate independently of stock rules.
Then it is now activate in all case.
- Remove the auto-reschedulting process of stock move via
the stock rule (`propagate_date` and `propagate_date_minimum_delta`).
Replace it by a automatic deadline date (`date_deadline`) propagation.
The deadline is the promise done to/by vendor/client (SO/PO)
then it is a readonly fields on picking/move and MO.
- Now the Scheduled date (`date`) of stock move is never propagate
and it is only related to the Scheduled date of
related document (MO or picking).
- Now when a move is created from procurement (sale),
`date_planned` = `date_deadline` - `security_lead`.
- The `delivery_date` of sale is no editable after confirmation
and propagate as the deadline to related stock move linked to order_line
- Adapt filter and decoration of MO and picking.
- Because we are the client in case of purchase (PO), the promise of vendor
can be not respected. Then we add the lead security to the deadline
(inverse the sale order logic) of PO picking (promise reciept date
+ security lead) to match with the replenishment.

task-2246665
2020-08-18 07:48:27 +00:00
yhu-odoo 7b8035563f [IMP] (purchase_)stock: reserve and replenish automatically
1. When reservation can't be done for some products, we automatically
evaluate their reordering rules and create the corresponding
replenishment document.
2. When receiving products in stock, automatically check if some stock
moves are available and assign them.

Task 2244230
PR #52433

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-07-28 09:47:04 +00:00
Tiffany Chang (tic) d25d320e0e [IMP] mrp,(purchase_)stock: allow replenishment with only stock module
This commit makes it so products can be replenished without any other
module. This is achieved by adding a "pull" rule to the default receipt
route generated when a warehouse is created. "Pull" rule is added to 1-,
2-, and 3-step receipt routes. Previous to this commit, an additional
module (e.g. purchase, mrp, etc.) was needed for a pull rule to trigger
with the existing receipt route rules. Replenishments can be triggered
via "Replenish" button in product form, recording rules (auto trigger),
and replenishment (manual trigger).

Additionally, this commit makes it so when other modules (mrp, purchase)
that handle replenishment are installed, this additional "pull" rule is
removed from the default receipt route to prevent undesired behavior
(e.g. MTO manufacturing components magically being received from no
where). Unfortunately this means 2 undesirable situations:

1. If a user adds adds/changes rules to the receipt route and then installs
   mrp or purchase then their additions/changes will be removed.
2. If a user removes either (when only 1 installed) or both of these
   modules then stock module will again not be able to replenish as the
   pull rule will not be re-added to the receipt route.

It is expected that these 2 cases do not need to be handled in most
cases or can be handled by advanced users.

Stock tests have also been updated to accomodate this new pull rule.

Specification 4 of overall inventory onboarding improvement task.
Task: 2220129
Related Enterprise PR: odoo/enterprise#10719
2020-06-18 08:33:22 +00:00
Arnold Moyaux 943da6df0f [IMP] stock, purchase_stock, mrp: Replenishment Report
New report to easily order missing products in each warehouse.
Orderpoint have a new type: 'manual'. Manual orderpoint are not
trigger by the scheduler but the user could create replenishment
from the report directly. The report use the forecast report in
order to detect missing quantity for today (it does not search
depending the lead time for each product warehouse due to lake
of performance). It compares missing quantity with incoming RFQ
and other ongoing orderpoint. If it still missing a new entry
for replenihsment is created (it's also automaticaly deleted if
the replenihsment has been done another way).

Task: 2161378
2020-04-22 07:52:45 +00:00
Arnold Moyaux 56efb55057 [IMP] stock, mrp, purchase_stock: RR check forecasted stock
When the scheduler runs, each orderpoint will check the forecast stock
for an infinite time. As example, if we plan a receipt of 10 products in
4 months and need to deliver 5 products next month, procurement will not
be launched since we have a forecasted quantity of 5.

In order to improve it, the orderpoint will compute the total lead days
from rules, suppliers/production delays, security days,...
Those lead days will be added to today in order to know at which date
the forecast stock should be checked and trigger the replenish document
for today in order to be delivered at the correct date.

Task: 1849912
2020-01-09 16:09:12 +00:00
Arnold Moyaux bdc2280309 [REF] stock: perf orderpoint as batch
Currently orderpoint run one request at a time. However it's not
efficient since compute are some private methods could be executed
one time in batch instead of record by record.

The strategy in order to improve it is:
- Still cut the orderpoints in batch of 1000 (usefull when using a new
cursor with intermediate commit)
- For each batch of 1000, create a list of procurement values and run
them in batch (commit a2a6b099a4 for more info)
- Each time a procurement exception is raised, catch the failing
orderpoint and rollback to the state before run. Remove the failing
order point from the current set and run it again.
- run method try to catch a maximum  errors by continuing to process even it
finds error in order to stack them. It would avoid to run the same set
again and again each time an error is raised.

test_orderpoint_1 took 975s before this patch and 100s after.

Task: 1849912
2020-01-09 15:59:12 +00:00
Julien Castiaux 4f03a5f136 [FIX] *: remove old deprecated modules/functions
PEP-594 is deprecating a bunch of modules. As part of the cleanup, we
are also dealing with long deprecated modules, functions and aliases.

* `assert_` -> `assertTrue`
* `assertEquals` -> `assertEqual`
* `assertNotEquals` -> `assertNotEqual`
* `assertAlmostEquals` -> `assertAlmostEqual`
* `assertRaisesRegexp` -> `assertRaisesRegex`
* `assertRegexpMatches` -> `assertRegex`
* `base64.encodestring` -> `base64.encodebytes`
* `base64.decodestring` -> `base64.decodebytes`
* `inspect.getargspec` -> `inspect.signature`
* `inspect.formatargspec` -> `inspect.signature`
* `logging.warn` -> `logging.warning`

closes odoo/odoo#36863

Task: 2003936
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-17 11:36:42 +00:00
Hetashree Chauhan a31ee1c0c6 [IMP] stock: pass tests without demo data for file proc_rule.
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
William Henrotin 8e62c63a73 [FIX] mrp: increase tolerance date tests
The tests relative to workcenters planning takes (sometimes) long time
to be executed. Before investigation more deeply, this commit relax a
bit more the tolerance delta in the test comparison

closes odoo/odoo#33939

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-06-11 08:32:30 +00:00
William Henrotin 870a70eba5 [FIX] stock: relax datetime test
The comparison of two datetimes is never exactly perfect. This commit adds
one second tolerance in the tests between two dates to ensure any false
positive result is avoided

closes odoo/odoo#33817

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2019-06-03 08:47:08 +00:00
Haresh Shyara c514e8ae6a [REF] stock: rescheduling propagation
This commit moves the "propagation minimum delta" from a company setting to a
per-rule setting.

We implement this idea in the stock module and take this opportunity to clean
up the override of stock move's write.

We add a few basics tests.

task-1913401
2019-05-29 12:48:52 +00:00
Christophe Simonis 9c77066f34 [MERGE] forward port branch saas-11.4 up to 6c103589c1 2018-09-14 16:00:17 +02:00
Christophe Simonis f3fa5a5ef7 [MERGE] forward port branch saas-11.3 up to 1e0a92c996 2018-09-13 19:30:33 +02:00
Christophe Simonis 87b3ca13bf [FIX] stock: correct tests to create pickings without using new() 2018-09-12 16:15:04 +02:00
Darshil Trivedi 827958a890 [REF] stock: rename procurement.rule to stock.rule
This commit is related to task ID 1852969.
2018-07-19 14:43:08 +02:00
Darshil Trivedi a35df8d371 [IMP] stock: merge push and pull rules
Usability improvement:
- Common view for push and pull rules
- Add an help text in order to describe the rule
- Rules menu
- Warehouse checked by default on route created by a warehouse
- Lower the MTO route sequence in order to take it first.
- Tooltip cleaning

Technical improvement:
The purpose of this task was also to merge stock.location.path(push rule) and
procrement.rule. Those two model were design to execute the same task
but in a different direction. Thus it contains duplicate code.

Task ID 1852969.
2018-07-19 14:43:08 +02:00
Yannick Tivisse bdbc7a6287 [IMP] stock: Convert yml file to python and xml 2017-11-16 14:49:06 +01:00