Commit Graph
1284 Commits
Author SHA1 Message Date
Raphael Collet 7e6cff5479 [IMP] core: search() and _search() no longer have parameter count
The parameter in search() is redundant with method search_count(), and
was making the calls less readable.

The method _search() is aimed at always returning a Query object.  The
method can therefore never return an integer, hence the removal of the
parameter.  This does not actually remove any functionality from the
method; counting result is simply given by using it differently.

Part-of: odoo/odoo#112126
2023-03-05 15:12:54 +01:00
Martin Maes 4d52a46dfe [FIX] mrp: review and workorder wizard modification
The workorder wizard helping to track the time spend on the workorders has been automated.
The name of the employee will automatically be the name of the admin of the session.
The productivity will also be updated based on the duration
The duration, start date and end date will update based on the two other ones.
This changes will ease the addition of time trackings.

closes odoo/odoo#107473

Related: odoo/enterprise#34786
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-03-03 17:04:47 +01:00
Martin Maes 09314106e2 [IMP] mrp_workorder: employee login in workorder list view
This main feature of this commit is adding the possibility to login with multiple employees on the list view of workorders.

There is now a button in the header that will allow to log in as an employee in the list view.
The flow is the following :
- The employee logs in
- He becomes the "admin" of the session and his name appears next to the log out button.
- If another employee logs in, he will become admin and the first one will no longer be visible in the header.
- The employee will start timesheeting on the workorder if he press the start button. Notice that the employees working on the workorder will appear in the last column of every work_order record.
- If this second employee logs out, the first one will not become admin automatically. He will first need to click on his name/avatar in the popup and will be asked his pin code (if needed) to log in again.

There is also a way to assign employees to a workorder.
A filter will help retreive the workorder on wich the admin of the session has been assigned.
In addition, a new button in the header allows to mark as done multiple workorders at once.

The timer component has been updated to avoid wrong values if the computer goes to sleep mode.

The wizard of the workorders allowing to see the time traking has also be modified (switching tabs).

From a more technical point of vue, the employees and admin will be saved in the session.
The employees working on a workorder will be saved on the record.

related : https://github.com/odoo/enterprise/pull/34786

Part-of: odoo/odoo#107473
2023-03-03 17:04:47 +01:00
yhu-odoo 9c5e80fb32 [IMP] mrp: improve Produce All
Currently, if the user change qty_done on any raw moves without
changing qty_producing on the MO, it's not possible to validate the
order. In this commit, we make it possible to validate the order as an
immediate production.

When qty_producing is 0 and validate the MO:
1. manual consumption moves: current consumed qty will be kept when
process the MO.
2. non-manual consumption moves: For tracked components, if
use_auto_consume_compoents_lots checked, and there is enough products
reserved, the qty_done will be filled, otherwise, an error will be
raise to ask user to fill in lot/sn. For non-tracked components,
qty_done will be filled.

Task-3116125

Part-of: odoo/odoo#113538
2023-03-01 17:01:17 +01:00
yhu-odoo ba7bf97444 [FIX] mrp: always no manual consumption when use_auto_consume_components_lots
When use_auto_consume_components_lots is on, it's always no manual
consumption on a MO even when the product is no tracked. Fix it

Part-of: odoo/odoo#113538
2023-03-01 17:01:17 +01:00
yhu-odoo 7fb27bd8b1 [IMP] mrp: untick manual consumption when remove operation_id
On the BOM, we add "Consumed in Operation" to a line, manual consumption
will be ticked automatically. In this commit, we make it that when
remove "Consumed in Operation" on a line, manual consumption will be
automatically unticked.

Task-3116125

Part-of: odoo/odoo#113538
2023-03-01 17:01:17 +01:00
yhu-odoo 5bb0f96f19 [IMP] mrp: manual consumption improvement
Previously we set a component on MO to be manual consumption by comparing
the To Consume and Consumed, if they are not the same, we consider it a
manual consumption. Now if any input activity in the Consumed cell, we
will consider it a manual consumption.

Note that in the code, we make the css class change happended in the
list renderer instead of the field widget. We do that because we want to
change the background color of the whole cell not just the text of the
field.

Task-3116125

Part-of: odoo/odoo#113538
2023-03-01 17:01:16 +01:00
yhu-odoo 439ba7d945 [FIX] mrp: show manual consumption when workorder not enabled
In 49bc9aac201136e684cac9d84df97f80d217afa4, when we need operation_id
when we check if manual_consumption is readonly or not, so
groups="mrp.group_mrp_routings" was added for manual_consumption.
As a result, we can't see manual_consumption on BOM when workorder is
not enabled.
To fix, we add a computed field as a workaround.

