Commit Graph
124 Commits
Author SHA1 Message Date
Nicolas Pierre d9f73a9ce6 [FIX] mrp: archive QC linked to archived operation
Instead of the delete icon next to the operations in a BoM, create a
button to archive the operation. Archiving an operation will also
archive the corresponding Quality Check.

closes odoo/odoo#77456

Task-id: 2619450
Community-pr: https://github.com/odoo/odoo/pull/76376
Enterprise-pr: https://github.com/odoo/enterprise/pull/20785
X-original-commit: 9761ef89ca0f12f2907d844451e56c4a833ee8ef
Related: odoo/enterprise#21291
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-09-30 13:32:01 +00:00
JF Aubert 1016bb25b5 [IMP] mrp: Improve MRP Planning features
Review Work Order pop up design:
- add mo reference and Components tab at first
Manufacturing Readiness:
- set 'When all components are available' as default

closes odoo/odoo#75675

Task: 2527408
Related: odoo/enterprise#20515
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-08-31 10:01:03 +00:00
Tiffany Chang (tic) fd52760266 [IMP] mrp(_account): include byproduct cost share in BoM/MO
For improved cost analysis, byproducts can now have a "cost share" (out
of 100%) indicated. This cost share will by multiplied by the total BoM
cost (i.e. components + operations costs) and reflected in the stock
valuation. The final product will also have the byproducts cost
subtracted from its final stock valuation. This is of course only
applies when costing methods are appropriate (i.e. non-standard price).

Additionally, we can now "Compute Price from BoM" for byproducts (via
its product form) and the BoMs that it is a byproduct of are now counted
towards its # BoMs smart button (we will now also see these BoMs when
clicking on the smart button). Of course when there is no cost share for
byproducts then clicking on "Compute Price for BoM" will not change the
a byproduct's cost and if there are multiple BoMs the prodcut is a
byproduct of, the calculation will only be based on the first BoM it
finds (i.e. same as current logic for manufactured products).

BoM Cost report has been updated to include byproducts with cost shares
(byproducts with cost share = 0 will not show up in report).
Additionally we update the report to display operations only costs now
that BoMs are allowed to have no components in them.

Part 1 of Task: 2440068
Upgrade PR: odoo/upgrade#2727
Related ENT PR: odoo/enterprise#20169

Part-of: odoo/odoo#74951
2021-08-26 11:34:35 +00:00
brsy-odoo 281e1a57b3 [IMP] mrp: MO/WO UI Improvements
Improve the UI for the MO and the WO with some new features, better readability and usability

- The forecast for the MO in draft makes the preparation of a MO easier. The behavior of `forecast_availability` depend of the state of the move
- The sum of expected duration and real duration in the MO, make the MO visually clearer
- The field Scheduled Date is rounding up to the next hour for less manipulation
- The automatic reference in a BOM if there is already a BOM for this product allows making less manipulation. I'm using this variable `number_of_bom_of_this_product` with the result of the query inside so I didn't need to do the query twice and the query doesn't take the current bom.
- A rounded value is better for the OEE in WO summary
- Have a tag for a workcenter can be a good idea to add more information to it. I'm using a random value for the color of the tag, we are doing it frequently to have a random color on multiple think.
- Knowing the final product of a WO is clearer
- To notify the user when creating a product with a reference that are already existing is a good idea.
- Change some color in the MO view for better readability
- And more minor tweak (like to align some part in the view)

--- Links ---
The PR: https://github.com/odoo/odoo/pull/74540
The PR on enterprise: https://github.com/odoo/enterprise/pull/20006
Task related: 2442895

closes odoo/odoo#74540

Related: odoo/enterprise#20006
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-08-25 07:50:36 +00:00
Rémy Voet (ryv) 7b7f65d504 [IMP] mrp: improve bom filter line by variant feature
On BoM, a component line can be filter out depending
of the product variant to manufacture
(with "Apply on Variant" field).

Extend this feature to operation and byproduct line.

task-2614126

closes odoo/odoo#74973

Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-08-16 07:20:03 +00:00
Aurélien (avd) 2e527b4cac [FIX] mrp: improve perf of explode
Batch the bom_search of bom_lines in mrp_bom.explode.
If we represent the bom hierarchy as a graph, essentially
switch from a depth-first to a breadth-first search, allowing
to batch search boms for each depth level, hence improving
the overall performance.

closes odoo/odoo#71137

X-original-commit: 44ae26e4477e1b76b3dbb0f1acd50e8553b14d71
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-05-21 10:46:46 +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
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
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
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
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) 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) 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) 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
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
Nicolas Martinelli 682650a57e [FIX] mrp: make _bom_find return type consistent
MAke sure the `_bom_find` meothd always return a `mrp.bom` recordset.

X-original-commit: adc6af4aeba7fb5ef43c30714d73e4b9401dc536
2020-11-09 10:01:36 +00:00
yhu-odoo c8d1042d33 [IMP] mrp: search bom by reference
When select a BOM in the field, now we only search by the finished
product name. In this commit, we will also match the reference of the
BOM.

