Commit Graph
1208 Commits
Author SHA1 Message Date
Triet Ngo d494f5988a [IMP] mrp: Add setup/cleanup time to Workcenter Specific Capacities
- Add columns setup/cleanup time to Specific Capatities of Workcenter
- Take into account these 2 fields when compute expected duration in WO

task-2925474

Part-of: odoo/odoo#97588
2022-09-02 14:17:59 +02:00
Triet Ngo e2d4586ac7 [IMP] mrp: Improve UI of Manual Consumption field on BOM
Auto mark manual_consumption as True as soon as the component is use in
an operation and make the field read-only

task-2925474

Part-of: odoo/odoo#97588
2022-09-02 14:17:58 +02:00
Triet Ngo dae82e7aae [IMP] mrp: UI Fix for Lot/serial column in MO form view
The commit modifies the following:
- add tooltip : 'Displays the consumed Lot/Serial Numbers consumed.'
- Change the column Serial Numbers to also display lot number
- Make the column read-only

task-2925474

Part-of: odoo/odoo#97588
2022-09-02 14:17:58 +02:00
William Henrotin 2c91ad3ae8 [FIX] mrp: remove onchange in import hack
Since d7716f071d, the onchanges to create the stock moves in mrp
production have been replaced by computes.
There was a hack in the create() method to trigger the onchanges in case
of import. As those onchanges do not exist anymore, this hack needs to
be remove too.
The compute methods are called naturally in imports.

closes odoo/odoo#99434

Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-09-01 19:17:36 +02:00
kir-odoo 3bb348bdde [FIX] mrp: mo split and merge fix
This commit fixes two bugs:
1) Wrong source location

    Before this commit:
    - Source location is incorrect after merging MOs and 3-step manufacturing is selected.
    - Operation type is incorrect after merging MOs

    After this commit:
    - Set the source location from the correct picking_type's value while merging MO.
    - Set the Operation type for the merged MO to be the same as the original MOs';

2) Traceback when splitting mo

    Before this commit:
    - When splitting a MO without a "responsible user" set then boom it's throwing traceback

    After this commit:
    - The "responsible user" is no longer required which matches the existing MO behavior

TaskID - 2754217

closes odoo/odoo#99374

X-original-commit: 67e3f2f66aeb1aa1a93ad5091af7c0375f6d9a93
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-09-01 15:33:15 +02:00
Stefan-Calin Crainiciuc (stcc) 592f39eba4 [FIX] mrp: scraps have wrong destination location
Steps to reproduce:

- Manufacturing app > Operations > Manufacturing orders > Create
- Set product to [FURN_7800] Desk Combination > Save > Confirm
- Click on scrap, choose any product > Done
- Edit the manufacturing order > set the quantity to 1/1 > Save

An error pops up: You cannot change the UoM for a stock move that has
been set to 'Done'.

This happens because the scrapped product has its destination location
wrongly set to the production location of the manufacturing order.
Because of this, it is considered as a component of the manufacturing
order. The scrap is also confirmed right after creation, so its state
is set to 'done'. Finally, when confirming a manufacturing order, all
of its component moves are also confirmed, hence the error.

This commit prevents the override of the scrap's destination location,
so that it is not wrongly considered a component anymore.

The commit also adds tests for the override method, added in
commit 0b247ab17ccc5be0c2058ef92ccf3502c97e0bb3

opw-2945182

closes odoo/odoo#99218

X-original-commit: 81820d4df5f23d9b6b2701e513ada89b528a865a
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-08-30 21:25:25 +02:00
Tiffany Chang (tic) e4988b70ab [IMP] stock{_account}: add reference opening magic in list view
The move line form view is too technical for the average user so instead we
can to auto-magically open the reference document instead (picking or MO
only for now).

We do the same with stock valuation layers as well, but this feature
will not be available until its custom JS is converted to OWL

"product moves" part of b2b task: 2882539

closes odoo/odoo#97109

Related: odoo/enterprise#29974
Related: odoo/upgrade#3819
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-08-29 23:46:36 +02:00
clesgow 2b2a7712e1 [IMP] mrp: Add automatic Days to Prepare MO
Since the new Overview report can compute the lead days and availability
delays from a BoM and all of its components and/or subassemblies, we can
use this data to compute the days that would be required to resupply all
components from a BoM.

So we add a button to compute it directly on the product form.

Task-2628323

Part-of: odoo/odoo#93194
2022-08-26 17:16:42 +02:00
FrancoisGe d531848034 [REF] mrp: Convert MrpFieldOne2ManyWithCopy to owl
The legacy field MrpFieldOne2ManyWithCopy added a control create
that performed an action when clicked.
In the new listRenderer we have added the possibility to define control
action buttons. So it is no longer necessary to create a custom field
for this use case.