Task-3116125

Part-of: odoo/odoo#113538
2023-03-01 17:01:16 +01:00
Mathieu Duckerts-Antoine 926c4d4769 [REF] mrp: revert partly "[IMP] mrp: adapt workorder gantt view"
Revert partly https://github.com/odoo/odoo/commit/d55e6cca0648c78ab27e0107ab7d545e9fd4972b.

Rationale: if the field workcenter_id is not found in the group_bys, the
records in a given row can be associated with different workcenters with
different unavailabilities. So if for instance two records in the same
row are related to workcenters 1 and 2 with respective unavailabilities
from Monday to Wednesday, and Thursday to Sunday, that row would be
totally greyed. This leaves the user with no interesting information.

Moreover, we are about to refactor the GanttView and we want to simplify
the API of the method gantt_unavailability, in particular we do not want
to send row records anymore.

Part-of: odoo/odoo#112756
Co-authored-by: Mathieu Duckert-Antoine <dam@odoo.com>
2023-02-28 20:38:50 +01:00
Stefan-Calin Crainiciuc (stcc) 53324c44de [REV] mrp: create productivity line before modifying workorder
Reverts https://github.com/odoo/odoo/pull/110666 because of breaking
behaviour introduced in https://github.com/odoo/enterprise/pull/35696

- Install quality_mrp_workorder
- Manufacturing > Config > Create 2 workcenters: WC1 and WC2
- Products > New Product > Name: P, type: Storable, Routes: Manufacture
- Manufacturing > BoMs > Create > Product: P, Operations Tab, add 2 lines:
- 1. operation: OP1, Work Center: WC1, Save
- 2. operation: OP2, Work center: WC2, Save
- Manual Save BoM, don't exit
- Components Tab, unlock column Consumend in Operation, add 2 lines:
- 1. Product: P1, Create and edit > type: Storable
- 2. Product: P2, Create and edit > type: Storable
- Both lines, quantity: 2.
- Each line, Consumed in operations: OP1 and OP2
- Save and exit
- Operations > Manufacturing orders > New > Product: P, Quantity: 2 > Confirm
- Workorder Tab > open first line tablet view: Quantity = 2.00/2.00 Units > Validate
- open second line tablet view: Quantity = 0.00/2.00 Units (!)

closes odoo/odoo#113574

Issue: The recommended quantity should also be 2.00/2.00
X-original-commit: 67774c967b587a660be032712b7a2369ed7abc3a
Related: odoo/enterprise#37500
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Stefan-Calin Crainiciuc (stcc) <stcc@odoo.com>
2023-02-24 18:16:19 +01:00
snd 4ab6f383e1 [FIX] mrp: translate blocking reason
Blocking reasons on workorders are not translatable, this fixes that.

closes odoo/odoo#113641

Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-02-24 17:13:13 +01:00
Xavier BOL (xbo)andYannick Tivisse 1648c25cc9 [IMP] resource: make working schedule optional in resource model
closes odoo/odoo#110548

Related: odoo/upgrade#4248
Related: odoo/enterprise#36101
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Co-authored-by: Yannick Tivisse <yti@odoo.com>
2023-02-22 20:25:16 +01:00
Arnold Moyaux 582f7f490f [FIX] mrp: studio on workorder gantt view
Traceback happens because it doesn't require records and call the
function without row records. The code doesn't handle that case.

Don't try to find unavailabilities in that case and just skip this
part of code

closes odoo/odoo#113104

Signed-off-by: Steve Van Essche <svs@odoo.com>
2023-02-20 15:56:28 +01:00
Adrien Widart (awt) 2865cc6119 [FIX] mrp: add SML with kit to confirmed picking
When validating a confirmed picking, if in the meantime the user
added an SML with a kit, the done picking will have some not-done SM
for each kit component.

To reproduce the issue:
1. Inventory > Operation Types, edit Receipts:
    - Show Detailed Operations: True
2. Create three products:
    - P_kit
    - P_compo
    - P_other
3. Create a kit BoM
    - Product: P_kit
    - Components: P_compo
4. Create a planned receipt R
    - Operations:
      - 1 x P_other
5. Mark R as todo
6. Add two detailed operations:
   - 1 x P_other
   - 1 x P_kit
7. Validate R

Error: The SM for P_kit has been replaced with its component, which
is correct. However, the done quantity of the new SM is 0, it should
be 1

