Commit Graph
251 Commits
Author SHA1 Message Date
Guillaume (guva) 20a82cf35a [FIX] mrp : MO set to close before finished
Step to reproduce :

- Create a Manufacturing Order for several pieces of a product with a
work center routing
- Open the Work Order which has been created
- The Manufacturing Order is set to 'to close', instead of 'in progess'

Cause of the issue

The state of the MO was never computed based on WO status.

Solution

The state of a MO is set to 'to close' when a WO is set as 'done'
or 'cancel'

opw-2584446

closes odoo/odoo#74411

X-original-commit: c237c9c3214b58d303a8597df2c836872c5e522c
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Signed-off-by: guva-odoo <guva-odoo@users.noreply.github.com>
2021-07-30 09:02:43 +00:00
Tiffany Chang (tic) 1e2c03a47d [FIX] mrp: lock MOs by default
Previous specification of making MOs unlocked by default was confusing
for users and made it too easy to accidentally change the qty to consume
rather than the consumed amount. This fix makes it so MOs are now locked
by default and will be unlocked/locked (including existing draft /
confirmed / in progress MOs) automatically when setting is changed.
Previous setting (Lock Quantities To Consume) has been repurposed for
this. When setting is active, no lock/unlock button will be visible to
match the updated setting description (i.e. non-done MOs can
never be locked).

Task: 2518523
ENT PR (only fixes test): odoo/enterprise#19732
Upgrade PR: odoo/upgrade#2655
2021-07-26 11:57:50 +00:00
Guillaume (guva) 7466779f2b [FIX] mrp: issue with products with variants
Step to follow

- Create a product with 2 variants and set route to Manufacture
- Create a BOM for the product
- Create an MO for one of the variants
- Save (in Draft State)
- Edit
- Change to the other variant
- Confirm
- Finish the MO Order
- Look at product moves on MO

Cause of the issue

In MrpProduction._onchange_move_finished method, self.move_finished_ids
was not empty before being assign.

Solution

Removed the records from self.move_finished_ids before
 assign another one to it.

opw-2572644

closes odoo/odoo#73563

X-original-commit: 5e34a02c3d897d888bf52b1977c25047326b76a8
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: guva-odoo <guva-odoo@users.noreply.github.com>
2021-07-16 07:44:28 +00:00
Rémy Voet (ryv)andnouraellm ae7e5960f1 [IMP] mrp: update workorder readiness behavior
- The work order state changes based on the availability of the components
- So if all BOM components are available the state of the first WO is set to ready
- The color of ready in the WO tree editable view will stay blue as long as done reserves the green color
- If one or multiple components are not available, the state of the first WO is set to waiting
- The color of waiting in the WO tree editable view is set to orange
By default to launch takes workorder_ready_count so it counts only ready WOs
- The user can always process the WO without restrictions even if the WO state is waiting

Task-2426773

closes odoo/odoo#71250

Related: odoo/enterprise#18523
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Co-authored-by: nouraellm <nea@odoo.com>
2021-07-13 11:53:12 +00:00
Nicolas Pierre 8883c06ada [FIX] mrp,stock: use correct qty to backorder in MO simplified view
The problem arises when a user creates a backorder for a MO after
registering overconsumption of some components through the simplified view.
The quantities of the components of the new backordered MO are then wrong.
Components that were over consumed in the first MO will have smaller
quantities in the new MO, the difference being the amount over consumed.
This problem does not appear in the case of the Tablet View where a proper
recalculation of quantities is done.

closes odoo/odoo#64911

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-06-02 10:26:28 +00:00
Adrien Widart 493fc880d1 [FIX] mrp: use work center's TZ to plan operations
When planning a Manufacturing Order, if an operation takes place in work
center with a different time zone, the computed date may be incorrect
(the start date may be outside the working hours)

To reproduce the error:
(Use demo data. Current timezone: Europe/Brussels)
1. In Settings, enable "Work Orders"
2. Open an existing Work Center
3. Click on "Standard 40 hours/week"
4. Set Timezone to "Asia/Bangkok"
    - Note that all slots are between 8:00-12:00 and 13:00-17:00
5. Create two storable products P_compo and P_finished
6. Create a Bill of Materials BM:
    - Product: P_finished
    - BoM Type: Manufacture this product
    - Components: 1 x P_compo
    - Operations: 3 x Operation with existing work centers
7. Create a Manufacturing Order:
    - Bill of Material: BM
    - Quantity: 100
8. Save, Confirm, Plan