Part-of: odoo/odoo#97558
2022-08-23 16:28:57 +02:00
Touati Djamel (otd) f4e9e15618 [FIX] mrp: avoid a traceback when using SN in a transfer
Steps to reproduce the bug:
- Go to Inventory→ Configuration→ Warehouse Management →Operations Types
- Go inside “Receipts”, and enable the checkbox “Create New Lots/Serial
Numbers for Components” and `Use Existing Lots/Serial Numbers`under the
traceability section
- Create a receipt transfers with a traceable product
- Mark as to do the transfer
- Try to add a SN for the product

Problem:
Traceback is triggered: “key error: raw_material_production_id”
because we use this field to add it in the context from the parent in
the `stock.move.line` view:
https://github.com/odoo/odoo/blob/15.0/addons/mrp/views/stock_move_views .xml#L53

But this field is not present in all views of the `stock.move` model

Solution:
To avoid adding this field in all the `stock.move` views, it is better
to add it in the context from the `python` code

closes odoo/odoo#98110

X-original-commit: 545713ae0a559e7f2747dd3cb4211ab752e1ef0c
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-08-16 09:19:28 +02:00
JF Aubert 144dd4c7f9 [FIX] mrp: fix workorders duration expected
_split_productions wrongly compute duration expected.

task: 2925901
related to task 2884562

closes odoo/odoo#98029

X-original-commit: fb1abddb20131f087d39abd1b87e920acd7282a4
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-08-12 11:29:00 +02:00
Nicolas Pierre 92744b7895 [FIX] mrp: allow creation of QC for MO backorders
Since https://github.com/odoo/odoo/pull/77254, Quality Checks are not
created on the backorders of a MO because the moves of the backorders
are not confirmed anymore. We therefore create the QC of the backorders
at the confirmation of the workorders.

closes odoo/odoo#97296

Task-id: 2901900
Enterprise-pr: https://github.com/odoo/enterprise/pull/29476
X-original-commit: 702dd5c902c40972e4362d28c8f10a1eb911a241
Related: odoo/enterprise#30033
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-08-02 13:06:36 +02:00
Fabien Pinckaers 3363e55cac [IMP] cleanup of help messages in all modules
This commit aims at removing unuseful help message to:
1/ reduce translators work, to focus on more useful translations
2/ not sending unuseful information in load_views
3/ reduce help message to useful messages, so that we can mark
   fields having a tooltip in the future UI.
4/ some cleanup of existing messages too

The main use cases:
- REMOVED: help redundant with the field name, providing no extra info
- MOVED TO COMMENT: technical help messages, that should not be in UX

closes odoo/odoo#97279

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-08-02 00:26:53 +02:00
Touati Djamel (otd) 2ab878aecb [FIX] mrp: do not confirm empty production with MTO rule
Steps to reproduce the bug:
- Create a storable product “P1”:
    - routes:
        - MTO
        - Manufacturing
- Create a SO:
    - Select the product “P1”
    - Confirm the SO

Problem:
The created MO is in confirmed state instead of draft.

This blocks the user, for example imagine that he has configured
the product with a first BOM without components and 2 others with
components. when the MO is created, the first bom will be selected,
and as the MO will be confirmed, the user will not be able to
select another BOM

Solution:
Since the MTO rule is not linked to an order point, we could be more
flexible, so the production created via `_run_manufacture()` without
bom or with a bom without component and operation via the MTO mechanism
will not be confirmed

opw-2897267

closes odoo/odoo#97099

X-original-commit: c623478aba040c0493e6da8a67c9742880572199
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-07-29 17:13:02 +02:00
PNO 33ed562cab [FIX] mrp: Wrong replenishment order notification
On the commit 69dcdd4, the order='create_date desc'
 was removed and the way of getting the MO for the notification changed. Now, the context is used, it should be written_after instead of written_date.
(The MO created is correct, only the notification is wrong)

OPW-2877457

closes odoo/odoo#96856

X-original-commit: b80287b265a4c01babedcbb58459c35d36a48066
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-07-28 05:04:26 +02:00
odoo 3d7247ad4d [FIX] mrp: don't miscount child/parent MOs in 2/3 Step Production
Steps to reproduce the bug:
- Enable 'Multi-Step Routes' option in Inventory settings
- Edit warehouse and update Manufacture = 'Pick components, manufacture and then store products (3 steps)'
- Create a storable product 'P1' with BOM:
    - BOM type: Manufacture this product
    - operations: “OP1”
    - Components: product 'C1' consumed in the operation 'OP1'