At some point, because the done quantity of SM_kit is gerater than
the demand, we create an extra move:
https://github.com/odoo/odoo/blob/24f2e3f73498e5eb180a6793de6c25efd414aadb/addons/stock/models/stock_move.py#L1529-L1534
So, the goal is to create a second SM_kit_02 with the expected
demand. Then, we merge this new SM_kit_02 with SM_kit:
https://github.com/odoo/odoo/blob/24f2e3f73498e5eb180a6793de6c25efd414aadb/addons/stock/models/stock_move.py#L1491-L1493
https://github.com/odoo/odoo/blob/5f8da70b5b1f313e9b676846e55e84621f55e734/addons/mrp/models/stock_move.py#L239-L242
As shown above, we explode SM_kit_02 which gives SM_compo. However,
we don't explode SM_kit. Thefore, we will not be able to merge
SM_compo with SM_kit. In such situation, we should also explode
`merge_into`.

For the explode method to work with SM_kit, we need to change few
lines: as said at step 4, the receipt is not an immediate one.
However, we still have a case here where the SM has a quantity done
without any demand and only the done quantity matters (as we are
validating the receipt)

OPW-3015933

X-original-commit: 35a5b83b93fceac4073689edd74d680bed09a143
Part-of: odoo/odoo#112814
2023-02-16 11:35:50 +01:00
Arnold Moyaux c68a159884 [FIX] stock,purchase,mrp: accumulative security days
Usecase to reproduce:
- Set the warehouse as 3 steps receipt
- Put a security delay of 3 days for purchase
- Set a product with a vendor and 1 days as LT
- Replenish with the orderpoint

You expect to have a schedule date for tomorrow that contains all the
product needed in the incoming 4 days.

Currenly the internal transfer from QC -> Stock is for tomorrow (ok).
The transfer from Inpur -> QC is plan for 2 days in the past. (not ok)
The PO date is plan for 5 days in the past. (not ok)

It happens because the system check at each `stock.rule` application if
purchase is part of the route. If it's then it applies the security lead
time. It's a mistake because we should apply it only the first time.

To fix it we directly set it when the orderpoint run and not during
`stock.move` creation.
However for MTO it's not that easy. We don't want to deliver too
early the customer. So we keep applying the delay during the
`stock.move` creation but only when it goes under the warehouse stock
location.

X-original-commit: 97f52bd40d97109a7983549d252476959ddceada
Part-of: odoo/odoo#112325
2023-02-09 20:03:59 +01:00
yhu-odoo 5e2b97b47f [FIX] mrp: workorder cost not included in price
When auto-fill the duration of workorders in immediate production, the
workorder cost is not included in the price of the product.
It happens becuase we calculate the price in _post_inventory but we set
the duration after _post_inventory. To fix, we set the duration of the
workorders in before _post_inventory.

closes odoo/odoo#111898

X-original-commit: 707769478b9f63319689ff2347d300ce1800d1d0
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Yuchen Huang (yhu) <yhu@odoo.com>
2023-02-03 17:41:21 +01:00
Yannick Tivisse 7bce5f3f95 [MOV] resource: Split files according to coding guidelines 2023-02-03 10:25:00 +01:00
niyasraphy 1436aa84c7 [FIX] mrp: mrp.bom model product_qty field precision
before this commit, the precision given for the field product_qty in mrp.bom model is Unit of Measure, which is not existing by default in Odoo decimal precisions.

after this commit, precision will be updated to default Product Unit of Measure precision

closes odoo/odoo#111115

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-02-02 15:02:13 +01:00
Stefan-Calin Crainiciuc (stcc) 74c684d541 [FIX] mrp: create productivity line before modifying workorder
Necessary for odoo/enterprise#35867

Steps to reproduce:
- Install Quality, Manufacturing
- Manufacturing > Settings > Enable Work Orders
- Manufacturing Orders > Create order for Table > Confirm > Work orders
tab > Open Tablet View
- Get to step 'Please encode the table legs lot number'
- Change the quantity to produce
- Pause > Continue

Issue:
The quantity to produce is reset to 4/4 Units.

Solution:
Check if the workorder is paused before applying `qty_done` changes.

opw-3032052

closes odoo/odoo#111402

X-original-commit: 4acb1781c5aedc011ba00054285f64963aa0dacc
Related: odoo/enterprise#36491
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Stefan-Calin Crainiciuc (stcc) <stcc@odoo.com>
2023-01-31 12:56:17 +01:00
snd a073438cce [FIX] mrp: set default qty_producing
When opening a work order and the quantity_producing is set at 0 by default, and since it is not possible to record 0 as done, the user always gets an error message when trying to carry on without manually editing that quantity producing field. This is not very user friendly as a manual input there on any device is burdensome.
This fix automatically sets qty_producing to be equal to qty_remaining in workorders for non-unique serial products when opening a workorder if the quantity is zero.