Error: (it depends on the time the test is done) The 'Scheduled Start
Date' of the second operation is incorrect. Adding the time zone
difference gives a time that is outside the work center's timetable
(i.e., outside 8:00-12:00 and 13:00-17:00).

The computations do not consider the time zone of the work center.

OPW-2393330

closes odoo/odoo#71332

X-original-commit: dab24e497f095d0c7857f07d037e9cb16749e2ea
Related: odoo/enterprise#18572
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-05-27 12:23:37 +00:00
Adrien Widart afda66598c [FIX] mrp: use correct UoM for each component in MO
In a Manufacturing Order, the components' quantities are rounded using
the rounding precision of the produced product's UoM. This leads to
incorrect values.

To reproduce the error:
1. In Settings, enable "Units of Measure"
2. In UoM, edit Units:
    - Rounding Precision: 1
3. Create two products P_finished and P_compo
    - P_compo's Product Type: Consumable
    - P_compo's UoM: L
    - P_finished's UoM: Units
4. Create a Bill of Materials
    - Product: P_finished
    - 1 Component:
        - Product: P_compo
        - Quantity: 0.2
        - UoM: L
5. Create a Manufacturing Order:
    - Product: P_finished
6. Confirm, Mark as Done

Error: Qty to consumes became 0 and consumed qty is 0. Both values
should be 0.2L, but they have been rounded using the rounding precision
of Units

OPW-2529462

closes odoo/odoo#71293

X-original-commit: aff3a2e06801dfb7a58df5180fb4ab5487b27f02
Signed-off-by: Steve Van Essche <svs-odoo@users.noreply.github.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-05-26 17:12:08 +00:00
Tiffany Chang (tic) f135171b61 [FIX] mrp: prevent MO validation with no consumption
If a MO is validated with all of its (component)
move_raw_ids.quality_done = 0, then when trying to validate the
nonsensical "The quantity to produce must be positive" validation error
will occur. This is due to all move_raw_ids being marked as Cancelled,
which auto-updates the MO state to cancelled, which prevents the
validation from properly completing.

To avoid this error, we prevent the user from having 0 consumption for
all components.

Task: 2422698
Related (v13 fix + bug description) Task: 2463893
ENT PR (test fixes): odoo/enterprise#18355

closes odoo/odoo#71068

X-original-commit: 81ba7084aeb3899787d083a2a2568a490f9c53e5
Related: odoo/enterprise#18411
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Tiffany Chang <ticodoo@users.noreply.github.com>
2021-05-19 17:26:18 +00:00
Tiffany Chang (tic) bf5e1debf9 [FIX] mrp: allow confirming of MOs without components
Prior to this commit, MOs would throw a usererror if there were no
components in it. This restriction made it so MOs created by a
replenishment (i.e. `warehouse.orderpoint`) for a BoM with no components
were never confirmed and the `qty_to_order` would accumulate for each
replenishment's new draft MO.

Steps to reproduce:
1. create a bom for a new product (w/ manufacturing route) with no
   components
2. create and confirm a sales order for the new product
3. go to Replenishment and automate the product's replenishment
4. create a new sales order for the product

Expected result: 2 confirmed MOs where the quantity of the first MO
matches the first sale order's quantity and the 2nd MO matches the
second sale order's quantity

Actual result: 2 draft MOs where the first MO matches the quantity of
the first sale order and the second MO matches the quantity of the first
sale order + the quantity of the second sale order

This commit makes it so MOs can now be confirmed even when it has no
components. Note this requires changing the logic in a few locations to
ensure expected behavior still occurs including:
- backorders are automatically confirmed.
- `reservation_state` is recalculated when expected (will be blank when
  no components).

Task: 2422698
2021-05-19 06:47:22 +00:00
William Henrotin e43c424fd9 [FIX] mrp: split call to write on stock move
You can, in a production order, change the quantity done of a stock move
raw and change its initial demand ('To Consume' field) in the same
transaction. This can lead to some issue as changing the quantity done
will update the stock move line and changing the initial demand will
unreserve the stock move thus impacting the stock move lines too.

This commit will split the values to update of a stock in move in case
the two fields have to be updated. First the stock move lines, then the
initial demand.

This commit also remove the default_product_uom_qty in the move_raw_ids
fields. This ensure the onchanges do not create/edit any stock move lines
with some reserved quantity.

opw : 2451298

closes odoo/odoo#70975