- Set Reordering rules for product 'P1'
- Run Scheduler and MO will be generated with order points
- Edit MO and add Producing Quantity less than to produce
- Validate the MO and create backorder.

Current behaviour:
- child/parent MO were getting visible when backorder was created in 2/3 Step Production.

Expected behaviour:
- No child/parent MO visible until child/parent relations are there

closes odoo/odoo#96533

Task: 2846768
X-original-commit: 14431b2497dcf4aaf778ef1b06e023101b00a4e2
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-07-22 16:22:06 +02:00
JF Aubert 3ced21cf87 [FIX] mrp: fix duration expected
_split_productions wrongly compute duration expected for backorders.

Setting quantity on production adapt many things including workorders,
so adapt original production after copy_data for backorders.

closes odoo/odoo#96179

Task: 2884562
X-original-commit: 71b8531881ff6924762ec34db3f2ddf858383218
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-07-18 19:55:16 +02:00
Denis Ledoux cf664a5dc8 [FIX] mrp: mo creation with move_finished_ids without byproduct_id
When creating a new manufacturing order with `move_finished_ids`
passed in the values, but `byproduct_id` is not amongst the move values,
the creation of the manufacturing crashed.

```
  File "/home/odoo/src/odoo/master/addons/mrp/models/mrp_production.py", line 811, in create
    vals['move_finished_ids'] = list(filter(lambda move: move[2]['byproduct_id'] is False, vals['move_finished_ids']))
  File "/home/odoo/src/odoo/master/addons/mrp/models/mrp_production.py", line 811, in <lambda>
    vals['move_finished_ids'] = list(filter(lambda move: move[2]['byproduct_id'] is False, vals['move_finished_ids']))
KeyError: 'byproduct_id'
```

By reading the implementation of the byproduct moves field:
```py
    @api.depends('move_finished_ids')
    def _compute_move_byproduct_ids(self):
        for order in self:
            order.move_byproduct_ids = order.move_finished_ids.filtered(lambda m: m.product_id != order.product_id)
```
it seems a better implementation to filter the move on the fact their
product is different than the manufacturing order to determine whether
they are byproduct or finished product moves.

Take the opportunity to write a unit test testing the tricky behavior
of the create override when both `move_finished_ids` and `move_byproduct_ids`
are passed in the create values.

This is related to revision
odoo/odoo@6c087f2043

closes odoo/odoo#96044

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-15 14:22:08 +02:00
Touati Djamel (otd) a4c00c071f [FIX] mrp: allow using an unbuilt serial number in manufacturing order
Steps to reproduce the bug:
- Create a storable product “P1”
    - Tracking: by serial number
    - BOM:
        - Component: C1

- Create a storable product “P2”
    - BOM:
        - Component: P1

- Create a MO to produce one unit of P1:
    - serial number: SN1
    - Confirm and mark as done

- Unbuild the manufactured product
- Manufacture the same product using the same serial number again

- Create a new MO to produce one unit of “P2”:
    - Component P1 → select SN1
    - Try to confirm and validate the MO

Problem:
Get User Error: The serial number “SN1” used for component “P1”
has already been consumed

We do a search in the `stock.move.line` to find if the SN has already
been used in a previous MO, but there is no specific condition to get
only those used in an MO so the unbuild order is in the same condition
and therefore the SN is considered as it has already been used
opw-2883450

closes odoo/odoo#95935

X-original-commit: 5ac7f4d6fa5551ba7c6da49a52edf0a7df2d0745
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-07-14 11:42:57 +02:00
Touati Djamel (otd) 8467f7b9ff [FIX] mrp: allow selecting only the SNs linked to the MO
Stpes to reproduce the bug:
- Create a storable product “P1”:
    - tracking: Serial number
    - BOM: 1 unit of C1

- Create the MO 1:
    - produce 1 unit of P1:
        - Create the SN1

- Create the MO 2:
    - produce 1 unit of P1:
        - Create the SN2

- Create an Unbuild order:
   - Select the MO1

Problem:
You have the possibility to select any Serial number linked
to the product “P1”, whereas only SNs created in this MO can be selected

opw-2834529

closes odoo/odoo#95956

X-original-commit: 167b1668450c5af44bc1d36d1c7d59921bc2b811
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-07-14 10:22:51 +02:00
Denis Ledoux d369929d60 [IMP] mrp: convert unbuild uom and locations onchanges
This allows to create a mrp.unbuild record without
the need to call the onchanges to set the uom and locations
or to set them manually during the `create` call.