task 3113153

closes odoo/odoo#111156

X-original-commit: ff96659e7f8d4a239ff641d1b3541226ae3cb9e5
Related: odoo/enterprise#36369
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Diez Stéphane (snd) <snd@odoo.com>
2023-01-27 09:18:14 +01:00
Adrien Widart (awt) 4ceb57fa64 [REF] mrp{,_account}: extract computation of WO cost
Extract that part so it can be overridden

closes odoo/odoo#109340

X-original-commit: 39ff78b1dd2d4ae7017fde0282f78ead34637696
Related: odoo/enterprise#35533
Related: odoo/upgrade#4220
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-24 10:20:12 +01:00
Martin Maes 0dab2525f9 [FIX] mrp: date_planned_start is empty
This commit fixes the traceback when the user push the start button
in the Work Order list View of a work order without a date_planned_start.
To recreate the traceback, the order must be based on a manufacturing order
with multiple work orders, with at least one with a scheduled start date and
one without a scheduled start date.
When creating the manufacturing order, it is important to make sure that
only the confirm button is pressed.

closes odoo/odoo#110587

X-original-commit: c4d16a57e03d2a9183b232344579978b839a9fb9
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-23 11:20:08 +01:00
Thibault Delavallée 4775bd93a2 [REF] mail: cleanup post with {view, template} wrappers
RATIONALE

Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.

SUMMARY

We now have two main API methods, based on business flow: either posting
on documents, either sending a mass mailing. Indeed those two flows are
different

  * post: create message, then launch notification process by taking into
    account subtype, followers, ...
  * mail: create mails in batch with recipients being based on template or
    given partners. No notifications is involved, only maybe traces if a
    mass mailing is linked

Delegate QWeb rendering to the render mixin (i.e. _render_template_qweb_view)
in order to have a single point to forge evaluation context and re-use
existing rendering code.

SPECIFICATIONS

Main API helpers are now

  * ``message_post_with_source``: (batch) post on records, using an ir.ui.view
    (given a record or its xml id) or a mail.template record (given a record or
    its xml id). When using a template, a composer is called to post on each
    record (as batch post is not yet supported). When using a view, a direct
    call to message_post using the rendered bodies is done, one record at a
    time.
  * ``message_mail_with_source``: send a mass mailing on records, acting like
    invoking the mail composer in mass mode. Same arguments are valid, either
    a reference to a view, either a reference to a mail template.

Other helpers are

  * ``_message_log_with_view``: (batch) log on records, using an ir.ui.view
    to render the body using QWeb (no notification process);
  * ``_message_log(_batch)``: (batch) log on records (no notification process);
  * ``message_notify``: notify partners on records (creating notifications
    specifically for some people while message itself is not displayed in
    chatter);

Code migration

  * ``message_post_with_template`` in "mass mode": use ``message_mail_with_source``
    and set the template record as source;
  * ``message_post_with_template`` in "comment" mode: use ``message_post_with_source``
    and set the template record as source;
  * ``message_post_with_view``: its main usage was to post on a document, in which
    case it generally can be replaced by ``message_mail_with_source`` using
    the view reference as source;

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 418761e344 [LINT] mail, various: use explicit subtype in message_post_{with_...}
RATIONALE

Purpose of this commit is to be explicit in subtype chosen when invoking the
message composer / calling message_post. As default value may not always be
clear, better be explicit in case the composer default value changes.

SPECIFICATIONS

Add explicit references to subtype when it is not obvious what will be the
final subtype, notably when using helpers (post_with_view or template which
uses the composer that is not crystal clear in its subtype management).

In this commit we also add support of XMLID-based subtype when invoking the
composer. A ``default_subtype_xmlid`` context key is transformed into a
``default_subtype_id``, to be used notably in JS where we cannot easily
use a ``ref``-like statement. Post API now also supports 'subytpe_xmlid'
argument allowing to give the xml id and ease calling the methods.

Use ``_xmlid_to_res_id`` to get directly the ID of subtypes in order to
avoid useless queries from ``ref`` that does an exists.

Also remove useless values given to post API, notably author_id that is by
default the current users' partner.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Ahmed Khalaf (ahkh) 1f4fb64a19 [IMP] mrp: MO component qty changes reflected in pickings
When changing quantities of raw moves after MO confirm,
procurement is run to fulfill updated need.

Since procurement creates new moves, some fixes were also done to allow
moves to be merged with older ones, including:
1) `date_planned_start` of merged MO included microsecond which
blocked merging new moves created by procurement with orig moves.
Removed microseconds.

