Before this commit, the product/product template computed mrp quantity
fields wasn't computed by active company but for all companies.
So, set `compute_sudo` on false for the different computed mrp quantity
fields of products and product templates to avoid to search with sudo
active and to search by company.
Steps to reproduce the bug:
Let's consider two storable products P1 and P2 where P1 is tracked by serial number
- Create a BOM B for P1 where P2 is a component
- Create a serial numberv SN for P1 with no quantity
- Create a MO M1 for P1 and click on button "Produce"
- In the view MRP Product Produce, SN is selectable in the field lot_id
- Now change B and set a routing on it
- Create a new MO M2 for P1 and click on produce
- At least one WO has been created, click on the first one
Bug:
- SN is not selectable in the field final_lot_id
The domain set on the field final_lot_id:
"['|', '&', ('product_id', '=', product_id), ('product_id.tracking', '!=', 'serial'), ('use_next_on_work_order_id', '=', id)]"
didn't allow to chose SN.
With this fix, it's now possible to chose SN on the first WO created for M2
opw:2059745
closesodoo/odoo#36425
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
The condition needs to be fined-tuned, so revert for now.
This reverts commit 40487aca5c.
closesodoo/odoo#36470
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Steps to reproduce the bug:
- Create a MO with a product with a normal bom B
- Save the MO
- Change the type of B to phantom
- Try to produce the MO
Bug:
It was impossible to cancel or confirm the MO.
It's not allowed to produce a MO with phantom bom.
opw:2061958
closesodoo/odoo#36329
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
It's due to MRP refactoring that confirm raw moves before finished
moves. It implies that in _assign picking, SFP with final product
will search a picking but the stock.move do not have a created_production_id
and it will be merged inside the intermediate SFP (it works before
because it was the intermediate SFP that was merged in the finished SFP).
_key_assign_picking is also added if multiple moves are confirmed w/
and w/h created_production_id, we won't merge them in the same picking.
closesodoo/odoo#36335
Signed-off-by: Christophe Simonis <chs@odoo.com>
Enable work orders, routings, and track components by lot numbers or serial.
Create an MO for a certain X quantity of finished products and plan work orders.
Only complete a partial amount Y of the overall X amount.
Specify the lots for the consumed tracked materials equal to the Y amount.
Then, return to the MO and click "Post Inventory".
An error is raised because the lot is missing.
This is because when processing workorders temporary lines
are created without lot/serial for tracked component products.
This is a limitation that require a task to be removed;
in the meantime we remove the button, in true bugfix fashion.
opw 2049806
closesodoo/odoo#35731
Signed-off-by: Nans Lefebvre (len) <len@odoo.com>
usecase to reproduce:
- Set the warehouse with manufacturing 3 steps
- Create a BoM with a Components that use a Sub BoM
- Set Both product MTO + Manufacture
- Create a MO
You have only 2 picking for the first MO with the SFP
that contains both the finished product and the intermediate
component. However they are created and moved at two different times
since you could not create the finished product withtout the
component, so there is no meaning to put them both in the same picking.
It happens because the _assign_picking will merge moves with the same
procurement group. In our case, it's the wanted behavior to have the
2 differents SFP linked to the same MO. So the solution would be to
add a condition to _assign_picking and don't merge moves if they come
from different MO, at this point the field created_production_id would
fit. However this solution is not robust if a customer creates a
new rule that add a 4th steps to the production process.
opw-2055688
closesodoo/odoo#35915
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Co-authored-by: Andrea Grazioso (agr-odoo) <agr@odoo.com>
There was a first version of mrp_subcontracting at rev [1] and now
there's a second verion at rev [2]. As the second version sensibly
changed the flows and models AND we don't have the time to backport the
changes AND saas-12.3 will be released on the saas, we chose to remove
the module in saas-12.3 to not have to support both version once v13 is
released.
[1] d91db5bde6
[2] 9b6a5398dfclosesodoo/odoo#35898
Signed-off-by: Christophe Simonis <chs@odoo.com>
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
When we change quantity to produce in mrp, all component lines are
removed and new line with the updated amount to product are created.
The problem appears when we change the quantity to produce and directly
click on a component line, because we open the line that will be
deleted. So if we change the quantity for this component manually,
this suppressed line will be added with the new value. And the computed
line will be also be added. So the line for one component will be
present twice (one with computed value and one with manual entry value).
To avoid this problem, when we change the quantity to produce, we update
information of each line (instead of deleting and creating new one).
So if we click on a component line just after changing the quantity,
we open the updated line (and not de deleted one).
* account, hr_expense, mrp, sale, sale_product_configurator, stock_account,
website_sale, website_sale_comparison
Before this commit, the `product.attribute.value` were stored on the variants.
This required filtering of attribute lines to find the appropriate matching
`product.template.attribute.value` that were used in most of the business code,
such as when computing the `price_extra`.
This also prevented to have multiple attribute lines for the same attribute,
which is needed to handle use cases such as grape varieties for wine products.
This will be done in the following commit.
After this commit, the combination of `product.template.attribute.value` will be
directly stored on the product variant.
Other changes
=============
Add `combination_indices` on product, which allows to quickly find a variant
matching a combination (1 simple indexed equality query as opposed to 1 query
with as many joins as there are attribute lines), and to add an easy
SQL constraint to ensure active combination uniqueness.
Add active field on `product.template.attribute.line` and
`product.template.attribute.value`, with the same behavior as variants:
They become archived if they can't be unlinked. This allows to keep the database
consistent, such as archived variants correctly keeping all their values, sales
order lines keeping their custom and no_variant. This is done with the help of
`ondelete=restrict` on the corresponding m2m fields, and the `unlink` methods
falling back to archiving when `unlink` is restricted.
Part of task-1912579
PR: #32946
This commit avoid searching into quants and stock.moves, the quantities
(available, forecasted, ...), for service product in order to speedup the search
on big recordset
closesodoo/odoo#35920
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
The computation of kit quantities was not efficient. A loop on each product
of the recordset to consider performed. Each time a product was seen as 'not a kit',
a new computation on the complete recordset was done. This leads to a N^2 complexity
This commit only compute stock quantities for non kit product in one batch
Updating a datetime field in a form view will fill the 'values' dict
with a string.
This commit casts the dates in mrp.production and mrp.workorder that are given to
their respective stock move into actual datetime object. This prevent any
converting error later in the process
Task : 2055912
closesodoo/odoo#35825
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
How to reproduce:
- Install mrp & mrp_workorder;
- Open Manufacturing and plan a workorder;
- Go on the Work Centers Overview;
- Click on "WORK ORDERS" button -> You got a "Something went wrong !".
closesodoo/odoo#35900
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
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.
closesodoo/odoo#35659
Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
When a move is created from a location A to a location B and not
via a rule but it wants to apply the rule logic in order to know
if a move is MTS or MTO then _adjust_procure_method is called.
It will check if a rule between A and B for the selected product/
category/warehouse and if it exists it will apply the rule procure
method to the move. If not it will check if the route MTO is ticked,
and will set the move as MTO even if no rule exist. It could be
miss understanding by the user that have moves MTO without matching
rule. It would be easier to have a single proccess with rule.
Modify tree view for MRP Production
Modify form view and tree view for Unbuild orders
Add group by for Bill of Materials
By default show line shart when opening MRP Production report
Modify view for Work Orders
Modify view for Work Centers
Modify view for Routings
Modify view for Maintenance Request
Modify view for Bill of Materials
task-2042304
closes - https://github.com/odoo/odoo/pull/35482
Introduces by #0679d0d54269ffe0664845e8e0bd1238110fd514 when you plan a
workorder, the corresponding workcenter will reserve a leave to avoid to
plan an another workorder in the same time slot.
But before this commit, when you unplan your workorder, the leave wasn't
unlinked, so the time slot stay reserved.
Now when a workorder is unlinked, its leave is too.
closesodoo/odoo#35003
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
The purpose of this commit is to simplify the `mrp.production` model in
reducing the number of date field.
The following fields was kept:
- `date_planned_start`: the planned date for the beginning of the MO
- `date_planned_finished`: the planned date for the ending of the MO
- `date_start_wo`: the preferred date to start a Work Order in case
the MO will plan one.
- `date_deadline`: is only indicative and is automatically set when
the manufacturing order is needed for a sale order.
- `date_start` and `date_finished`: no changes.
Task #1935229
Co-authored-by: Whenrow <whe@odoo.com>
Selling a product you don't have in stock anymore triggers a message
without pertinent information about available quantity.
This commit adds a little widget on sale order line to inform the salesman
there are not enough quantity available. Clicking on it will reveal:
* The estimated delivery date
* The actual quantity on hand
* The quantity forcasted at the estimated delivery date
For kit product, the quantities are the maximum occurence of kit available
regarding components quantities.
Task 2003485
closesodoo/odoo#34336
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
The stock module adds 4 quantities on products:
Quantity on hand
Incoming quantity
Outgoing quantity
and Forecast Quantity
Forecast Quantity is equals to Quantity on hand + Incoming quantity -
Outgoing quantity. Those two last ones are computed from the open stock
moves wainting to be validated but the reservation is not taken into account.
This commit introduces a fifth quantity 'free_qty' that acts like the forecast
one but only with reserved quantities.
This attribute is misleading as it is insufficient to correctly upgrade
the database. It only renames the column in the database, but other
operations are needed, like updating the corresponding `ir.model.fields`
record (and its xmlid). The default values and the translations are also
lost during the upgrade.
Moreover, this feature was misused. It was:
- left on fields during multiple versions.
- used on reports (SQL views). This would be ok if the feature was
complete, but, as is, it was useless.
- kept unchanged after a second renaming of the field (which can happen
versions later the first rename).
- used, even when the meaning of the field changed. i.e. the field
`archived` has been renamed to the classic `active`, but the value
in the database should be switched.
Read_group only work on stored field. We still can't make these fields
stored related because of what's explained on the comment: the write
aren't batched and a constraint is raised. See rev 0679d0d542
task-2036914
closesodoo/odoo#35268
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
In some cases, when changing in the inventory setting from tracking lots and
serial numbers to not tracking, an issue could occur when trying to close the
MO with processed work orders and lots.
opw:2040752
closesodoo/odoo#35250
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>