For instance, this makes easier to create unbuild orders
using XMLRPC when you do not use multiple UOMs or multiple locations.

closes odoo/odoo#95557

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-12 01:29:20 +02:00
Denis Ledoux 4abacd9cff [IMP] mrp: default workorder duration_expected without form/onchanges
With this revision, the expected duration is correctly set
when creating a production order with work orders without the need of
onchanges, through a form.

For instance, this allows an easier implementation to create a production
order with work orders through XMLRPC API calls,
as you will not need to manually set the expected duration value
or to call onchanges manually to set it.

For instance, without this change to remove the `default=60.0`,
the part added by this revision in the test `test_update_quantity_3`
would fail
```
2022-07-11 09:15:14,644 21 ERROR master odoo.addons.mrp.tests.test_order: FAIL: TestMrpOrder.test_update_quantity_3
Traceback (most recent call last):
  File "/home/odoo/src/odoo/master/addons/mrp/tests/test_order.py", line 347, in test_update_quantity_3
    self.assertEqual(production.workorder_ids.duration_expected, 90)
AssertionError: 60.0 != 90
```
while it just does the same thing than the existing `test_update_quantity_3` test
but without the use of a form / onchanges.

Part-of: odoo/odoo#95733
2022-07-11 20:25:11 +02:00
Denis Ledoux aa07793d9d [IMP] mrp: convert production order product, uom, bom onchanges
This allows to create a production order record without
the need to call the onchanges to set the product, uom or bom
or to set them manually during the `create` call.

For instance, this makes easier to create production orders
using XMLRPC when you do not use multiple UOMs.

closes odoo/odoo#95544

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-08 17:10:42 +02:00
Denis Ledoux b92d42b3ae [IMP] mrp: convert byproduct product_id onchange to compute
Convert the onchange on `product_id` to a compute field

This allows to create a `mrp.bom.byproduct` record without
the need to specify the uom during the creation nor calling the onchange
method. The uom defaults from the product uom.

This way, if the database is not configured to use multi UOMs,
the users do not have the specify the UOM to use.
For instance during an XMLRPC call to create a byproduct.

closes odoo/odoo#95270

Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
2022-07-07 11:22:52 +02:00
debu-odoo 6da6add464 [FIX] mrp,stock: UI fixes
Purpose of this commit to fix the UI in Manufacture app.

So, in this commit done following changes As suggested in Task:
    - Able to expand next activity column of MO list view
    - Added tooltip of default capacity field on work center
    - Added quantity tooltip of BOM

TaskID - 2689994

closes odoo/odoo#95315

X-original-commit: 463a81eb325f624e8947f1b3444947f8ba1dc24b
Related: odoo/enterprise#29113
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-07-05 13:53:55 +02:00
CarmenMiranda cd63ae6637 [FIX] mrp: Access Error on MRP Stock Picking Type
Now the way of access to an action is using the method `_for_xml_id` of
the model `ir.actions.actions` and not reading the action itself because
they need the access of the group "Administration/Settings" which not
all the users have it, so we were having an error with users that have
the permissions to see MRP Picking Types but they didn't have the group
mentioned above.

closes odoo/odoo#95312

X-original-commit: 1554fc9f8a98f4723b4f3cc1a8c0bd772c317ce5
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-07-05 13:53:46 +02:00
Adrien Widart 9da9ad2a80 [FIX] mrp: replan workorders
In some cases, replanning a work order does not change anything.

To reproduce the issue:
(Use demo data):
1. In Settings, enable "Work Orders"
2. Create two manufacturing orders (MO01, MO02) with 1 x [FURN_8522]
Table Top
3. Confirm MO01 and MO02
4. Set the same Scheduled Start Date (SSD) on the WO of each MO
    - A warning should be displayed on the work order line because of
the conflict
5. Open the warning and click on "Replan"

Error: Nothing happens, the warning is still displayed and the scheduled
start date does not change.

For the warning symbol to be displayed, we check (through
`_compute_json_popover`) if two work orders are in conflict:
https://github.com/odoo/odoo/blob/8cb5aad6126e3f63ee4ef91115c8b4a6be571828/addons/mrp/models/mrp_workorder.py#L719-L722
So, we base this information on the `mrp.workorder`