2) `_set_date_deadline` did not allow a simple date update to moves with
orig or dest moves. Added context to hard set all moves in self to specific
deadline.

3) `_update_candidate_moves_list` when merging moves, did not return candidates
from pickings that were merged to same MO. Usually just mattered when decreasing
quantity. Added explicit check for sibling pickings in MO

closes odoo/odoo#93712

Task: 2859547
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-13 16:26:57 +01:00
William Henrotin 0149a26c62 [FIX] mrp: byproducts follow putaway rules
Before this commit, the byproduct and putaway feature do not work
together. More specifically, changing the quantity to produce on a
manufacturing order will create automatically a byproduct move line (or
update the existing one with the new quantity) but never look for a
putaway rule to apply.

This commit makes use of `_set_quantity_done()` method on `stock.move`
that *do* call the putaway strategy mechanism

X-original-commit: d4a968412e68cc9da3ec2d9725caa90830287c48
Part-of: odoo/odoo#109669
2023-01-12 08:02:48 +01:00
JF Aubert 0cdf410a44 [IMP] mrp: Remove mrp.immediate.production model
closes odoo/odoo#108446

Task: 3094741
Related: odoo/upgrade#4163
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-11 13:20:48 +01:00
JF Aubert b0a6c525b0 [IMP] mrp: Improvements
- Many ui/text updates
- Fix To consume field display
- Add Draft/Done filters to Scrap views
- Fix BoM name_create problems due to _rec_name set to product_tmpl_id

Task: 3094741
Part-of: odoo/odoo#108446
2023-01-11 13:20:47 +01:00
Alvaro Fuentes b21ecab391 [FIX] mrp: avoid MemoryError in _get_orderpoint_products
`super()._get_orderpoint_products()` returns more than 1 million
products. Applying _bom_find to all of them is too much.
https://github.com/odoo/odoo/blob/55e327705deed2aa31c1fc9eca49a8a66135c020/addons/stock/models/stock_orderpoint.py#L567-L568

Issue observer on menu Inventory > Operations > Replenishment during
upgrades to 16.0

closes odoo/odoo#109311

X-original-commit: 263cb8eafb3ac0db5cb950e66dba3c924e52f187
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Alvaro Fuentes Suarez (afu) <afu@odoo.com>
2023-01-09 10:11:27 +01:00
William Henrotin 5eba1ff07e [FIX] mrp: add index on created_production_id
in sale_mrp module, the method `get_sale_order_count` get all stock move
with created_production_id = the current production order. Without
index, this request is significantly slow.

X-original-commit: 4c17020fb452f639d9395dccdd5fcefee109ed01
Part-of: odoo/odoo#109201
2023-01-06 12:29:38 +01:00
Jinjiu Liu b5e8f85eaa [FIX] *: missing date filter for stat button
Reproduction:
1. Install Sale, Inventory
2. Go to Sale->products, search for “Customizable Desk”
3. Hover the cursor on the stat button “Sold”, from its definition, the
analysis should show the sold items in last 365 days
4. Click on the “Sold” button, no filter for “Order Date”

Reason: in V14, the “time_ranges” feature is removed. Thus using it in
the context won’t create any filter for searching

Fix: We use a custom filter to replace the time range "last_365_days".
We also make sure that the domain produced by that filter is the same as
the one used to compute the button count server side (this was not the
case in Odoo 13 when "last_365_days" was used). Similar fix is also done
in mrp and l10n_ar. Mind the utc convert for correct results.

opw-3000595

Related commits:
Removal of time_ranges: https://github.com/odoo-dev/odoo/commit/be5a51a345b8986da0e19627260f64f984e11ae9
Date filter fix: https://github.com/odoo/enterprise/pull/10938

closes odoo/odoo#108951

X-original-commit: 03057029b210a59f3d7012aeea66cfa95790a8c8
Signed-off-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Signed-off-by: Liu Jinjiu (jili) <jili@odoo.com>
2023-01-02 20:39:53 +01:00
Touati Djamel (otd) 8e4e32ab01 [FIX] mrp: use the operation type set on the BoM in MO
Steps to reproduce the bug:
- Enable “Multi-Step Routes” option in the inventory settings
- Create a storable product “P1” with BoM:
    - Add any Component
    - Go to “Miscellaneous” tab
    - Create a new picking type and set in the “Operation” tab
- Create a Mo:
    - Add the product “P1”
    - Select the created BoM
    - Go to “Miscellaneous” tab

Problem:
The operation type set on BoM does not update when selecting the BoM
on a manufacturing order