X-original-commit: e8c1f6b1a3f58b68181bf4d2599bd37efb83b5c7
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-05-18 11:58:11 +00:00
Rémy Voet (ryv) b23edf5db2 [FIX] mrp: fix multi plan MO
The button plan of in the manufacturing order tree view doesn't
confirm correctly the draft MO selected (but only the related moves).

task-2479111

closes odoo/odoo#70608

X-original-commit: ef9515611ac96368eae14fc941bca15e3724557a
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-05-10 13:29:20 +00:00
Pratima Gupta 0626ad78ef [FIX] mrp: suggest the qty to produce instead of 0 in workorders
Before this commit, if any workorder is stared to produce, qty
producing was 0. After this commit, if product tracking is none
then system will suggest the remaining qty of workorder to produce
when user is start it.

TaskId - 2480775

closes odoo/odoo#70207

X-original-commit: 5bbc234d43a415be18fcfa42dad33b1577644719
Related: odoo/enterprise#18086
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-04-30 17:48:13 +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
yhu-odoo 729db008f5 [IMP] mrp: make mo under consumption consistent with picking
Considering the MO under consumption situation:
  component A, to consume = 2, consumed = 1
Previous, after "mark as done", the MO will have two lines:
  component A, to consume = 1, consumed = 1, state done
  component A, to consume = 0, consumed = 0, state done
Now, after "mark as done", it will be consistent with picking:
  component A, to consume = 1, consumed = 1, state "done"
  component A, to consume = 1, consumed = 0, state "concel"

Task 2446915
PR #66583
ENT PR odoo/enterprise#16554
2021-03-30 11:49:54 +00:00
yhu-odoo 0fc9e8fbcc [IMP] stock: no extra moves when over consumption
This commit is a revert of revert 561b3461a0
and 97ba860fd38c530d3f3678f676754862afad0f11.
Previously we split moves when no picking, now we consider it
unnecessary.

Task 2446915
COM PR #66583
ENT PR odoo/enterprise#16554
2021-03-30 11:49:53 +00:00
Nicolas Pierre fd19b0d7a2 [IMP] stock: replenishment using qty from the BoM
The replenishement creation currently calculates the quantity to order
using a default multiple quantity of 1. In case of manufacturing route,
we want to calculate the multiple quantity according to the quantity
produced in the BoMs.

closes odoo/odoo#62766

Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-02-18 11:51:18 +00:00
Goffin Simon f78e04e026 [FIX] mrp: Existing operations can only be added to one BOM
Generic operations will be applied for every manufactured product passing
through the work center.

An operation linked to a bom will only be applied when the specific manufactured bom is produced

So on a BOM, every operations must be created for this specific BOM

The widget many2many is wrong because it will overwrite the generic operations

opw:2458974

closes odoo/odoo#66888

X-original-commit: a430c06ec6ec286a2d9ef55de6eebec60feeae3f
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-02-25 21:49:19 +00:00
Goffin Simon 2ad6f4e14e [FIX] mrp: Existing operations cannot be added to BOM
Steps to reproduce the bug:

- Go to an existing BOM B
- Edit B and try to add an existing operation O in operations tab

Bug:

It was impossible to add an existing operation

opw:2458974

closes odoo/odoo#66712

X-original-commit: ffab43fbf54b2f914b34c18da2391f3a18b3326c
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-02-23 15:23:44 +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
Nicolas Pierre b03e900a40 [IMP] stock(_*), mrp: highlight PO/SO links on forecast report
Replenishment is great to replace MTO but misses the direct link between SO and PO (smart buttons on both SO and PO to link to the corresponding PO and SO).
The info is actually there in the forecasted report but it is not accessible directly from the PO and in the case of the SO does not highlight the corresponding line of the SO.

This adds a graph icon in the PO, MO and receipt form to directly access the forecasted report (it already exists for SO and delivery).
The information linked to the SO/PO/MO/receipt/delivery is also sent to the forecasted report to highlight the corresponding line.
Note that in the case of the SO, the information needs to go first through the qty_at_date widget (which contains the link to the forecast report).

The graph icon for the PO, receipts and MO turns red when the forecasted quantity at expected date is negative. This is done using the new 'forecasted_issue' field.

closes odoo/odoo#62264

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-02-09 13:41:27 +00:00
Denis Ledoux e402cd496f [FIX] mrp: qty_available computation of a kit and its component
When `qty_available` was being called
for a kit and its components at the same time,
e.g.:
 - Kit product
   - Product 1
   - Product 2