However, the planning logic is based on another model:
`resource.calendar.leaves`. When planning a WO, we create a
`resource.calendar.leaves` and we link this slot to the WO thanks to the
field `leave_id`:
https://github.com/odoo/odoo/blob/4870606b00a758e63713e6e82c0cba9b1e7dd4aa/addons/mrp/models/mrp_production.py#L1238-L1248
Therefore, when replanning a WO, we ensure that the new slot does not
overlap any existing slot in the same workcenter. But, here is the
issue: when writing the start date (step 4), we try to replan the WO of
the MO only if this MO is already planned:
https://github.com/odoo/odoo/blob/4870606b00a758e63713e6e82c0cba9b1e7dd4aa/addons/mrp/models/mrp_production.py#L723-L724
Wich is not the case in the above steps. So, we don't (re)plan anything
=> we don't create any slot.

As a result: the warnings are displayed, which is correct, but when
trying to replan one of the WO (step 5, viathanks to
`_plan_workorders`): There isn't any slot starting from WO's start date
(there isn't any slot at all!), so we can create a new slot -> the start
time of the WO does not change -> considering their start times, there
is still a conflict between both WOs.

Comment: if after the step 5, the user tries to replan the other WO, it
will work: the first replanning fails but a slot has still been created.
Therefore, when replanning the second WO, the newly-created slot will be
detected, a second slot will be created after the first one and the
start date of the second WO will be postpone (according to the second
slot).

(!) Note that nothing creates any slot if we directly define the start
time of the WO during the MO creation (step 2). So this use case will
fail too.

We should ensure a perfect coherence between both models
`resource.calendar.leaves` and `mrp.workorder`.

OPW-2887413

closes odoo/odoo#95087

X-original-commit: 9d4d8d24792933e53a4ca422ccedde8ddc93cdf4
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-07-01 17:48:23 +02:00
alt-odooandvancleeff 8566928015 [FIX] mrp: correct logging of quantity exception note on pickings
It could happen that there are other objects than stock.move linked to
the manufacture order. This is currently creating an error when
concatenating the objects. As we are only keeping stock.move objects to
log the exception on those, we should filter them before the concatenate
operation to avoid the error.

closes odoo/odoo#94893

X-original-commit: 1cdb682163e24fc01677cdcd0e1b83592443fffc
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Alex Thuyls (alt) <alt@odoo.com>
Co-authored-by: vancleeff <mvw@odoo.com>
2022-06-29 18:55:17 +02:00
Nicolas Pierre 9f3c6bfd25 [IMP] mrp: add production capacity in split wizard
Add in the split wizard the quantity of MO that can be produced using the available quantity of components.

closes odoo/odoo#88855

Pr: https://github.com/odoo/odoo/pull/88855
Task-id: 2773895
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-06-27 11:20:03 +02:00
Adrien Widart 2244e9b127 [FIX] stock, mrp: display the forecast symbol for inter-wh SM
To reproduce the issue:
(Let WH01 be the existing warehouse)
1. In Settings, enable "Storage Locations"
2. Create a second warehouse WH02
3. Create a storable product P
4. Create a planned and internal transfer:
    - From: WH01/Stock
    - To: WH02/Stock
    - With: 1 x P
5. Save the transfer
    - Error01: the forecast symbol is green, it should be red
6. Confirm the transfer
    - Error02: idem

Error 01: Because the picking type is internal, we don't consider the
picking as a consuming one. Therefore, we don't reach the line that
define the forecast availability as negative:
https://github.com/odoo/odoo/blob/892232b5aef42dd2706cb9d1d027b1c463ca50dd/addons/stock/models/stock_move.py#L446-L448

Error 02: Fixing the first error is not enough. Thanks to the first
correction, we reach this line:
https://github.com/odoo/odoo/blob/892232b5aef42dd2706cb9d1d027b1c463ca50dd/addons/stock/models/stock_move.py#L449-L450
And we will then call another method to compute the forecast
availability:
https://github.com/odoo/odoo/blob/892232b5aef42dd2706cb9d1d027b1c463ca50dd/addons/stock/models/stock_move.py#L457-L463
However, `_get_forecast_availability_outgoing` won't define any forecast
availability for the move (it won't find any quantity to fulfill the
need). So, when getting the value (`forecast_info[move]`), we will a
have the default values:
https://github.com/odoo/odoo/blob/892232b5aef42dd2706cb9d1d027b1c463ca50dd/addons/stock/models/stock_move.py#L2035
where `result` is the dict returned by
`_get_forecast_availability_outgoing`. Later on, when using the field
`forecast_availability` to render the view: in case of an outgoing
transfer, we use the forecast widget:
https://github.com/odoo/odoo/blob/73ab94402878a16c34c0e131818ffc0d2e8da3da/addons/stock/views/stock_picking_views.xml#L393-L394
And it correctly works because we compare the forecast availability with
the demand:
https://github.com/odoo/odoo/blob/6eaa4a2ae3b12b244f4c4277ef9cbc172f492f0a/addons/stock/static/src/js/forecast_widget.js#L34

However, in case of an internal transfer, we don't use the forecast
widget:
https://github.com/odoo/odoo/blob/3a2ee95c3ddfa0b2cf9383772ba48ebf6d9d5bb2/addons/stock/views/stock_picking_views.xml#L388-L391
And, if `forecast_availability` is equal to zero, it should mean that
there will be just enough stock to fulfill the need [1]. This explains
why the symbol is green.

So, the issue comes from the values returned by
`_get_forecast_availability_outgoing`: it should not set the forecast
availability to zero if there isn't any stock available.

[1] Some tests need to be fixed to respect this definition of
`forecast_availability`

task-2822157

closes odoo/odoo#94332

X-original-commit: 7610664cfbcfa89b0a9608663952544f8c9f195d
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2022-06-24 11:32:48 +02:00
Victor Feyens d2fb479d31 [FIX] mrp: settings user unable to save settings
Settings user is not able to access Bill of Material (mrp.bom) records
unless they have additional groups (account, inventory, manufacturing, ...)

This commit makes sure the operation is done in sudo so that any setting user
is able to save the settings.

Part-of: odoo/odoo#91909
2022-06-23 23:48:30 +02:00
Adrien Widart c7c96d61e9 [FIX] mrp: apply source location of unbuild order on SM
When unbuilding a product, the selected source location is not applied
on the SM.

To reproduce the issue:
1. In Settings, enable "Storage Locations"
2. Create two storable products P_compo, P_finished
3. Update the qty of P_compo: 1 in WH/Stock
4. Create a BoM:
    - Product: P_finished
    - Components: 1 x P_compo
5. Process a manufacturing order MO with 1 x P_finished
6. Transfer the P_finished from WH/Stock to WH/Stock/Shelf 1
7. Create an unbuild order UO:
    - Manufacturing Order: MO
    - Source Location: WH/Stock/Shelf 1
    - Destination Location: WH/Stock/Shelf 2
8. Confirm UO
9. Open the associated product moves

Error: The SML of P_finished is incorrect, its source location is
WH/Stock instead of WH/Stock/Shelf 1 (as a result, the quants are
incorrect too).

The issue only happens with P_finished. The destination of the
components is correctly defined:
https://github.com/odoo/odoo/blob/90a87d6ecd420c61ea8db8a6c571db477ee7220e/addons/mrp/models/mrp_unbuild.py#L229
(i.e., we use the destination location of the unbuild order)

OPW-2869454

closes odoo/odoo#94367

X-original-commit: 45ec5871a1ee6e3a31e790323f08df20715f4171
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-06-23 10:15:12 +02:00
Adrien Widart 92a049ecff [FIX] mrp: find child/source MO
When a MO is generated in order to supply another one, the smart buttons
"Source MO"/"Child MO" are still invisible.

To reproduce the issue:
1. In Settings, enable "Multi-Step Routes"
2. Enable MTO route
3. Edit the warehouse: 3-steps manufacturing
4. Create 3 stored products Super, Sub and Compo:
    - Sub has two routes: MTO and Manufacture
5. Create two BoMs:
    - For 1 x Super:
        - 1 x Sub
    - For 1 x Sub:
        - 1 x Compo
6. Create and confirm a MO with 1 x Super

Error: On confirmation, a second MO is created to produce one Sub, which
is correct. However, neither the first MO nor the generated one has a
link with the other one (through the smart button "Source MO"/"Child
MO")

When confirming the MO, a SM is created to bring one Sub to the
pre-production location. Thanks to MTO route, this will generate another
SM that brings one Sub from post-production to stock location (this will
lead to the creation of the second MO). However, the other SM (1 x Sub
from Post to Stock) doesn't have the same procurement group. This is the
reason why it is not found by the `_compute` methods.

OPW-2730830

closes odoo/odoo#94334

X-original-commit: 81e5ce05f2f79eb19489f00fb867143189fb38df
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-06-23 10:15:01 +02:00
Ivàn Todorovich 0822e8c867 [IMP] mrp: use prefetch for recursive quantities computation
This commit achieves two things:

1) Avoid calling super() on an empty recordset, in case all products
   are kits. Even on an empty recordset, some queries would be fired.
   This commit avoids them.

2) Use prefetch to read kit components quantity fields, to make use
   of the recorset optimizations that ends up saving sql queries.
   Otherwise, component quantities were computed on-demand one by one.