opw-3091436

closes odoo/odoo#108632

X-original-commit: cd561574d044d4799163ac90305c7914855ead50
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-12-26 11:39:49 +01:00
Ahmed Khalaf d7246ef786 [FIX] mrp: fix change MO qty to produce
Before this commit, if a user changes a MO move qty to 0
and then tries to change the MO qty to produce, an error occurs.

The move with 0 qty is no longer cancelled or unlinked as this was not
the intenteded behavior.

Since the change production wizard no longer deletes cancelled moves
a test was updated accordingly.

closes odoo/odoo#108534

Taskid: 3082611
X-original-commit: 39abadb30dc8fab6b2a1ca24cb2916ab148fb5fa
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Ahmed Khalaf  <ahkh@odoo.com>
2022-12-22 15:55:09 +01:00
Adrien Widart (awt) 1f3cbfd7ca [FIX] mrp: hide smart buttons for kits
When a kit template has several variants, the on hand quantity can be
incorrect.

To reproduce the issue:
1. Create two products P_compo, P_kit:
    - P_kit:
        - Storable
        - Variants:
            - Color (White, Black)
    - P_compo:
        - Storable
2. Update the on hand quantity of P_compo: 10
3. Create two BoMs:
    - BoM01:
        - Product: P_kit
        - Variant: Black
        - Type: Kit
        - Components: 1 x P_compo
    - BoM02:
        - Product: P_kit
        - Variant: White
        - Type: Kit
        - Components: 2 x P_compo
4. Open the form view of the template P_kit

Error: it displays "15 units on hand", which is impossible (there are
only 10 P_compo available)

Since it is difficult to determine the expected value, a decision has
been made: hide these smart buttons if a template has more than one
variant and if at least one of the variants is a kit.

OPW-2645299
OPW-2678400
OPW-3076502

closes odoo/odoo#108284

X-original-commit: cf3b83d6a48c080d900d9cf343e4012be718c79d
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-12-22 11:40:55 +01:00
William Henrotin 859c24528e [FIX] mrp: do not recompute duration expected
Since 2515482d5a70, the duration expected of a workorder was always set
to the real duration at the validation of the workorder. This commit
ensure the duration expected is left unchanged even if the
date_planned_finished is updated.

closes odoo/odoo#108233

X-original-commit: 46e1ae4d9918de1aaf6b4a7565dba422b03fcb36
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-12-19 10:31:00 +01:00
Touati Djamel (otd) 3ac47d27f5 [FIX] mrp: display warning when archiving component product
Steps to reproduce the bug:
- Create a BoM with components
- Archive one of the components

Problem:
No warning is displayed for the user to inform that the product is
used as a component in a BoM

opw-3089104

closes odoo/odoo#107863

X-original-commit: 9b7c416387d93507b6f750aba58ad6233a59d512
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-12-13 18:09:51 +01:00
Touati Djamel (otd) 515fbccae3 [FIX] mrp: do not convert the quantity if there is no BoM
Steps to reproduce the bug:
- install “mrp_mps”
- Create a storable product “P1”
    - routes: Manufacture + MTO
    - make sure there is no BoM set

- Go to “Master Production Schedule”:
    - Add the product “P1”
    - Add a quantity and click on “Replenish”

Problem:
A User Error is triggered with the following message: `The unit of
measure Units defined on the order line doesn't belong to the same
category as the unit of measure False defined on the product. Please
correct the unit of measure defined on the order line or on the product,
 they should belong to the same category.`

The `compute_qauntity` function is called to convert the qty into the
UoM of the BoM, but since there is no bom, an empty record is given as
a parameter:
https://github.com/odoo/odoo/blob/8c5fb8b71538462422c8f166b772b5e316ecd6b5/addons/mrp/models/stock_rule.py#L122

https://github.com/odoo/odoo/blob/0f91970020af640faa3a06369fa888315f83f98f/addons/uom/models/uom_uom.py#L215

opw-3085227

closes odoo/odoo#107476

X-original-commit: 7d0df9035cf603ed25ef88a3cf99ed89aef6771e
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-12-08 13:38:11 +01:00
yhu-odoo 589622e82e [FIX] mrp: qty_remaining missing dependancy
To reproduce:
Create a MO without product_id, then add a new line in work orders.
Error raises.

Since cab8d8fe7f744fb4dd0cd61b624f6f4519eb8d8d, we started to show
qty_remaining of WO on MO form. It triggered the compute function of
qty_remaining. Since we don't set product_id, production_id.product_uom_id
is not provided when doing the calculation.

