Commit Graph
20 Commits
Author SHA1 Message Date
Aurélien (avd) 6c0744d672 [FIX] stock: speed up _find_delivery_ids_by_lot
Rewrite _find_delivery_ids_by_lot to reduce the number
of recursive calls by grouping the producing move lines
together before each recursive calls. This reduces
the number of search calls, speeding up the whole method.

Add a unittest to check if the delivery_ids field
of a lot recordset is properly computed.

opw-2824464

X-original-commit: e7b9f14d4a9ce4ed61451b24b567f751fb4bcbe2
Part-of: odoo/odoo#95398
2022-07-06 13:11:48 +02:00
Adrien Widart b622f3b9b1 [FIX] mrp: produce a tracked and manufactured component
In some cases, it is not possible to produce a tracked product that has
been used as a component of another product.

To reproduce the issue:
1. Create three products A, B, C:
    - A storable
    - B storable and tracked by lot
    - C consumable
2. Update on-hand qty of B
    - 10 x lot L01
    - 5 x lot L02
3. Create two bills of materials
    - Product: A
        - Components: 1 x B
    - Product: B
        - Components: 1 x C
4. Produce 15 x A (MO01)
    - Note: it should use 10 L01 and 5 L02
5. Produce 15 x B with lot L03 (MO02)

Error: When marking MO02 as done, a user error is displayed: "Cannot set
the done quantity from this stock move, work directly with the move
lines." The user should be able to mark the MO as done.

When confirming MO02, it confirms the associated SMs. Since the
conditions are respected, we try to assign both consumed and finished
moves. Because of step 4, there are two quants for the product B in the
production location (one for L01 and another for L02). Therefore, when
reserving the qty of the finished move, two SML are generated. As a
result, when marking MO02 as done, we write the `quantity_done` on the
finished move. This triggers the inverse method and leads to
`_multi_line_quantity_done_set`, where the error is raised because the
done quantities are not defined on each SML:
https://github.com/odoo/odoo/blob/1354081e43b71edbd434dccc6df6d0881c672a81/addons/stock/models/stock_move.py#L363-L364

Thanks to `_set_quantity_done`, we can write these done quantities on
each SML (and then the incorrect lots will be replaced by the producing
lot).

OPW-2752436

closes odoo/odoo#89015

X-original-commit: 65efb3ec5416fab6bb9ba0a015565b2abb3928cd
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-04-19 15:33:53 +02:00
Adrien Widart 77ca3a830d [FIX] mrp: produce SN product with lot of unbuilt product
To reproduce the issue:
1. Produce a SN product P with lot L
2. Unbuild it
3. Produce 1xP with lot L

Error: When setting the lot, an error is displayed. When marking the MO
as done, a second error is displayed

Both domains in `_onchange_lot_producing` and in the beginning of
`_check_sn_uniqueness` are incorrect. We should centralize the
uniqueness checking thanks to all existing computations in
`_check_sn_uniqueness`. This way, unbuilt/scrapped moves will be
considered

OPW-2721205

closes odoo/odoo#84374

X-original-commit: 2540104e95cea7baaa22ccfce97759771dbbaf34
Signed-off-by: Tiffany Chang <tic@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2022-02-11 11:40:19 +00:00
William Henrotin 6a23b9bcd6 [REF] *stock*: rename model stock.production.lot into stock.lot
Task: 2648449
Part-of: odoo/odoo#80434
2021-12-07 16:20:05 +00:00
Arnold Moyaux bdcb3d192b [REF] stock: move stock.inventory feature into stock.quant
This commit removes stock.inventory(.line) and moves its general
functionality into stock.quant. Some features are lost during this
switch as well.

Feature Additions:
- New single list view for inventory adjustments (no more multiple
  inventory adjustment records to keep track of!)
- Improved cyclic counts (annual inventory day setting) + next inventory
  dates are immediately viewable in view (vs auto-generated inventories
  based only on location)
- Specific quants (i.e. counts) can be assigned to users for more
  flexibility (vs only able to restrict by location + product
  combinations)