closes odoo/odoo#94225

X-original-commit: ef4ae7f62d6b690b4745b4145ce25ff02b6b29f6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-06-22 09:58:40 +02:00
Touati Djamel (otd) d3bda140cc [FIX] mrp: remove immediate_transfer key on MO creation
Steps to reproduce the bug:
- Enable the `Multi-Step Routes` option in the settings
- Go to inventory > warehouses > Select 2-step manufacturing
- Go to inventory overview > Click on Manufacturing
- Create a MO > confirm
- Go to the created picking

Problem:
The state is “ready” instead of “waiting” because the picking is
created in immediate transfer:
https://github.com/odoo/odoo/blob/fd6aa428ce7b7ab03ba920b1c020f5862f56f731/addons/stock/models/stock_picking.py#L137

So when we compute the state, as the picking is in immediate transfer
and the “stock.move” is confirmed, the picking status will be
`assigned`('ready')

https://github.com/odoo/odoo/blob/8c4819882011ba6bbeefe97931a26a96e60d38a3/addons/stock/models/stock_picking.py#L431

Solution:
No need to call `get_action` function to fill the context,
we can return the action directly

opw-2876050

closes odoo/odoo#93488

X-original-commit: 64f00fd41546127182f6fc977753bb00f4b6f63f
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-06-15 12:23:14 +02:00
clesgow ab825e9f19 [FIX] mrp: date_deadline lost on mrp backorders
When creating a backorder for a manufacturing order, date_deadline for
its raw_moves are lost in the process, as the field is set to copy
False. But the split of a manufacturing order is not a usual copy paste.