To fix, add production_id.product_uom_id as dependancy of qty_remaining,
and don't do the calculation without it.

opw-3092723

closes odoo/odoo#107434

X-original-commit: 0b10241c0bcbecda73dae04c8a5f1ceb8033a388
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Yuchen Huang (yhu) <yhu@odoo.com>
2022-12-08 13:38:00 +01:00
Ahmed Khalaf 1aa59f8b01 [FIX] stock, mrp: popover widget sub templates
This commit changes popover widget such that instead of altering the
popover component during app lifecycle to make dynamic
popover templates, use `t-call` to call template passed in props.

closes odoo/odoo#107286

X-original-commit: f1a9de85c19a53c9516cac44de6cbaf53d850842
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-12-06 17:11:58 +01:00
JF Aubert dd228ff39f [FIX] mrp(workorder_hr): fix workorder duration
Previously, _intervals_duration (called by _compute_duration)
sometimes loose the last mrp.workcenter.productivity.
A fix has been made.
First, mrp.workcenter.productivity.loss _convert_to_duration
calculates according to the loss type, we have to take that in account.
Second, mrp.workcenter.productivity _close badly generates
performance timers.
For example, test_mrp_employee_analytic_account generated
- productive for 1st employee from 10:00 to 11:00
- performance for 2nd employee from 10:00 to 11:00
- performance for 2nd employee from 11:00 to 11:00 (! duration = 0)
Now, the timers are
- productive for 1st employee from 10:00 to 11:00
- productive for 2nd employee from 10:00 to 11:00
which is correct.

closes odoo/odoo#106908

Task: 2985735
X-original-commit: 8638ec145ab83e4afafa39a5c9e987e8d772bfd1
Related: odoo/enterprise#34533
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Jean-François Aubert <ajf@odoo.com>
2022-12-01 14:33:57 +01:00
JF Aubert b7e499473c [FIX] mrp(workorder_hr): fix workorder times
Fix workorder times problems:
- sum in workorders list view
  (displays numeric value rather than mins:secs)
- timers sometimes starts at -00:01
- almost all tablet view actions reset the timer (click burger, ...)
- clicking pause stops the timer at the next second
- seconds are lost in employee timers

Task: 2985735
X-original-commit: 7dceef12771890f9fb9fa554e70414c622053ced
Part-of: odoo/odoo#106908
2022-12-01 14:33:57 +01:00
Jinane Maksoud 4e06b34bce [FIX] mrp: fix the filter order in _bom_find_domain
Only active boms should be returned by the domain even if
they match a product id.

closes odoo/odoo#106615

X-original-commit: 2a73890d304476833d76bac9a36ef92f12f267a3
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-28 14:51:36 +01:00
William Henrotin 9ee9be3f4d [PERF] mrp,stock,purchase: sql improvement
First correction: replace call to `read_group` to `_read_group` in order
to avoid useless joints on table product_template and ir_translation
when the grouping key is a Many2One.

Second correction: add an index on workorder's `state` field. The
get_conflicted_workorder_ids() method search for ready workorders that
are in conflict relate to their planning. The state value is searched to
many times to not index it

closes odoo/odoo#106582

Task: 2852423
X-original-commit: b5019eec76845316e554f2dd11a6d8bbf6fea433
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-25 18:56:02 +01:00
Jigar Vaghela 82c1443254 [IMP] mrp,mrp_*,repair: MRP back to basics 6
mrp
===
- no time has been recorded on operations then give warning with apply button

- do not allow to mass edit UOM in any manufacturing state

- set value of lot/serial from MO and set read only on unbuild from MO

- remove "archive operation" icon

repair
======
Currently it is not possible to select a return on a repair order unless save it first. so after this commit user can able to select it without save it.
only show picking related to selected product

closes odoo/odoo#106571

Task: 2845380
X-original-commit: dd60647ce41547ecd00bbde45ddf564a7ada91c7
Related: odoo/enterprise#34403
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-25 18:55:35 +01:00
Tiffany Chang (tic) a3e1975074 [FIX] mrp: prevent editing of readonly locations for MO moves
Issue: In the MO view, the src location for components was editable and
the dest location for byproducts was editable when neither of these
should be.

Due to the same field appearing twice in the same x2many field list,
there were 2 issues:

1. something changed (probably during OWL refactoring) that made it so
   the 2nd invisible field instance of the field was overriding the
   "readonly='1'" property of the 1st instance when it was in the view
   (i.e. when multi-locations is active) [in previous versions this did
   not happen]