Task 2326786
PR #57945

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-10-14 07:23:19 +00:00
Nicolas Galler 4c2a03aa8f [FIX] mrp: validate BOM lines with same product as BOM
Current behavior before PR:

It is possible to create a BOM that has a BOM line that reference the
same product as the BOM itself.  This is undesirable as when we create a
manufacturing order for this product we will have an error.

It is a regression bug that was introduced in commit
575353e251a0cce3bbff759edaeb56b5718beb11 between v12 and v13.

Behavior after PR is merged:

When saving a BOM it will validate that no product line references the
same product, or the same product variant, as the BOM itself.  Note that
it is allowed to have a BOM for a product variant that references
another variant of the same product.

opw-2347941

closes odoo/odoo#59633

X-original-commit: 917e4c67b4aa14ca71ec6cba4bc6d20a86459f42
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-10-09 12:05:27 +00:00
Victor Feyens fdb23e282b [IMP] *: wrong any() usage
Replace wrong usages of any(list|recordset), by any(generator)
to speed up computations, avoiding list creations and/or looping twice on a recordset
for nothing.

any([generator]) => any(generator)
any(filtered) => any(generator)

closes odoo/odoo#55768

Related: odoo/enterprise#12360
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2020-08-14 09:56:10 +00:00
William Henrotin a8a98a614c [FIX] mrp: bom with operation duplication
Duplicate a BoM with operations and some BoM line consume in specific
operation. The operations are well duplicated but the 'consume in
operation' field still point to the original BoM's operations.

This commit search for the operation to replace based on the name and
the workcenter_id.

Task : 2278147

X-original-commit: 4c6d445dfd561a236b1b171ccbcc2ff2b6236640
2020-07-03 11:22:15 +00:00
Martin Trigaux 80e97e98ce [IMP] *: use named placeholders in translated message
When more than one parameter is present in a message, it helps the
translation to use named placeholder. This way, the order can be
changed. It also helps the comprehension of the message.
2020-06-18 13:03:34 +02:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02: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
Simon Lejeune c660770ebd [REF] mrp: remove routing model
Set the operations directly on the Bill of Material.
Duplicate the demo data where a routing was shared.
Adapt the tests.

Remove the following feature:
    - set the same routing on parent and kit child bom
    - when planning, if the component of the kit have the same operation
      than a component of the parent bom, merge these operations

task-2241471
2020-06-15 16:59:40 +02:00
Andrea Grazioso (agr-odoo) 6e69a2bf0b [FIX] mrp: successfully retrieve empty computed field
1. Install MRP
2. Launch an Odoo shell on the database
3. Type the command
`print(env["mrp.bom.line"].browse(1).child_line_ids)`

Traceback will occur with exception
odoo.exceptions.CacheMiss: ('mrp.bom.line(1,).child_line_ids', None)

This occur due to the empty value that the computation of the field
yields, which is not saved in cache.
Fix by adding a default value.

opw-2226951

closes odoo/odoo#50950

X-original-commit: fc885499a3c75d8d564569ec4cea41a8a64f3164
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-08 15:50:43 +00:00
Nicolas Martinelli 6bc3b30371 [FIX] mrp: Sub BoM
- Create products P1 & P2
- Create a BOM for P1
  Operation O1
- Create a BOM for P2
  Use 1 unit of P1
  Operation O2
- Open the 'Structure & Cost' report for P2

The BOM of P1 is not taken into account in the report.

This happens because a 'Sub BoM' must have the same Operation than the
parent (or no operation set).

There is no real functional reason for this, so we remove the
limitation.

opw-2246370

closes odoo/odoo#50743

X-original-commit: 5d3e88aa919a69ad54076637e72b880552e2a0be
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-06 11:14:35 +00:00
William Henrotin 5569768ec2 [FIX] mrp: create a bom with positive quantity
Creation of production order from a bom with 0 quantity to produce will
fail. As there is already a constraint on the quantity to produce on MO,
this commit adds the same constraint on BoM.

closes odoo/odoo#48485

X-original-commit: 1330500885ae096372ab32fba4ffc9db252dd2d4
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-03-30 07:42:38 +00:00
Nicolas Martinelli 17e12603a2 [FIX] mrp: dynamic attribute
- In inventory app, create an attribute that is dynamic
- Create a product with a variant with the dynamic attribute
- Create a bom for the product with some specific component for that variant
- Open structure and cost

A crash occurs.

In this case, the object is a `product.template`, so a condition
product-specific shouldn't be checked.

The template is set at:

https://github.com/odoo/odoo/blob/3588487ab4ef867f7fb981a395deaf298eb4a4e4/addons/mrp/report/mrp_report_bom_structure.py#L107

opw-2198976

closes odoo/odoo#47769

