The 'Structure & Cost' report has been changed to 'Overview', changing
some of its functionnalities. The override previously done in
mrp_subcontracting must be adapted to match the changes done in the mrp
module.
Also, the report has been converted to OWL in the process, requiring
changes in the overriden files as well.
Finally, the now obsolete code only related to the old 'Structure &
Cost' report has been removed.
Task-2628323
Part-of: odoo/odoo#93194
Ease subcontractor stock tracking by using dedicated locations.
Simply declare location as a subcontracting one (rules are
automatically adapted) and set it on vendor.
closesodoo/odoo#88644
Task: 2720393
Related: odoo/upgrade#3755
Signed-off-by: Tiffany Chang <tic@odoo.com>
Previous fix: https://github.com/odoo/odoo/pull/84631 missed the case
when raw_move_ids have already done move_orig_ids (i.e. when 2/3 step
MOs or subcontracting w/ resupply contractor). This made it so when
MOs are backordered, these moves would not be reserved even though they
were in the original MO.
This issue was fixed during a refactoring (reserved amounts are now
distributed to backordered MOs), but this commit will add a test to
prevent the issue from returning in the future.
Part of Task: 2777571
Original PR fix (pre-refactoring): odoo/odoo#91460closesodoo/odoo#97383
X-original-commit: a825d9ed715b369128c876174ca6ebfac72adbe5
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Tiffany Chang <tic@odoo.com>
In the web client, in a real use case, it's not possible
to write on fields which are invisible,
as it's not possible to write on fields which are readonly.
This is a first step in the goal to change the behavior
of the `groups=` attribute in the back-end views,
to remove them for the view instead of making them invisible.
This is mainly to reduce the diff of the revision that will introduce
the mentioned above behavior change.
As nodes with `groups=` will be removed from the view
when the user doesn't have the group, it's no longer possible
to set a value on a field having a `groups=` the user doesn't have
in the `Form` test class, as the field will no longer be at all in the
view.
However, these unit tests shouldn't have been able to set values
on invisible fields in the first place.
This revision therefore aims to correct the unit tests setting value
on fields which were invisible because the user executing the
test was not part of the required group(s) for these fields
to be visible in the view.
closesodoo/odoo#94337
Related: odoo/enterprise#28936
Signed-off-by: Denis Ledoux (dle) <dle@odoo.com>
In module mail, invalidating 'message_ids' on a mail thread also
invalidates its inverse field 'res_id' on messages. If you haven't
flushed it before, your cache will be inconsistent, as shown by the test
/mail:TestMailgateway.test_message_process_bounce_records_channel.
In module purchase_stock, add depends on report.stock.quantity. This
ensures that when the model is queried after changes in other models,
the data on which the SQL view depends is flushed to the database before
querying that model's table.
closesodoo/odoo#66938
Related: odoo/enterprise#16722
Signed-off-by: Raphael Collet <rco@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
BoM Structure & Cost report has different errors:
- The product cost of a subcontractor included in a product doesn't
scale with the quantity of the product (Issue 1)
- The BoM cost of a product composed of a subcontractor doesn't include
the subcontractor price (Issue 2)
- The BoM cost of a component composed of a subcontractor doesn't scale
with the quantity for the subcontractor price (Issue 3)
Steps to reproduce:
1. Install mrp_subcontracting_purchase
2. Create a product 'TEST 1', in the Purchase tab specify 'Azure
Interior' as vendor with price 5$
3. Create a bill of material for the product 'TEST 1' with BoM type
'subcontracting', subcontractor 'Azure Interior' and product 'Bolt' as
component
4. Create another product 'TEST 2', in the Purchase tab specify 'Azure
Interior' as vendor with price 8$
5. Create a bill of material for the product 'TEST 2' with BoM type
'subcontracting', subcontractor 'Azure Interior' and product 'TEST 1'
as component
6. Go to the BoM Structure and Cost of product 'TEST 1'
7. The product BoM Cost doesn't include the subcontractor price (it
should be the sum of its components) (Issue 1)
8. Increase the quantity of the product by 1
9. The subcontractor's product cost doesn't change (it should increase
with the quantity) (Issue 2)
10. Go to the BoM Structure and Cost of product 'TEST 2'
11. Increase the quantity of the product by 1
12. The BoM Cost of component 'TEST 1' only counts the subcontractor
price once (it should be the sum of its components) (Issue 3)
Solution:
Scale the subcontractor product cost with the quantity, update the
BoM cost of a product with the subcontractor price (in `_get_bom`) and
scale the subcontractor price with the quantity (in `_get_price`)
opw-2844482
closesodoo/odoo#92095
X-original-commit: 4f3347c6925e10ec62a85bb01d7cdb65b1e13b15
Signed-off-by: Adrien Widart <awt@odoo.com>
Signed-off-by: Guillaume Merlin (megu) <megu@odoo.com>
Adapt db775ffd308638a390be52eba3ca11c9c2d1602d to subcontracting flow,
to avoid performance issues when receiving a large amount of SNs
closesodoo/odoo#85603
Task: 2777451
Signed-off-by: Arnold Moyaux <arm@odoo.com>
This task will:
- Clean the code (e.g. the production's moves are now created directly)
- Have the same behavior when creating object in the UI or directly in
backend
It's mainly on the `mrp.production` object and most of the computed
stored field are used as default value or act like an onchange on draft
production. Once the production order is validated, it's only modify
by direct write
Task-2709753
closesodoo/odoo#83576
Related: odoo/enterprise#24405
Signed-off-by: Arnold Moyaux <arm@odoo.com>
In case of a MRP subcontracting, it is not possible to process the
delivery with several backorders.
To reproduce the issue:
1. Create two products P_compo, P_finished
- Both storable
- P_compo must have the route "Resupply Subcontractor on Order"
2. Update P_compo's quantity: 5
3. Create a BoM:
- Product: P_finished
- BoM type: Subcontracting
- Subcontractors: a partner P
- Components: 1 x P_compo
4. In Inventory, create a planned transfer T:
- Operation Type: Receipt
- Receive From: P
- Operations: 5 x P_finished
5. Mark as Todo
6. Inventory > Resupply Subcontractor, find the delivery of P_compo for
P and process it
7. Back to T, set the done quantity to 1.25
8. Validate T (with backorder)
9. On the backorder BO1, set the done quantity to 1.0
10. Validate BO1 (with backorder)
11. Open the second backorder BO2 and validate it
Error: a Validation Error is displayed "You can not enter negative
quantities.", which doesn't make sense
The issue comes from the inner method `_get_available_move_lines` in
`_action_assign`. When validating a picking, at some point, we are here,
at the beginning of `/mrp_subcontracting._action_done`:
https://github.com/odoo/odoo/blob/6d6b2c41adfa842c82252373b3dbd1ed0a5ebc92/addons/mrp_subcontracting/models/stock_picking.py#L36-L37
To understand what happens next, we need to note that, in this method,
the associated MO will be marked as done later (on line 76). Back to the
current line (L37), we are calling `super` which leads to the
problematic `_get_available_move_lines`. Suppose we are on step 10 (we
are validating the first backorder), we have
https://github.com/odoo/odoo/blob/58a9f57c0827a51e46ef0f52a3d48ba343667fe0/addons/stock/models/stock_move.py#L1390-L1391
`move_orig_ids` contains two stock moves, each one associated to one MO.
However, as said above, the second MO is not yet marked as done, this
will be done later on in `/mrp_subcontracting._action_done`. Therefore,
`move_lines_in` is only defined with the first SM, from the first MO,
with a quantity of `1.25`
Further in `_get_available_move_lines`, we have:
https://github.com/odoo/odoo/blob/58a9f57c0827a51e46ef0f52a3d48ba343667fe0/addons/stock/models/stock_move.py#L1403-L1405
`move.move_orig_ids.mapped('move_dest_ids') - move` gives two SM, and
here is the issue: the second one is already processed, so both are kept
in `move_lines_out_done` and the sum of their quantity is equal to
`1.25 + 1 = 2.25`
Therefore, at the end of the method, when computing the difference, it
gives a negative difference. This negative value will be used to create
a SML and later on, it will trigger the validation error.
Once the above issue is fixed, there is another "invisible" issue that
need to be fixed: when generating several backorders on the deliveries,
only the first one will trigger the creation of a new MO. Suppose we are
back in `/mrp_subcontracting._action_done` (still on step 10 in the
above case), in the first for-loop:
https://github.com/odoo/odoo/blob/6d6b2c41adfa842c82252373b3dbd1ed0a5ebc92/addons/mrp_subcontracting/models/stock_picking.py#L39-L43
`move._get_subcontract_production()` returns the two MO (from the
initial picking and from the first backorder). However, since the first
one has already been processed, the if-condition is validated.
Therefore, this for-loop is done and the second MO is not processed (the
quantities are not recorded and its field
`subcontracting_has_been_recorded` is not defined to `True`). As a
result, still in `/mrp_subcontracting._action_done`, we are now in the
second for-loop:
https://github.com/odoo/odoo/blob/6d6b2c41adfa842c82252373b3dbd1ed0a5ebc92/addons/mrp_subcontracting/models/stock_picking.py#L71-L72
`_subcontracting_filter_to_done` removes the two MOs because the first
one is done and the second one has not its field
`subcontracting_has_been_recorded` set to `True`. The condition in the
first for-loop is not accurate enough.
OPW-2731658
closesodoo/odoo#83658
X-original-commit: 1b740ae148acfc832b124122763817b08ea110ab
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
There is 2 major issues with the production of multiple serials number
- Performance issue
- Duplicated code with classic backorder mechanism
The performance issues exist since backorders were create one by one
and `stock.move` and `stock.move.line` are always recomputed. They
are not created in batch neither.
_generate_backorders is removed and replace by _split_productions. The
functionality are the same. Technicaly it does the maximum in batch,
first it creates all the `mrp.production` then all the `stock.move`
and finaly, it splits the existing `stock.move.line` among the new
`stock.move`
It means that the reservation is not recompute anymore during a
backorder process and will remain the same than the splitted production
order.
Performance metrics (10 components):
| 2 | 10 100 1000
before | 0.47s | 2.84s | 32.25s | 580.53s
-----------------------------------------------
after | 0.13s | 0.36s | 2.60s | 35.17s
task 2633369
Part-of: odoo/odoo#77254
The stock convention on location name is always to name the destination
`location_dest_id`. It was not the
case on the stock rule model
Task: 2648449
Part-of: odoo/odoo#80434
When validating a receipt, if the product is subcontracted and if the
picking is not fully done, it will be impossible to create a backorder
To reproduce the issue:
1. Create two products P_compo, P_finished
- Both storable
- Both tracked by lot
- P_compo must have the route "Resupply Subcontractor on Order"
2. Update P_compo's quantity: 4
3. Create a BoM:
- Product: P_finished
- BoM type: Subcontracting
- Subcontractors: a partner P
- Components: 1 x P_compo
4. In Inventory, create a planned transfer T:
- Operation Type: Receipt
- Receive From: P
- Operations: 4 x P_finished
5. Mark as Todo
6. Inventory > Delivery Orders, find the delivery of P_compo for P and
process it
7. Back to T, Record Components:
- Quantity: 3/4
- Set a Lot for P_finished
8. Validate T, Create Backorder
Error: a User Error is raised "You need to supply a Lot/Serial Number
for product: - P_finished"
Since P_finished is subcontracted, a related MO has been generated. On
step 7, when recording the used components, since all P_finished have
not been produced, a second MO is created for the last P_finished.
However, when validating T, both MOs are selected and validated. This is
an error since the user has not yet recorded the used components for the
last MO. The latter should not be validated.
OPW-2582538
closesodoo/odoo#78496
X-original-commit: 21068076b4a6b134f5f07c4c03de7c4eb37b4688
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
In a lot of test class, we use `setUp` instead of
`setUpClass`. `setUp` is execute for each test method and `setUpClass`
will be execute only once by Class (and use savepoint + rollback).
Then change setUp into setUpClass reduce the time to make all tests
and avoid to repeat this error for the future.
closesodoo/odoo#78082
Related: odoo/enterprise#21563
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Take in account the bom consumption of subcontracting BoM:
- In flexible and warning we can now record extra component
(even if there isn't tracked component).
- In the warning case, we get a warning issue in during the recording
of component if we consume more than expected
- In case of script consumption, we cannot record component expected
if some are tracked. In this case we can consume more than expected
only if the user is a mrp manager.
Also fix "Set quantities" Button for the subcontracting
task-2486811
closesodoo/odoo#75041
Related: odoo/enterprise#20350
Related: odoo/upgrade#2750
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
- The "BoM Structure & Cost" takes now in account
the subcontracting cost.
The subcontracting cost depends of the best supplier info in product
and subcontractor register in the BoM.
- Also add this subcontracting cost (to the cost field) when we click on
"Compute Price from BoM" in the product view.
task-2486811
Part-of: odoo/odoo#75041
Add a operation type (`stock.picking.type`) for
the subcontracting resupply in order to distinct
easily the a simple delivery and a resupply to a subcontractor.
task-2486811
Part-of: odoo/odoo#75041
In subcontracting, there wasn't a way to make
the subcontracting resupply delivery plan before
the subcontracting receipt.
Now the hidden subcontracted MO, take in account
(in his planning) the `produce_delay` (in days) of
the product which is automatically plan the
subcontracting resupply delivery correctly.
task-2486811
closesodoo/odoo#75072
X-original-commit: 829369d3ca0530f1aad0599fbb1598810a928cc3
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
Before this commit, for a subcontracted product with reserved available
tracked components, if at least one component is recorded but not all,
the "Record components" button isn't available anymore.
How to reproduce:
- Create a product and create a subcontracting BOM for this product;
- Add a tracked component for this product;
- Add some qty. for the tracked component in the subcontracting loc.;
- Create a receipt for the subcontracted product (for demand qty. more
than 1) with the subcontractor as partner and confirm it:
=> The "Record components" button should be visible.
- Record a part of the demand qty. then click on "Continue", then on
"Discard":
=> The "Record components" button is now hidden.
It's because the button is hidden if all the MO are done or to close
(they are) and if all the tracked move lines have a SN/LN (they have as
they are reserved).
task-2604728
closesodoo/odoo#73991
X-original-commit: 392bc27c0ef0bc238a7eac98497b293622f0fe1d
Related: odoo/enterprise#19756
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Step to reproduce:
- Create a subcontracting BoM by partner A,
for a tracked product B (by serial or lots)
- Create a incoming transfer coming from A and mark as todo.
- Fill the move with move lines with lot + quantity.
- It is impossible to validate the transfer, "You need to supply lot..."
Also at the creation of the picking a warning popover indicate that
the previous operation (the hidden MO) is set after the transfer.
These issues comes from the refactor of mrp for v14 and the part of
subcontracting wasn't complete obviously.
Fixes done:
- Rewrite the code of the `_action_done` for subcontracting. It is for
the case of tracked finished product without any tracked component,
there wasn't any code to manage that. Now manage it by backorder MO
feature. Fix the main bug
- Set finished_date_planned before the transfer to avoid the alert
popover.
- Avoid to write activity in channel about the hidden MO in case of
cancelling.
- Fix `action_record_components` to manage multiple subcontracting
products with tracked component.
- Remove the `priority` field from the wizard MO (in case of tracked
product. Also the wizard is not really a wizard, just a weird hybrid
MO form)
PR: odoo/odoo#61606
task-2357115
closesodoo/odoo#62109
X-original-commit: 1a34e46eaca14aec981dd0f162e8014c7cb0abea
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
This commit does 3 things:
1. When 'action_confirm' is triggered in a manufacturing order, any
'move_raw_ids' (components) that are unable to be fully reserved
when `action_assign` is triggered will be checked for an automatic
reordering rule (RR). If a rule exists it will be auto-triggered.
This includes subcontractor manufacturing orders. Relevant test
updated to match this.
2. When a MO is completed, auto check if there are corresponding
confirmed stock moves that can be populated by the completed products
and trigger their 'action_assign' to reserve the completed products.
3. If a new move line is added to an already confirmed MO, then do same
auto-RR check/trigger. (note will occur for pickings without extra
code since `stock_picking.action_confirm` is triggered again in this
case.)
This reuses similar logic as odoo/odoo#52433 from task 2244230.
Originally this was done in the `action_assign`, but has been moved to
`action_confirm` so as to imitate the now archived MTO process with RR.
Overlapping logic has been moved into stock_move for easier reusability.
Note that this now means editing existing moves' `product_uom_qty` (i.e.
Demand) will not have a flow to auto-trigger their RR.
Subcontracting test updated to match + new mrp test added for this new
feature.
closesodoo/odoo#57334
Task: 2322496
X-original-commit: 2688cd1bae489b1dec8862f4de727ac20514844c
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Improve onboarding by removing the replenish on order route.
Companies that do MTO process could unarchive the route in
order to have a basic configuration.
closesodoo/odoo#55147
Task: 2245882
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
After the odoo/odoo#52949 , the registering of tracked component,
in case of subcontracting, was broken. Fix and try to mimic
the same flow than before. The produce wizard has been replaced
by a clean MO form to register component and use backorder mechanisme
of MO to manage tracked finished product + tracked component.
task-2278147
closesodoo/odoo#54994
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
New report to easily order missing products in each warehouse.
Orderpoint have a new type: 'manual'. Manual orderpoint are not
trigger by the scheduler but the user could create replenishment
from the report directly. The report use the forecast report in
order to detect missing quantity for today (it does not search
depending the lead time for each product warehouse due to lake
of performance). It compares missing quantity with incoming RFQ
and other ongoing orderpoint. If it still missing a new entry
for replenihsment is created (it's also automaticaly deleted if
the replenihsment has been done another way).
Task: 2161378
**Steps to reproduce:**
* Create a subcontractor.
* Create a BoM of type Subcontracting and assign the subcontractor.
* Create a children contact for the subcontractor.
* Creat a purchase order (or a receipt picking) with the children contact of the subcontractor.
* Confirm the document.
**Current behavior:**
Subcontractor documents are not created.
**Expected result:**
They should be created.
**Cause:**
The BoM search is not including possible parents of the partners.
**Solution:**
With the use of `parent_of` operator in the search, we cover both cases of the children
and the parent as initiators of the subcontracting.
closesodoo/odoo#46670
X-original-commit: 86726aba26f4ba8d7dadb29ed2415baf49fe54c0
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
When subcontracting a product via a purchase order and not a simple
receipt. Then the cancelation of the receipt will not only cancel
the receipt of the finished product but not the delivery for the
components.
It happens because button_cancel on purchase order will call
_action_cancel the stock.move linked to purchase order line. It will
not call action_cancel on the stock.picking. However the part
responsible for the cancelation of components delivery is in the
stock.picking action_cancel method.
Move the stock.picking action_cancel logic in the stock.move
_action_cancel method since it's always call for both usecase.
Fixes#42551closesodoo/odoo#42653
X-original-commit: 841305f271411c3a67af271ac09da9ce0922f100
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
followup of rev [0]
If these wizards are called on multiple pickings, display the list of
the pickings that could be impacted and allow to select which one should
be impacted.
We also adapt the sanity checks at the start of `button_validte` in
order to specify the concerned pickings if needed. We do not enable the
multi behavior for batch at the moment, so it's only enabled for the
validate multi in the list view.
[0] 6ab4b0d496
task-2069646
closesodoo/odoo#41497
X-original-commit: ff276c6484b138982f185ec9c832f2dbf25baaef
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
`action_done`on pickings should be a private method,
and called only trough the picking validation process.
task-1938108
closesodoo/odoo#39174
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
Before this commit a returns would select the classic
partner location. However in the case of a subcontractor return
it should be returned to the subcontract location
Force to set subcontractors on subcontracting BoM since
it's always used in order to determine if a subcontracting
should be apply on a receipt or not. Also there is not magical
behavior has 'if there is no subcontractor on the BoM then it
means all partners...'
- nothing tracked
The "register components" button shouldn't appear, the receipt looks normal.
- finished products tracked
The "register components" button shouldn't appear, the receipt looks normal.
- finished products not tracked and components tracked
The "register components" button appear and the burger redirects to "Produce" wizard. The user should record all the productions before being able to access SML through the burger wizard. He cannot force any SML for subcontracted products with tracked components before having recorded all the productions.
- finished products and components tracked
The "register components" button appear and the burger redirects to "Produce" wizard. The user should record all the productions before being able to access SML through the burger wizard. He cannot force any SML for subcontracted products with tracked components before having recorded all the productions.
Test the flow when a product is set as resupply on subcontract
and not MTO, it should be trigger by a reordering rule and not
by a subcontracting receipt.
Add a test for the following usecase:
- Subcontracted product and components tracked by lot.
- Create a receipt
- Use the register components button in order to prefill quantity
- Correct the final lot on details operation form
If the components have the route resupply subcontractor on order then the
delivery order triggered by the receipt do not have the origin nor the
subcontractor partner. This commit update the procurement group in
order to add those information and propagate it.
due to commit 108ee65af2a88d61526dc047043138bddc3f9b63#diff-99ad190cf09687f6efdebc1f7636062c
picking type for subcontracting order use field use_create_components_lots
instead of classic picking type.
Replace the type subcontractor on the partner.
Instead replace it by a property for a subcontracting location.
The purpose is to have a simplier configuration. The user would
just need to add the partner on the BoM in order to start a
subcontracting process.