In this specific case, we need to keep the date_deadline as well, or
resulting moves wouldn't be able to be merged with moves in
pre/post-production pickings from the original manufacturing order.

Task-2797359

X-original-commit: b50db19fa0da58dc0734c8cd494795743eaf0984
Part-of: odoo/odoo#93233
2022-06-10 10:29:41 +02:00
Nicolas Pierre 5b2d16360d [FIX] purchase_stock: days to purchase not used in orderpoint action
Since https://github.com/odoo/odoo/pull/86682, when a user opens
the replenishment view, the  Days to Purchase are not taken into
consideration when calculating the forecast of a product.
This was due to the fact that the Days to Purchase are now taken from the
orderpoint and not from the company settings. This is fixed by taking
the company setting if no value from the orderpoint is sent to the
method.

closes odoo/odoo#93252

Task-id: 2871408
X-original-commit: ac1df1949e4523aff65543f1381300fc7de3b4e4
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: npi-odoo <npi@odoo.com>
2022-06-10 09:28:13 +02:00
JF Aubert fcc7b3d46a IMP] mrp: add workcenter capacity per product
Allow workcenter capacities based on product instead of
applying the same capacity for all.

closes odoo/odoo#87131

Task: 2691328
Related: odoo/enterprise#25532
Related: odoo/upgrade#3370
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-06-03 16:40:09 +02:00
JF Aubert dbd09f16a2 [IMP] mrp,mrp_workorder: workorder scheduling revamp
Currently MRP only allows sequential scheduling of work orders.

This commit allows to specify the dependencies for work orders to be
scheduled in parallel or in a complex diagram.

By enabling the feature in the settings and at the bom level,
you can specify dependencies between operations:
on the operation form, select the operations on which the
current one depends.

The dependencies will be reflected in work orders during planning.

The workorders Gantt view has been adapted for you to visualize
and manipulate the dependencies.

Please note:
- work orders without predecessors will be started first
- they can all be done in parallel
- when all work orders of this step are finished, their successors
  will start
- and so on, step by step

Also, with the feature activated at the bom level and no dependency,
the parallel scheme will be applied (all operations at first step).

Finally, without activation at the bom level, the dependencies will
be created in order to satisfy the current sequential model.

Task: 2691328
Part-of: odoo/odoo#87131
2022-06-03 16:40:08 +02:00
Ahmed Khalaf (ahkh) ae76ba4386 [FIX] sale,stock,mrp,purchase: added uom precision
Task: 2764771
Part-of: odoo/odoo#91640
2022-06-03 12:02:08 +02:00
Touati Djamel (otd) ca5b12b07c [FIX] mrp_plm: compare the difference between two BOMs
Steps to reproduce the product:
- Enable “Work Orders” option in MRP settings
- Create a storable product “P1” with BOM:
    - BOM type: Manufacture this product
    - operations: “OP1”
    - Components: product “C1” consumed in the operation “OP1

- Create an ECO for “P1”:
    - Type: New Product Introduction
    - Apply on; Bill Of materials
    - Click on “Start Revision”

Problem:
A BOM change will be created for the component “C1” where it will be added and removed.