- Counts can be requested (i.e. bulk assigned to user/for a specific
  inventory date)

Feature Removals:
- Can no longer look at previous inventory adjustments linked to a
  specific record. Each quant has a history button to show inventory
  related moves. [relevant account moves are also now harder to see via
  stock as well]

Other changes:
- Bulk of changes were for demo/test
- Some changes were done to ensure "Update Quantity"/"Inventory Report"
  views still mainly function the same as before with the exception of a
  new column added to support updating quant quantities in these views.

Task: 2440026
ENT PR: odoo/enterprise#17329
Upgrade PR: odoo/upgrade#2326

closes odoo/odoo#68409

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-02 11:51:38 +00:00
yhu-odoo 2c5ce41c42 [IMP] uom: change default rounding to two
Change the default rouning digits of all UoMs to be two, also change the
decimal.precision of UoM to be two. Adapt all the tests.
Also to avoid hardcoded digits in `should_consume_qty` widget.

PR #56000

X-original-commit: 460ec0402a2352a5b179d81935f7230f6bc97cb7
2020-09-09 09:21:12 +00:00
Rémy Voet (ryv) 5011ec520c [REF] mrp: review consumption allowing
Now, by default, a Bill of Material have a flexible
consumption instead of strict consumption. Also
add new consumption choice: a flexible consumption
but with a warning when the bom isn't respected.
Also, now, the strict (a new warning option) consumption
is checked only when we try to mark as done the MO.

task-2241471
2020-06-15 16:59:41 +02:00
William Henrotin 0e2765f5fd [REF] mrp: no more produce wizard
Use a view similar as the pickings one.

task-2241471
2020-06-15 16:59:41 +02:00
Rémy Voet (ryv) 53252608d7 [REF] mrp: backorder mechanism
Allow to "backorder" a production, meaning create another manufacturing
order with the quantity remaining to produce. We also use the
reservation of the first order on the next ones by using
`post_inventory` on the first one and moving the newly created stock
moves to the backorder.

We introduce a wizard similar to the one in stock.
Backorders have a sub-sequence.
Backorders are linked together through the procurement group.
We allow creating a backorder even if workorders are running by closing
them, the backorder will call `button_plan` and create its own.

task-2241471
2020-06-15 16:59:40 +02:00
Simon Lejeune 96406dc2a9 [REF] mrp: multi company
Ensure proper domains are applied and enforced on relation fields thanks
to the `check_company` attributes.

Make sure unbuild have proper sequence for each companies.

The produce wizard and workorders company is the one of the production.
The BoM line company_id is the one of its bom_id.
Added some tests.

task-1985992
2019-09-03 15:05:03 +00:00
Raphael Collet 9920f20e4c [IMP] models: ORM speedup
This branch is the combination of several optimizations in the ORM:

* store field values once in the cache: the cache reflects more
faithfully the database, only fields that explicitly depend on the
context have an extra indirection in the cache;

* delay recomputations by default: use method `recompute` to explicitly
flush out pending recomputations;

* delay updates in method `write`: updates are stored in a data
structure that can be flushed efficiently to the database with method
`flush` (which also flush out recomputations);

* make method `modified` take advantage of inverse fields to inverse
dependencies;

* filter records by evaluating a domain on records in Python;

* a computed field with `readonly=False` behaves like a normal field
with an onchange method;

* computed fields are computed in superuser mode by default.

Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien
Pinckaers.

closes odoo/odoo#35659

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-08-20 12:43:59 +00:00
Yannick Tivisse 14067543d0 [IMP] uom: Remove parentheses on uom names
Purpose
=======

Parentheses in the label of units of measure sometimes make
reading needlessly uncomfortable.

Specification
=============

Remove parentheses in the name of every standard uom.uom and hardcoded
occurence on views/field names.

TaskID: 2030444