2. because of the change by https://github.com/odoo/odoo/commit/168cbe66bee7824bdf389de5c6c680342e27bc6d
   we ensure that these two required fields are always correctly set (to
   the MO's values as per the default when multi-loc is active) when the
   MO's moves are created.

Part of general bugfix task: 2985735

closes odoo/odoo#106542

X-original-commit: 1bb2c44d32e669a9b936da90cbd80721b2c897ef
Related: odoo/enterprise#34396
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
2022-11-25 17:56:55 +01:00
JF Aubert d55e6cca06 [IMP] mrp: adapt workorder gantt view
Adapt workorder gantt view to show blocked slots and summed times.

closes odoo/odoo#100350

Task: 2444754
Related: odoo/enterprise#31410
Signed-off-by: Steve Van Essche <svs@odoo.com>
2022-11-25 13:13:59 +01:00
Touati Djamel (otd) 8daffdd16a [FIX] mrp, sale_mrp: always use BOM UoM on Replenishment
Steps to reproduce the bug:
- Create a storable product “P1”:
    - route: MTO + manufacture
    - uom: unit
    - BOM:
        - qty: 1 dozen
        - component: 12 units of “C1”
- Create a SO:
    - Product: 12 unit of “p1”
    - uom: unit
    - Confirm the SO

Problem:
The UOM set on the product is used instead of the BOM UoM on the created
manufacturing order.

wrong MO:
    - 12 unit of "P1"
expcted MO:
    - 1 dozen of "P1"

opw-3048190

closes odoo/odoo#106351

X-original-commit: 8c5fb8b71538462422c8f166b772b5e316ecd6b5
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-11-24 10:02:53 +01:00
Adrien Widart (awt) 99c3e750c3 [FIX] mrp: check SN uniqueness on WO
When marking a WO as done, if the serial number defined is related to an
unbuilt product, an error will be raised and the user will not be able
to mark the WO as done

To reproduce the issue:
1. Create a BoM for product P with one operation
    - P is tracked by SN
2. Produce one P with serial S
3. Unbuild it
4. Create and confirm a second MO with 1 x P
5. Start the WO
6. On tablet view, set the finished lot to S
7. Mark the WO as done

Error: a UserError is raised because "This serial number [...] has
already been produced". However, this serial number has been unbuilt so
the worker should be able to use it again

When marking the WO as done, we check the uniqueness of the defined
serial number. But:
- The check is not accurate enough, hence the above error
- The lot of the WO is a computed/inverse field based on lot of the MO
- Once the WO closed, we can still change the lot of the MO
- When marking the MO as done, a better method checks the SN uniqueness
(does not fail in the above case)

Therefore, the checking on WO side is useless. We should let the MO side
handle this.

Moreover, let's say that there is already one P in stock with serial S2.
On tablet view, if the worker set the lot to S2, there should be a
warning so he can be aware of the situation. This is already the case on
MO side:
https://github.com/odoo/odoo/blob/45e37b2ad7bdcfd9f9f7e1dabbd0a99c9a0b5cdc/addons/mrp/models/mrp_production.py#L694-L705

(This commit is linked to a similar commit OE side, same opw)

OPW-3002424

closes odoo/odoo#106152

X-original-commit: 60a4c37c781ceb20123cb99603ddd2890b1c806c
Related: odoo/enterprise#34183
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-11-23 11:26:06 +01:00
William Henrotin cefb805273 [FIX] mrp: change dependency of related field
Fields `product_qty_available` and `product_virtual_available` on
stock_move are related on quantities fields of move's product_id. On
large database, those two fields will slow down every transactions that
updates stock move state (confirmation, validation, ...).

`state` on stock.move is a dependent field of computed field `qty_available` on
product.product which is dependent field of related field
`product_virtual_available` on stock move. This relation tree implies
that updating the state on one particular stock move will mark its
product (qty_available) as 'to be recomputed' and thus **every** stock
moves (product_virtual_available) of this product as to be recomputed.
On database will 100k+ stock move per product. Fetching all stock move
of some products take 90% of a manufacturing order validation time. This
is problematic knowing those two quantity fields are only used in the
stock move tree form so computed anyway at the view rendering.

This commit change the `depends` of those two related field to mark them
as to be recomputed only if the product_id change.

closes odoo/odoo#106070

Opw: 3047017
X-original-commit: 189e825e567e4c633d721ce9f0fee906535edf06
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-11-21 09:51:19 +01:00
Thibault Delavallée 202153fb1b [IMP] mail, various: cleanup empty list help message overrides
Purpose is to cleanup code: stop using help parameter name (use help_message as
help is a keyword), try to call super(), ...

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#105992
2022-11-18 13:59:53 +01:00