Commit Graph
995 Commits
Author SHA1 Message Date
Swapnesh Shah acb9e5fe49 [FIX] mrp: do now allow to select cancelled mo
Before this commit, User can select Cancelled MO before selecting Product.
but it is already blocking since we already have constrains to not allow ubnuilding
Cancelled MO.

With this commit, We are always showing Done MO.

closes odoo/odoo#70316

X-original-commit: 48c0efcc97e35e00ec5803235a89a2c18e821990
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-05-04 10:31:16 +00:00
Swapnesh d7f24257b3 [FIX] mrp: display correct uom on by products
Before this commit, It was always showing all
Unit of Measures in By Product lines.

With this commit, We are showing UoMs based on Category
of Selected Product's UoM.

closes odoo/odoo#70367

Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-05-06 16:52:25 +00:00
Swapnesh Shah ac5590c7db [FIX] mrp: compute duration when needed
Before this commit there would be trackback (TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType') when you will try to remove field Start date as we are using the field to compute duration.

With this commit, we compute duration when Both fields are present.

closes odoo/odoo#70482

X-original-commit: f29597fce37350f1c05d98341b959809bbb160b2
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-05-06 12:58:03 +00:00
Swapnesh Shah f7e0787ae4 [FIX] mrp: set default product on unbuild order
Before this commit, Creating Unbuild order using
 Unbuild Button was resetting Bom as it was calling
`_onchange_product_id` after setting `mo_id` which was
resetting Bom on Unbuild order.

To Fix Issue, We setting `default_product_id` so It would not
reset `bom_id` when `_onchange_product_id` is called.

Fixes: #70216
Odoo Ticket: 2521788

closes odoo/odoo#70304

X-original-commit: 4de0ae434d1adc97fc1077b8d0f23c7e800ec161
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-05-04 09:23:17 +00:00
Swapnesh Shah 2511100232 [FIX] mrp: allow to select product w/o bom
Without this commit, User was not allowed to create Unbuild Order
for the product without BoMs from Unbuild Orders menu.
But User was able to create Unbuild Order using 'Unbuild Order' button
on MO.

With this commit, We are allowing user to select Products without BoMs
to make this behavior consistent so user can create Unbuild Order from
Unbuild Orders menu.

closes odoo/odoo#70246

X-original-commit: eb332de42a36b7235d5578d39d345a5ff1df7759
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-05-03 10:58:11 +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
Ivan Yelizariev 038fdcabe0 [FIX] mrp: optimize _compute_used_in_bom_count
previous implementation works slowly for products with many variants.

Performance Test
================

* ~5 K product.template
* ~14 K product.variants
* ~12 K mrp.bom
* ~414 K mrp.bom.line

Reading time for the field on a product with ~1000 variants

Measuring total request time:
* Before 9,5 sec
* After:
** without module upgrade 1,5 sec
** with module upgrade 0,3 sec

Measuring query execution in psql:
* Before 7,2 sec
* After:
** without module upgrade 0,7 sec
** with module upgrade 0,001 sec

---

opw-2494423

closes odoo/odoo#69293

Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-04-15 09:15:16 +00:00
Swapnesh Shah ccbab1a1ea [FIX] mrp: remove workorder_ids on removing bom_id
Method `_onchange_workorder_ids` will create workorder_ids
for the the selected bom but it was not re-setting it on removing
BoM.
It was causing issue on `_action_confirm` as Bom for the selected
WO will not be found.

closes odoo/odoo#69662

Fixes: #68261
X-original-commit: 13832912daafad7c472d7414eaacede9e302e787
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-04-22 10:30:21 +00:00
hur@odoo.com 4959fdd2bb [FIX] mrp: Kit Operations on parent MO without operations
Usecase to reproduce:
- BOM PROD 1 -> No operation -> KIT COMP 1
- BOM KIT COMP 1 -> at lease one operation

Create a MO and confirm it -> Traceback.

It happens because workorders_by_bom[production.bom_id] will try to
find the bom related to production order. However they don't exist but
it will create the entry [BOM PROD 1] = mrp.workorder()

The [0] will be call on each values of the list afterward and raise
the traceback

opw-2477269

closes odoo/odoo#69651

X-original-commit: edabb86a306c4dda088b39f163de5668b5d90392
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-22 09:43:04 +00:00
Ivan Yelizariev 8a6b6dee7d [FIX] mrp: optimize _compute_used_in_bom_count
previous implementation works slowly for products with many variants.

Performance Test
================

* ~5 K product.template
* ~14 K product.variants
* ~12 K mrp.bom
* ~414 K mrp.bom.line

Reading time for field ``used_in_bom_count`` on a product with ~1000 variants

* Before 9,5 sec
* After 1,5 sec

---

opw-2494423

closes odoo/odoo#69341

X-original-commit: a2d63e8ae5d6bc0e822d12d724b5e3ff5a979cad
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
2021-04-15 17:16:54 +00:00
JF Aubert 0b3bdcf14c [IMP] mrp: change bom operation
Ease bill of material - operation configuration.

- allow to change the BoM of an operation,
- allow to update a BoM by duplicating existing operations(& quality points),
- by extension, changing the operation of a quality point update the products.

closes odoo/odoo#65628

Task: 2413246
Related: odoo/enterprise#16159
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-04-15 09:39:45 +00:00
Nicolas Pierre 1355c9694e [FIX] mrp: archive operations when deactivating WO
When we deactivate the work orders in the settings, new MOs still
use operations that were assigned to the BoM, it just does not show the
Operations tab. We fix that by archiving the operations when work orders
are deactivated in the settings.

closes odoo/odoo#66108

Related: odoo/upgrade#2344
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-14 07:48:16 +00:00
Adrien Widart 6a48fd9237 [FIX] mrp: set qty produced on operation
When marking an operation as done, the quantity produced may be zero.
Therefore, the duration computation will not work.

To reproduce the error:
1. In Settings, enable "Work Orders"
2. Create two products P_prod and P_compo
    - P_compo is consumable and its cost is 100
3. In Manufacturing, edit/create a Work Center WC
    - Cost per hour must be 60
4. Create a Bill of Materials BM
    - Product: P_prod
    - Component: P_compo
    - Operation:
        - Work Center: WC
        - Duration Computation: Compute based on tracked time
        - Based on last 3 work orders
        - Default Duration: 10:00
5. In Structure & Cost, notice that BoM Cost is 110
    - 100 (P_compo's cost)
    - 10 (OP's cost based on default time)
6. Do the following 3 times:
    - Create a MO with P_prod using BM, Confirm
    - In Work Orders, click on Start, then Done
    - Edit the Real Duration of OP: 20:00
    - Mark as Done
7. Back to BM, open Structure & Cost again

Error: BoM Cost is 110, this is incorrect: OP's cost is still 10, it
should be 20 (from step 6).

The problem is the quantity produced for each operation. Since this
quantity is never defined, it remains at 0. Therefore, when computing
the duration, since there is no quantity, the module keeps the default
value.

This fix changes the behavior. When the user marks the operation as done
from the form view, the module defines the quantity produced using the
quantity in production (this quantity may have been defined by the user
through the tablet mode). If this value is also 0, the module will use
the quantity expected by the MO.

`('qty_produced', '>', 0)` is added to avoid lines with zero quantity
produced, which was possible before this fix. Otherwise, the duration
calculation will give wrong values.

OPW-2453996

closes odoo/odoo#68917

X-original-commit: 93be6c6cfcfb3c4e52790569632dbdcdb1a3ae54
Related: odoo/enterprise#17540
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-04-07 17:27:39 +00:00
yhu-odoo 92e577d106 [IMP](sale_)stock,mrp: smart putaway rules
We introduced new Smart Putaway Rules.
Locations now can have a storage category, on each storage category,
we can specify the amount of products/packages(with certian package
type) that can be stored in the location.
On putaway rules, we can also set a storage category. Now when apply a
putaway rule, we will find a suitable child location of the out
location according to quantity/weight setting on the storage category.

Task 2341820
PR #63516
ENT PR odoo/enterprise#15363
UPG PR odoo/upgrade#2040
2021-03-31 09:00:40 +00:00
Rémy Voet (ryv) 64caa930b3 [REF] stock: cache the get_warehouse of stock.location
To avoid multiple search of the get_warehouse for the same location
and extra SQL request (it happens a lot for complicate flow, e.g.
mrp_mps, replenishment report).
Translate it into a standard compute to use the cache of
the ORM for no-store compute field (`warehouse_id`) and put
some depends to be always correct (even if `warehouse_id` shouldn't
change in the same request).

task-2439019
2021-03-30 09:27:05 +00:00
Rémy Voet (ryv) 974c4398b4 [REF] *mrp*: batch _bom_find
Some usage of `_bom_find` are performance bottleneck (one request by
product). By example, when the mrp is installed, search products
with fields compute by `_compute_quantities` (e.g. 'Negative forecasted
quantity'). it is due to the override of `_compute_quantities`
in mrp which will make (in the worst case) a `_bom_find` for each
product in the DB.
To avoid this situation the `_bom_find` method become batched
which can handle several products in once. The signature of the method
has changed and uniformize in all module.

Example performance Gain:
------------------------
In a DB with 7000 products (type 'product'), 500 locations, 1800 BoM,
9000 Stock moves, etc. Search in the tree view with filter "Negative
forecasted quantity":
Before: 10879 (nb SQL request) 12.67 +- 0.11 sec (Total RPC Time)
After: 159 (nb SQL request) 1.82 +- 0.03 sec (Total RPC Time)

task-2439019
2021-03-30 09:27:05 +00:00
yhu-odoo 93efaa8ce3 [IMP]stock,mrp: merge same components on MO
When adding extra components on MO, merge to one line if we already have
same components

Task 2446915
PR #66583
ENT PR odoo/enterprise#16554

Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-03-30 11:49:54 +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
Adrien Widart 212deeea29 [FIX] mrp: prevent creation of reordering rule on kit
Because kits might never be in stock, it's impossible to fullfil the
quantity of a reordering rule: asking a mini/maxi quantity on a kit
makes no sense.

Odoo will continuously propose to order more to reach the quantity
necessary for the kit, but will never reach the asked qty, as it's a
kit, not a manufactured product.

OPW-2448878

closes odoo/odoo#68362

X-original-commit: c47a9319c081105e46e56f881b25fd6442266089
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-03-25 16:50:54 +00:00
svs-odoo 02bd058800 [IMP] mrp: workcenters views
Some changes on the MRP workcenter model (`mrp.workcenter`):

  - Adds a stat button in the form view to display operations used by
    the workcenter;

  - Enables the multi-edit on the list view;

  - Adds multiple fields in the list view, often as optional;

task-2382256

closes odoo/odoo#62126

Related: odoo/enterprise#17250
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-03-24 08:21:34 +00:00
svs-odoo 38ac9ccbc1 [IMP] mrp: operations listview
On the MRP operation model (`mrp.routing.workcenter`):

  - Changes the order (ordered by workcenter and BOM in priority);

  - Adds computed field, `time_computed_on`, which is only used in list
    view (display on how many numbers of work orders the duration is
    computed);

  - Adds multiple fields in list view (often optional display);

  - Adds two groupby (by BOM and by workcenter).

task-2382256
2021-03-24 08:09:17 +00:00
Rémy Voet (ryv) c294f5236a [FIX] stock: fix _get_matching_bom
The`picking_type_id` of the stock.rule wasn't take in account in
the search of BoM because the `_get_matching_bom` with a empty `self`.
fix it by call on the current rule.

X-original-commit: d43e9cb9ad8d1c0c020209de0e8f6ffdcbc960a1
2021-03-16 12:09:00 +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
Rémy Voet (ryv) 0468e3ccc1 [FIX] mrp: avoid dynamic domain for product_id in MO form
Issue:
On DB with a lot of product (e.g. 50K) the MO form is very slow
open/modify. It is due to the `_compute_allowed_product_ids` which
will set the `allowed_product_ids` fields with all product ids possible
(32K), then the `convert_to_record` will take a bunch of time to filter
out no-active product.

Fix:
In your case, to avoid to send bunch of ids to the web framework and
bypass the costly `convert_to_record`, we decided to simply (static) the
domain of `product_id` (`mrp.production`). The flow will be slightly
different (doesn't filter depending of `bom_id`) but still good and
maybe better (we can now modify the product without removing the
BoM/product in the MO form).
Remove `allowed_product_ids`.

opw-2475151

closes odoo/odoo#67753

X-original-commit: a1a4f4548b395127cf7f816379a63f2d47688893
Related: odoo/upgrade#2272
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-03-12 13:00:20 +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
Adrien Widart 9777a2b4d6 [FIX] mrp: kits and PO based on reordering rules
If a product is a kit and has a storable component, if this component is
already ordered (with sufficient quantity), when running the scheduler,
the ordered quantity of this component will still be increased.

To reproduce the error:
1. Create two products P_kit and P_compo
	- Both are storable products
	- P_compo must have at least one vendor
2. Create a BoM for P_kit:
	- Must be a kit
	- Add P_compo to components
3. Set a reordering rule for P_kit
4. Inventory > Operations > Run Scheduler
5. Go to Purchase and find the generated RfQ
	- The ordered quantity is correct
6. Repeat 4-5

Error: This time, the ordered quantity is incorrect. While you don't
have any P_kit on hand, each time the scheduler is run, the ordered
quantity will increase.

A similar issue has already been fixed: #63891. The original commit
targets the version 13, but the fix has also been applied to v14 (#64277).
However, here the case is slightly different: the user run the scheduler
twice while the first RfQ is not yet confirmed and received. In such a
case, the scheduler must also check the "quantity in progress". In version
14, it seems nothing computes this quantity for the kits.

OPW-2421841

closes odoo/odoo#65100

X-original-commit: f53ab55000c32fd67c567f01a9533298936daaac
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-01-27 09:57:57 +00:00
Rémy Voet (ryv) c8b3035efc [FIX] mrp: add indexes on highly search fields
Add two indexes (on `product_id` and `product_tmpl_id`)
on the `mrp.bom` model to speed up `_bom_find`
which is highly used and it uses always the `product_tmpl_id` and
sometime the `product_id` in the search domain.

Performance Gain:
With a DB with 2K BoM, a `_bom_find` search (`product_id` and
`product_tmpl_id` are in domain): The SQL execution time
is +- 5 times faster.

task-2390516

closes odoo/odoo#64934

X-original-commit: 64861aed03b616820d717bc08e7c38c56145e0f2
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-01-22 15:49:11 +00:00
Rémy Voet (ryv) 4fa1f28cd0 [IMP] mrp: improve scalability of action_explode
Replace union of RecordSet by union of OrderedSet to reduce the
complexity and improve the scalability. It can be a bottleneck to
huge number of move to validate.

task-2390516

X-original-commit: d9510aee26578e1b345a7700f7c94032d5745bf4
2021-01-22 15:49:11 +00:00
Rémy Voet (ryv) bec794f776 [REF] stock,purchase(_*),mrp: clean related fields
Related fields are by default readonly and they should be when it
is possible. A editable related field will write on the related
model and will cause extra unwanted write of data. These unwanted write
can cause performance issues in some case (see odoo/odoo#63865).

Then remove the `readonly=False` of some related fields
(where it is useless):

- In 'mrp.workorder' (mrp): `working_state` and `production_date`
should be readonly.
- In 'purchase.order' (purchase): `product_id` should be readonly.
- In 'purchase.order.line' (purchase): `state` should be readonly.
- In 'product.supplierinfo' (purchase_requisition):
`purchase_requisition_id` should be readonly.
- In 'purchase.requisition' (purchase_requisition):
`product_id` should be readonly.
- In 'product.template' (stock):
`route_from_categ_ids` should be readonly.
- In 'stock.move.line' (stock):
`is_initial_demand_editable` should be readonly.
- In 'stock.move' (stock):
`product_tmpl_id` should be readonly.
- In 'stock.production.lot' (stock):
`product_uom_id` should be readonly.
- In 'stock.quant' (stock):
`product_tmpl_id` should be readonly.
- In 'stock.rule' (stock):
`route_sequence` should be readonly.
- In 'stock.change.product.qty' (stock):
`product_variant_count` should be readonly.
- In 'stock.return.picking.line' (stock):
`uom_id` should be readonly and also because it
is forced by `_prepare_stock_return_picking_line_vals_from_move`,
it should be related to the product uom not the one on the move.

task-2424248
2021-01-21 11:09:58 +00:00
JF Aubert 718d16f386 [FIX] stock: multiwarehouses bugfix
Ease multiple warehouses per company creation.
Clarify unique warehouse code constraint message.

task: 2371755

Fix Replenishment Forecasted Report incorrect warehouse & quantity display.

closes odoo/odoo#62601

Task: 2401496 (ticket: 2393320)
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-01-07 10:37:25 +00:00
Adrien Widart 31bf2fd446 [FIX] mrp: reordering rules for BoM product
When running the scheduler, if one of the concerned product  is a
kit, it will always generate a RfQ for the components, even if there
are already enough of them.

To reproduce the error:
(Need purchase)
1. Create 2 products P and P_compo
	- Both must be storable products
	- P_compo must have at least one vendor
2. Go on P-product page
3. Add a reordering rule (e.g., min: 5 and max: 10)
4. Add a BoM
	- Must be a Kit
	- Add P_compo to components
5. Inventory > Operations > Run Scheduler
6. Go to Purchase, find the generated RfQ
7. Confirm the order, Receive Products, Validate
8. Go on P-product's page
	- As you can see, you have enough P-products on hand
9. Repeat steps 5-6

=> You should not find any RfQ since you already have enough P-products.

When checking the P-product's page, you can see the correct quantity on
hand because it uses the `_compute_quantities` method and this one has been
overridden in the mrp-module so a kit will be correctly computed.

However, when running the scheduler, it uses another method to get the
current quantities: `_compute_quantities_dict`. Since this method has
not been overridden in mrp-module, it will use the basic implementation
and this one does not consider the possibility for a product to be a
kit.

This fix creates an override of `_compute_quantities_dict` so it can
compute the correct quantities of products with 'phantom' as BoM type.
Moreover, for the code to be simpler and clearer, thix fix also merges
`_compute_quantities` and the new `_compute_quantities_dict`.

OPW-2421841

closes odoo/odoo#64326

X-original-commit: 609e2f4427082431b56aa8f999d74ed9d39db653
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Adrien Widart <adwid@users.noreply.github.com>
2021-01-11 11:46:01 +00:00
Rémy Voet (ryv) e292c3fb53 [REF] mrp: consumption of workorder become related
Avoid duplicate information in DB.

task-2373638
2021-01-05 08:32:58 +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) e4b0f75799 [REF] mrp: clean onchange of mrp.production
Avoid crappy try-except in `onchange_picking_type` and have a coherent
fallback instead.

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

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

task-2373638
2021-01-05 08:32:05 +00:00
Rémy Voet (ryv) e8be3acb83 [IMP] mrp: add indexes in mrp.workcenter.productivity model
We add a index on the workcenter_id and workorder_id, both
have a One2many related to  (`time_ids` of workcenter and workorder)
and both is in the some search domain in python (also in search view).
(Also change the `readonly='True'` into correct form `readonly=True`
of `production_id`, and remove duplicate fields `workcenter_id` in view)

task-2389380

closes odoo/odoo#63500

Related: odoo/upgrade#2042
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-12-22 12:43:00 +00:00
Rémy Voet (ryv) d346cd1ec2 [IMP] mrp: add index on bom_id for byproduct
The `bom_id` field has a One2many inverse `byproduct_ids`
then it should by index to avoid bottleneck if byproduct is
highly used by a lot of different BoM

Performance improvements:
When there is 20K of Byproduct line, read a BoM is x1.8 faster.

task-2389380
2020-12-22 12:43:00 +00:00
Rémy Voet (ryv) 876c2c33e8 [REF] mrp: remove indexes of mrp.production (date_x)
Remove index on fields `date_start` and `date_finished`. Both
has not used expected in the gantt view `view_production_gantt`
which not used anymore (and have no sense because it should use
`date_planned_start` and `date_planned_finished` instead.
Remove this old gantt view too.

task-2389380
2020-12-22 12:42:59 +00:00
Rémy Voet (ryv) e74ecbbd6c [REF] mrp: remove index on state (mrp.unbuild)
The state of `mrp.unbuild` is a boolean value (`draft` or `done`) which
is already quite useless in the most of the case. Also this state is
never used explicitly in the code (in a search), then it seems legit to
remove it.

task-2389380
2020-12-22 12:42:59 +00:00
Rémy Voet (ryv) e3423d3f28 [REF] stock,mrp: remove index of priority fields
Indexed of boolean values is quite useless and the one of `priority`
(MO/Pickings) can be only used in filter search view (`starred`).
Then remove priority indexes from `stock_move`, `stock_picking` and
`mrp_production`.

task-2389380
2020-12-22 12:42:59 +00:00
Andrea Grazioso (agr-odoo) b3a23aa0e8 [FIX] mrp: avoid traceback on company reset
- Create a new MO
- Remove the company name

The user see a traceback

This occur because the compute method does not check if the company is
set

opw-2422441

closes odoo/odoo#63917

X-original-commit: b7fa0cfad03a8319f03c1aa89eb67635e1200f67
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-12-30 14:30:16 +00:00
Rémy Voet (ryv) 5199fb34f0 [FIX] mrp: avoid write product_tmpl_id from BoM line model
`product_tmpl_id` of BoM line should be readonly,
there is no sense to change the product template from
the BoM line model. Also it avoids useless write on product
and inverse recomputation.

opw-2420830
closes #63631

closes odoo/odoo#63890

Issue: odoo/odoo#63631
X-original-commit: 5a4746141670bdd241d85c7908a57ee9efa56c3f
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2020-12-29 15:58:07 +00:00
svs-odoo 186a8b962b mrp,stock: rename quality_control_worksheet
Add option to install Quality Control / QC Worksheets from stock
settings.

task-2281266
2020-12-09 08:30:28 +00:00
yhu-odoo f1933add37 [IMP] mrp: install quality_worksheet in setting
Add a checkbox to install quality_worksheet in mrp setting, it will be
shown when quality_control is installed.

Task 2281266
2020-12-09 08:30:28 +00:00
Yannick Tivisse 0078a21876 [IMP] resource: Remove deprecated methods 2020-12-08 10:22:36 +00:00
Adrian Torres 679185f3e8 [IMP] *: replace all raises inside unlink by api.ondelete
With this commit, all instances of errors being raised inside
`BaseModel.unlink` overrides are moved into methods decorated with
`api.ondelete` which is safer.
2020-12-04 09:16:16 +00:00
Tiffany Chang (tic) 2eb40fee87 [IMP] mrp, (sale_)stock: remove unused imports
Removing some unused imports noticed while working on task: 2359317
2020-11-30 16:29:08 +00:00
Nicolas Martinelli 0a09992f9d [FIX] mrp: UoM category mismatch
- Create Product A with UOM of type Unit
- Create Product B with UOM of type Unit
- Create BOM of type Kit on Product A with Product B as a component
  with UOM of type Unit
- After saving BOM, change the UOM of Product B with UOM from another
  categories (e.g. kg) and save the product
- Try to access product list

A warning appears and prevent showing the products in any way.

It is caused by the call to `_compute_quantities`.

In this case, it is ok to skip the error. Indeed, it will raise later on
when trying to use the kit. But at least, it gives the possibility to
the user to access the product list.

opw-2393711

closes odoo/odoo#62537

X-original-commit: 6de2537ac82d9dad3cb3f56a7b9b35856681a6ad
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-11-27 13:39:19 +00:00