When creating an ECO, a copy of the original BOM will be created,
and then we compare the BOM lines of the two BOMs if they are identical (product, qty and operation)
but as the operation has been duplicated therefore created with a different ID,
the two lines will not be identical and a distorted change in the BOM will be detected

Solution:
It is better to compare the fields of the operations instead of their ID to detect if a change has been made in the BOM

opw-2823253
opw-2809586
opw-2833083

closes odoo/odoo#92670

X-original-commit: 5c16aa22c70f8a0a377a55b912307ab07222c643
Related: odoo/enterprise#27943
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-06-02 10:56:21 +02:00
Ahmed Khalaf (ahkh) 964bfda3bf [FIX] mrp: transfers are created from manual moves in MO
When manfacture in 2 steps is setup on warehouse, transfers are created
when confirming an MO, manual moves added did not have a warehouse and thus not
included in the picking. The default warehouse is set to the source location
warehouse in MO.

closes odoo/odoo#91879

Related: odoo/enterprise#27577
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-06-01 16:26:29 +02:00
Ahmed Khalaf (ahkh) 1b2cf66f6e [FIX] mrp: skip archived operations in bom
Part-of: odoo/odoo#91879
2022-06-01 16:26:29 +02:00
Nicolas Pierre 87d33596d1 [IMP] mrp, purchase_stock: visibility days and days to prepare MO
- Add the concept of 'Days to Prepare MO' in  mrp, similar to 'Days to
Purchase' but defined at the product level. Both concepts are merged into
Days to Order at the orderpoint level, taking the value of Days to Purchase
for orderpoints with a buy route and Days to Prepare MO for orderpoint with a
manufacturing route.
 - Add the concept of 'Visibility Days' on orderpoints. The idea is to
avoid to create through reordering rules multiple small orders for  the
same product on a small time frame but rather to order directly a bigger
quantity. When Visibility Days are defined, the quantity of the orders
created by a RR is not the quantity forecasted at Today + Lead times
(quantity that triggered the order according to the RR), but the
quantity forecasted at Today + Lead Times + Visibility days.
The Visibility Days are different for purchase and manufacturing.
Changing the route of the orderpoint will change its value. They
can be defined at the company level and further fine-tuned on the
orderpoint. In case of change of the parameters at the company level,
only orderpoints without a specific value of Visibility Days  will
be changed.
 - Alignement between Manufacturing and Purchase Security Lead Time
(previously the Manufacturing Security Lead time didn't impact the
procurement date, instead the manufacturing time was made longer).

closes odoo/odoo#86682

Task-id: 2738838
Pr: https://github.com/odoo/odoo/pull/86682
Related: odoo/upgrade#3415
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-05-31 19:16:55 +02:00
Arnold Moyaux 86878dd13e [FIX] mrp,purchase_stock,stock: avoid new param
following commit 55398263f9297ab2709e4c4c2a9c6c3ee7f59c8a
Introduce a new param to fix a notification issue. However
we could use the context instead of a new parameter in order
to avoid breaking the customisation.

Linked to PR #88303 discussion

closes odoo/odoo#92353

X-original-commit: 69dcdd410adcefe29bfa4fecd2e7c50fe3465b19
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-05-27 15:42:40 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Pieter Claeys (clpi) b3305b1886 [FIX] stock,purchase_stock,mrp: replenishment notification
When clicking order now on a replenishment line (orderpoint) for a manufacture or WH resupply route, it will sometimes show a notification for a purchase order that was created earlier instead of the correct one.

closes odoo/odoo#91404

X-original-commit: 9ca9bcc51fa289ddb0548f81a795755d196e31ca
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-05-16 10:09:52 +02:00
Pieter Claeys (clpi) aeda32f9e7 [IMP] mrp: settings grammar fix
Task: 2799674
Community PR: https://github.com/odoo/odoo/pull/88801

Part-of: odoo/odoo#88801
2022-05-12 16:05:02 +02:00
Pieter Claeys (clpi) 1e15fb9b81 [FIX] mrp_subcontracting: open merged MO form view
Bug fixed where when the MRP subcontracting module was installed the merging of MO's would not open the MO form view.
Correctly displays the breadcrumbs as well.

Task: 2799674
Community PR: https://github.com/odoo/odoo/pull/88801

Part-of: odoo/odoo#88801
2022-05-12 16:05:01 +02:00
Pieter Claeys (clpi) 978df88644 [IMP] mrp: search for product attribute values in MO view
Task: 2799674
Community PR: https://github.com/odoo/odoo/pull/88801

Part-of: odoo/odoo#88801
2022-05-12 16:05:01 +02:00