The kit product available qty was always computed to `0.0`,
because when computing its component available quantity,
they were computed to `0.0` because they were marked
as `protected` by the ORM when calling the compute method
for these records at the first call.
When the `qty_available` compute method for the kit
then called recursively the `qty_available` compute
method for the component, as the component record
were marked as protected,
the ORM filled their value with the Falsy value `0.0`.

This issue occured particularly in the upgrade integrity unit test
which makes sure the available quantities of the products remain
unchanged after upgrade. This test computes the available
quantities for a bunch of products at the same time,
and its therefore likely a kit product gets its available
quantity computed as the same time than its components.

upg-3185
upg-4215
upg-4228
upg-5558
upg-5745
upg-5856
upg-6012
upg-6064
upg-6076
upg-6306
upg-6514
upg-6588
upg-6729

closes odoo/odoo#65758

X-original-commit: 8e152a567a6003dae4abb3b537b963eec4142d6d
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2021-02-08 18:58:04 +00:00
Rémy Voet (ryv) 4d57ce473b [REF] mrp: clean BoM operations
- make `bom_id` required. No sense to have a operation without BoM
- `company_id` of operation is now related
- Clean the multiple `allowed_operation_ids` into related
fields instead.

task-2373638
2021-01-05 08:32:58 +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 Galler 3700b9b38b [FIX] mrp: update date on move when editing date after planning WO
Behavior prior to this commit:

 - normally when editing the Scheduled Date on a MO, the date on the
 related stock moves is updated.  However this does not happen once the
 MO is planned
 - if the date is edited and the MO is planned, the MO is automatically
 unplanned, but the date on the stock moves is not automatically updated

Behavior after this commit:

 - when the date is updated on the MO and it is planned, the dates on the
 stock moves will automatically update, so that the behavior is
 consistent with how it would work if you clicked Unplan first then
 updated the date.

Note:

 - this commit is forward ported from 14.0.  Only the unit test was
 ported, as the behavior had already been modified to match the
 expectation.

opw-2417108

closes odoo/odoo#64006

X-original-commit: 97f79960dbb3aa371378f576cfdce9670ca8ccce
Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
2021-01-04 12:20:51 +00:00
Tiffany Chang (tic) c7f53f770c [IMP] mrp, (purchase_)stock: improve move reservation
Currently stock moves are auto-assigned (i.e. reserve free stock) both
when the scheduler is run and when a corresponding stock move that can
assign a move is completed. This strictness was causing issues for
prioritization of moves to assign, for example a picking with a
scheduled_date far in the future could automatically reserve all stock
if it was created before another picking that an immediate
scheduled_date. To ease this, an extra setting has been added to
stock.picking.type to let users choose how reservations should occur for
moves assigned to that picking_type (or picking with that picking_type):

1. 'at_confirm' = automatically when:
   - stock is available when the move's associated picking/MO is
   confirmed,
   - when new stock becomes available,
   - when the scheduler is triggered (+ stock available).
2. 'manual' = user must always manually click "Check Availability"
   button (scheduler will no longer reserve).
3. 'by_date' = automatically when within the move's reservation_date
   and:
   - stock is available when the move's associated picking/MO is
   confirmed,
   - new stock becomes available when move is already confirmed, or
   - the scheduler is run (+ stock is available).

'by_date' has an extra option of # days before the move's scheduled
date that affects the move.reservation_date.

Task: 2359317
Upgrade PR: odoo/upgrade#1868
ENT PR: odoo/enterprise#15050
2020-11-30 16:28:47 +00:00
Nicolas Galler f060e3df0a [FIX] mrp: carry over origin from source move in 3-step mfr
Behavior prior to this commit:

- when the warehouse uses a 3-step manufacturing process, if I create a
Sales Order, the MO generated does not show the SO# as "Source", instead
it shows the MO#

Behavior after this commit:

- the MO source shows the SO# (similar to how it works when using the
2-step or the 1-step manufacturing process)
- the origins are assigned thus:
  - Delivery Picking = SO name
  - Post-prod Picking = SO name
  - MO = SO name
  - Pre-prod Picking = MO name

Note:

- there is no implementation change in this commit - we just ported the
test from the original commit in 13.0 (the behavior in 14.0 was already
OK)

opw-2380717

closes odoo/odoo#62512