X-original-commit: 3c476dee5d3a0cc0fde0f9c6620507a07929e4fc
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-17 09:24:01 +00:00
Arnold Moyaux 7466f2cae8 [FIX] mrp: allow to use variant in order to build another variant
Usecase for example A black T-shirt made  from a white T-shirt and
black color. This behavior was possible in 12.0 and 11.0 and was
removed by commit 77a8d92196

Close #40540

closes odoo/odoo#44084

X-original-commit: 575353e251a0cce3bbff759edaeb56b5718beb11
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-01-28 11:13:36 +00:00
William Henrotin dd76e2df97 [FIX] mrp: remove dynamic domain on production 2019-12-27 10:00:43 +00:00
William Henrotin 6b4f447de9 [FIX] mrp: consumption required 2019-11-22 12:39:52 +00:00
fw-bot abd9d1506e [FIX] mrp: error w/o traceback on create BoM
If a Bill of Material is created without code (eg. when created as a new
group from a kanban view grouped by BoM) we would get a traceback
instead of an error.

With this changeset, we get a "You cannot create a new Bill of Material
from here." error if it is being tried.

opw-2124162
fix #38904
closes #40289

closes odoo/odoo#40457

X-original-commit: 32c13cd7d1387c0ea81a9bb5968d18c2b8f32051
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2019-11-18 19:28:01 +00:00
Christophe Simonis d74b451805 [MERGE] forward port branch 13.0 up to f4105eb9c7 2019-10-09 02:08:17 +02:00
Arnold Moyaux 02dfe1e8e7 [FIX] mrp: mobile byproduct BoM form view
On Mobile the byproduct One2many only empty line.
It's due to default kanban view using the _rec_name
in order to display the byproduct name. On byproduct the
_rec_name is not defined nor the field name so the kanban
is empty.

closes odoo/odoo#37403

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2019-09-25 08:11:20 +00:00
Christophe Simonis 6c948c36bb [MERGE] forward port branch saas-12.5 up to 197474e5b9 2019-09-13 18:07:59 +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
Sébastien Theys 22a11a6f4d [REF] product, *: save product.template.attribute.value on variants
* 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
2019-08-26 13:01:13 +00:00
William Henrotin 2137e45bb5 [IMP] stock, mrp: do not compute quantities on service product
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

closes odoo/odoo#35920

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2019-08-21 12:22:53 +00:00
lbs-odoo 9a0fedfc65 [IMP] various: improve searchviews UX
Improve searchviews UX in all the modules

TaskID: 2029731

closes odoo/odoo#35700

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-08-16 13:35:21 +00:00
Christophe Simonis 886eca0131 [IMP] *: remove usage of oldname attribute
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.
2019-08-05 09:36:41 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Adrian Torres 9e71d57d11 [REM] *: remove calls to api.one and adapt code
Adapt all code that was using `api.one` to recordset-style method and
remove any and all calls to `api.one` in preparation for its removal.
2019-07-05 09:04:45 +00:00
Mitali Patel 9d710df076 [REF] *: use the new decimal precision syntax
Since previous commit moved decimal_precision module's feature into base,
use the new syntax for fields declaration
Remove the imports to the removed module
Remove the module from dependency in manifest

sed -i "s|digits=dp.get_precision('\([A-Z a-z]*\)')|digits='\1'|" **.py
sed -i "/from odoo.tools import decimal_precision as dp/d" **py
2019-07-03 11:16:24 +00:00
Christophe Simonis 9035fb8a2a [MERGE] forward port branch saas-12.4 up to 618ea1ab67 2019-06-18 10:24:25 +02:00
Hiral Bhavsar 3cd7ed07a2 [IMP] *: remove 'view_type' on window actions.
The old tree views don't really exist anymore, this odd pseudo-flag to
dispatch between "list" and "tree" tree views has no reason to remain.

Task 1937686

closes odoo/odoo#31243

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-17 11:34:17 +00:00
Christophe Simonis 25e3f27062 [MERGE] forward port branch saas-12.3 up to 48a9f5a633 2019-06-17 13:20:35 +02:00
Christophe Simonis 34a8754d4f [MERGE] forward port branch saas-12.2 up to 498b4b4350 2019-06-14 15:20:01 +02:00
Christophe Simonis 8853e6b594 [MERGE] forward port branch 12.0 up to 7ef4ba03c4 2019-06-11 15:20:13 +02:00
Florent de Labarre 808238212e [FIX] mrp: add persistent domain
Steps to reproduce the bug:

- Create a product template A with variant color: black and white.
- Create attribute : size : 16gb and 32 gb
- Create a bom with template A.
- Add a bom line L with product B
- Save the bom ,edit it and select an attribute value for L

Bug:

All attribute values of the database (color: white, color: black, size: 16 gb, size 32 gb)
were displayed.

opw:2006988

closes odoo/odoo#33949

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2019-06-06 12:03:19 +00:00