closes odoo/odoo#34492

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-07-15 12:57:34 +00:00
svs-odoo cc9324f740 [IMP] *: usability of Inventory Adjustment
Change the use of Inventory Adjustment, notable changes are:

    - Removed filter field: When user creates a new inventory
    adjustment, he can set one or multiple locations and/or products.
    An inventory adjustment will worry only about defined
    locations/products, but if neither product or location was set,
    it'll manage all stock.

    - Inventory Adjustment Lines have their own view instead of be
    listed on the Inventory Adjustment form view.
    Inventory adjustment lines have new color legend:
        - Red: The quantity is outdated.
        - Blue: There is difference between the on hand quantity and the
        counted quantity.
    New inventory lines created by the user are written in bold.

    - User can't modify already existing inventory lines, except for the
    counted quantity.

    - When an inventory line is outdated, the user has the possibility
    to select and update it, that'll recompute the on hand quantity.

    - When an inventory adjustment is validated, it will take in account
    only the difference between the theoretical quantity ('On Hand
    Quantity') and the counted quantity to adjust the quants.

    - When an inventory adjustment is canceled, it will keep its
    inventory lines and won't regenerate them when re-started.

    - When an Inventory Adjustment generates Account Moves, user can now
    find them in a stat button in the Inventory Adjustment form view.

Also, made some changes in demo data to match new requirement.

Task #1935921
2019-05-29 14:03:29 +00:00
William Henrotin 199bb65b42 [IMP] mrp: rename final_lot_id
Commit 5ef46664a2 share code between produce
wizard and workorder. Field final_lot_id is now commonly used but not very
well named. This commit rename it into finished_lot_id as it represent the
lot number of the finished product.

Task : 1998064

closes odoo/odoo#32761

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-05-27 07:45:07 +00:00
Arnold Moyaux 12da02d161 [REF] mrp: rename subproduct in byproduct
subproduct and byproduct are both used in code.
However the UI always shows by-product only.
Rename sub.product, sub_product,... in byproduct
in order to use the same term everywhere.

closes odoo/odoo#32540

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2019-04-12 12:50:34 +00:00
Arnold Moyaux 030db4a4b0 [IMP] mrp: tracability on byproducts
In MRP the tracability is only set between the finished
products and the components. However when the by-products is
tracked by serial number, it could be usefull to know from which
components it was created. This commit add the link between by-products
and raw materials (only in produce wizard at the moment).

Technically we replaced the one2many field by a many2many.
2019-04-12 12:50:34 +00:00
William Henrotin 5ef46664a2 [IMP] mrp: add production lines
To record a production via a manufacturing order, the user can either
use the produce wizard or the workorders views. Those two objects was
technically different but act more or less the same. This commit aims to
merge the similar behaviors in common code

We introduce two new abstract models :
 1. Abstract workorder to share workorders and the produce wizard
 2. Abstract workorder lines to share active_move_line on workorder and
    product_produce_line on the wizard. Those abstract line keep the information
    about the quantities and lot number to put on component move lines and
    finished product move lines

Task : 1891864
2019-02-01 08:13:25 +00:00
Arnold Moyaux 7206b385b5 [IMP] mrp: raw moves generation in onchange 2018-11-27 11:58:02 +00:00
Arnold Moyaux 3bb3e6a530 [IMP] mrp: add a 'draft' state to MO
The purpose is to be able to plan manufacturing order
without propagate the components's documents directly.
Except when the manufacturing comes from a pull rule, it will
be confirmed directly.

In order to do it, it will just create the moves without confirm them.
They will be only confirmed after a 'Mark as Todo' click.
2018-11-27 11:57:43 +00:00
TWA 0cd475124f [IMP] stock,mrp: Enable traceability report for non-tracked products
PURPOSE
=======

Make the traceability report available in more use cases.

SPECIFICATIONS
==============

1. Traceability Button on Manufacturing Orders
There should always be a traceability report available on the MO,
no matter if the finished product is tracked or not.

Example 1 : finished product is not tracked
            but the components are tracked
Example 2 : finished product is not tracked (qty>0)) but
            the components are tracked
Example 3 : no products are tracked

Task id: 1861928
2018-08-21 22:25:25 +02:00