X-original-commit: 0281dee6da75e68403772ebd368d57c1feb98c37
Signed-off-by: Nicolas Galler <ngaller@users.noreply.github.com>
2020-11-27 11:13:33 +00:00
Fanny He ccb6b26336 [FIX] product, decimal_precision, stock, mrp: Prevent quant reservation issue
One can set a Unit of Measure precision rounding more
precise than the overall Decimal Accuracy. This can trigger the error
'It is not possible to unreserve more products', as there will be
inconsistencies on reserved quantities due to decimal roundings.
We add 2 warnings on Units of Measure and Decimal Accuracy.
Therefore, users are warned when their UOM/decimal changes can
cause inconsistencies in quants reservation.

Also, we want to prevent the issue at the root by ensuring that both the move
and the quant have the same reserved quantity.
The contrary can happen e.g. when a product is defined in Liters (rounding .001)
but used in an operation in ml (rounding .01, so e.g. 187.5ml).
The conversions between the 2 UOM can cause the differences of reservations.

In _prepare_move_line_vals we make sure uom_quantity_back_to_product_uom
is not more precise than the overall Decimal Accuracy. That way, if
the reserved quantity changes between UOM conversions, the move line created
is in the quant/product UOM, and we do not have move line's reserved quantity >
quantity in stock.
We do the same for _update_reserved_quantity (stock.move), when updating
a move line.

In _update_move_lines, because of UOM conversions, new_quantity_done
can differ from ml.product_uom_qty, which triggers the creation of an extra
move line, leading to reserved quantity > quantity in stock. To prevent
that, we compare the reserved quantities in the product UOM.

opw 2206902 (Example 1)
opw 2171541
opw 2221227
opw 2233937
opw 2198775
and many more

closes odoo/odoo#62279

X-original-commit: 478a42beb5876171afeab7df27fa69548edbf849
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-11-24 19:06:39 +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
Nicolas Galler 4c2a03aa8f [FIX] mrp: validate BOM lines with same product as BOM
Current behavior before PR:

It is possible to create a BOM that has a BOM line that reference the
same product as the BOM itself.  This is undesirable as when we create a
manufacturing order for this product we will have an error.

It is a regression bug that was introduced in commit
575353e251a0cce3bbff759edaeb56b5718beb11 between v12 and v13.

Behavior after PR is merged:

When saving a BOM it will validate that no product line references the
same product, or the same product variant, as the BOM itself.  Note that
it is allowed to have a BOM for a product variant that references
another variant of the same product.

opw-2347941

closes odoo/odoo#59633

X-original-commit: 917e4c67b4aa14ca71ec6cba4bc6d20a86459f42
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-10-09 12:05:27 +00:00
William Henrotin 0c6d8ecfaf [FIX] mrp: no finished move management
This commit makes sure we do not try to update the quantity on a
finished stock move (during record production or confirming the produce
wizard) if there is no finished move available.

Closes #57227

closes odoo/odoo#59430

X-original-commit: 141df3b398aee2bac10e3ce94e15bb4bd14d17af
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2020-10-07 15:00:34 +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) 2270406c48 [FIX] mrp: force the UoM in case of serial number tracking
In case of manufacturing a product tracked by serial number,
there is no reason to be able to make it with a different UoM of
the product (which lead to rouding issue).
Then when we confirm the MO in this case, the UoM and quantity
will be converted to product UoM.

PR #56000

closes odoo/odoo#57333

X-original-commit: f0da27e7eb474e6db4cd999306c420804aaa6f9b
Related: odoo/enterprise#13059
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-09-09 09:21:12 +00:00
yhu-odoo 2c5ce41c42 [IMP] uom: change default rounding to two
Change the default rouning digits of all UoMs to be two, also change the
decimal.precision of UoM to be two. Adapt all the tests.
Also to avoid hardcoded digits in `should_consume_qty` widget.

PR #56000

X-original-commit: 460ec0402a2352a5b179d81935f7230f6bc97cb7
2020-09-09 09:21:12 +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
JF Aubert 9b53ab050d [IMP] mrp,stock: allow to encode lots in a m2m on the move
Allow to add serial numbers as tags on the move in production order and
stock picking. The purpose is to earn time for database with
only tracking installed.

Also when only create_lots is checked on picking type. New lots
could select existing lot and an onchange trigger a warning if
it's used.

closes odoo/odoo#55883

Task: 2280985
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-08-18 13:51:25 +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
William Henrotin 963ad5eada [FIX] mrp: keep duration ratio
Updating the quantity to produce on a production order will recompute
the expected production duration. This can be counter productive on
prototyping production when no BoM are given. The default expected batch
duration is set to 60 minutes. Setting the actual production time then
updating the quantity to produce will naively change the duration to
60 x the new quantity.
This commit compute the duration pro rata in case of 'no BoM' production
and recompute everything in case of BoM production.

Task : 2278147
2020-08-10 09:40:24 +00:00
William Henrotin 68f06c7acc [FIX] mrp: copying production order copy all moves
Before this commit, only the moves raw were copied on production
duplication. As the finished move is created normally in an onchange,
this means a production order duplicated have not any move finished.

Task : 2278147
2020-08-10 09:40:24 +00:00
William Henrotin 49e8fe82af [FIX] mrp: delete finished move at onchange
Changing the Bom on a production order will erase all the raw moves to
recreate the new ones. This commit make sure the finished product are
erased as well.
Before this commit, if the product was changed with the BoM. The first
finished product became a byproduct for the second one.

Task : 2278147
2020-08-10 09:40:24 +00:00
William Henrotin 1cc0af304f [IMP] mrp: replan workorders on delays
In a scenario parent mo <-> child mo, delaying the production start on
the child mo will delay the parent start but not the parent's workorders
This commit will replan the workorders each time a planned production is
delayed.

Task : 2278147
2020-08-10 09:40:24 +00:00
William Henrotin a6cd4d8c8c [IMP] mrp: immediate production
This commit introduce the immediate production mechanism. As it works on
stock.picking, marking a (some) production(s) as done without consuming
anything will pop a wizard allowing the user to transfer all the reserve
component quantities as done quantities.

Task : 2278147
2020-08-10 09:40:24 +00:00
Arnold Moyaux 69eaaac3a1 [IMP] stock: Hide Replenish on Order routes
Improve onboarding by removing the replenish on order route.
Companies that do MTO process could unarchive the route in
order to have a basic configuration.

closes odoo/odoo#55147

Task: 2245882
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-08-03 07:43:05 +00:00
svs-odoo 372b900fe3 [IMP] mrp: forecast widget
Add the forecast widget for the manufacture orders' components.

task-2058495
2020-07-31 12:36:55 +00:00
svs-odoo 832af92115 [IMP] mrp: extend replenishment report for mrp
Adds the Manufacturing Order as replenishment/consuming document for the
replenishment report.

task-2058495
2020-07-31 12:36:54 +00:00
fw-bot 679a746b78 [FIX] mrp: avoid consumption check for null additional components
Adding additional product to a production but consuming 0 on it will
trigger the consumption warning wizard while no difference with the bom
are occurring. This commit do not trigger the consumption issue in that
case.

Task : 2278147

closes odoo/odoo#54561

Related: odoo/enterprise#11885
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-07-16 13:39:30 +00:00
Simon Lejeune 249a1a7541 [FIX] mrp: bunch of fixes
Bunch of last minute fixes including:
- serial handling in tablet view
- expected durations and backorders
- button unplan unlinks the leave but the computed aren't recomputed
  then we need to manually set the date_planned_start/finished
  then we need to not propagate them on the related document
  (move/production) because they are required
- operation company_id wrongly set

task-2241471
2020-06-15 16:59:42 +02:00
Arnold Moyaux 556a905166 [REF] mrp: byproduct onchange
Create the byproduct moves at the onchange.

task-2241471
2020-06-15 16:59:41 +02:00
Arnold Moyaux ed7012e8fd [REF] mrp: workorders for enterprise
Removed abstract workorder

Removed the integration of expiry wizard in tablet view since it should
be moved in enterprise in the tablet view implementation (not possible
to set consumed lot on workorders on community anymore)

Refactor _set_quantity_done to use ORM command in order to not return a
dict with vals to_create/to_write

task-2241471
2020-06-15 16:59:41 +02:00
Rémy Voet (ryv) 328efb085a [REF] mrp: plan fields refactor
- The Scheduled Date can't be change if the MO have some planned WO.
(WO defines the scheduled date of the MO)
- Now the Scheduled Date 'date_planned_start' is set by default
with the deadline date if there is or now if there isn't (same than before).
- For MO, 'plan_date_finished' is now invisible. But keep the field
because it is used to set the date_expected of finished moves.
- Change the plan behaviour: Plan depending of the scheduled date if
this one is bigger than now, else try to plan as soon as possible.

task-2241471
2020-06-15 16:59:41 +02:00
Arnold Moyaux 182f1b8e26 [REF] mrp: workorder onchange
Create the workorders at the onchange when setting the bom and not a
"plan" anymore.

task-2241471
2020-06-15 16:59:41 +02:00