About this commit 8e7c0e544a8d3d18c57634750ee7ea03052c84b1
We need to manually invalidate the cache (of the quant) if a error
(other than concurrent ones) is raise from the write. Because
we can't know what the `write` has already put in the cache (e.g.
`write_uid`), we need invalidate it.
opw-2371161
X-original-commit: 7d75745267dada371d421ec93d50fb10b0006457
For validate 5K stock move line with SN:
Without index: 200 sec of SQL execution
With index: 15 of SQL execution
opw-2374846
X-original-commit: 21d7afca292f4c213d1fcfb4a31e0b7157eb941c
Issue:
The `_update_available_quantity` will flush the all environment due to
the savepoint (at each call). When we working with the package,
it becomes bottleneck due to the `_compute_package_info`. Indeed,
it computes two compute store field (`location_id` and `company_id`) and
depends of multiple field of related quants `quants_ids.xxx`. It means
that each time we enter/exit in the savepoint to update quants, this
compute will be execute (because of flush + compute_store).
Solution:
Avoid flushing when enter in the savepoint of
`_update_available_quantity` (`flush=False`)
Performance gain:
To validate a Delivery with 1000 move lines with package (source and
dest):
- Without patch: +- 120 sec
- With patch: +- 17 sec
opw-2371161
closesodoo/odoo#62841
X-original-commit: b2d57323caf9f7fe47c4fe9ac26b0e955d9987b9
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Commit 49b965eb1ec6a7ec6c07fa643cc6ae35ee8b5d91 introduced
`product_tmpl_ids` into the context for displaying kit components but
did not use it in the domain due to a missing `s`.
This commit adds the missing `s` in the domain.
closesodoo/odoo#62870
X-original-commit: aa135eb966810311837f4d446962850bb5aec82d
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
The 'On Hand' button triggers action_open_quants on product model. It
do not explode the kit into its component
closesodoo/odoo#62390
X-original-commit: 49b965eb1ec6a7ec6c07fa643cc6ae35ee8b5d91
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit makes it so the quantity of a SN in a location is now
restricted between -1 < quantity < 1 (previously it was only quantity <
1). This change provides stronger protection against a duplicated SN
(e.g. a quantity of -2 means that the SN was somehow moved from that
location twice). This restriction was also relaxed to not include
location.usage='inventory' because this could prevent the user from
fixing a duplicated SN (since they were prevented from creating a
quantity of 2+ in an Inventory Loss location).
closesodoo/odoo#59834
Task: 2336455
Related: odoo/upgrade#1839
Related: odoo/enterprise#14667
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Add a new feature to allow automated (as part of scheduler) generation
of inventory adjustments based on user set value for how often they should
be done for 'internal' and 'transit' locations.
- When is the inventory created?
When cyclic frequency is set to a non-zero value, the next date an
inventory should be automatically generated for a location is based on
whether or not a previous inventory for that location was completed.
If an inventory is overdue based on the previous inventory date, one
will be scheduled for tomorrow. If no previous inventory date exists,
schedule the next one based on today's date. A new inventory will be
created by the scheduler if there is not an existing in progress
inventory for the location (to avoid a conflict).
- What about descendant locations?
Descendent locations will not have an inventory created if their
ancestor is supposed to have a cyclic inventory done at the same time.
Note this includes when that ancestory already has an in progress
inventory and isn't having a new one created.
- What about cleaning out of date cyclic inventories?
This automation will also delete existing draft inventories that include
this location (created before the day the scheduler is run) or any of
its descendants (i.e. inventories with only that descendant location
selected to avoid deleting obviously manually created inventories).
Task: 2336455
Upgrade PR: odoo/upgrade#1839
What are the steps to reproduce your issue ?
1. Install 'stock'
2. Create 'ProductA' with 'Tracking By Lots'
3. Create some 'Lots/Serial Numbers', for example 'CodeA0 and 'CodeA1'
4. Go to 'Reporting/Inventory Report'
5. Remove 'Product > Location' from the search bar.
6. Click 'Create' and select 'ProductA' with 'WH/Stock' Location
What is currently happening ?
When you set 'Lot/Serial Number', the available lots to choose
are not limited to the selected product only.
What are you expecting to happen ?
Show only lots of the selected product.
Why is this happening ?
The domain contained no condition which depended on the product.
How to fix the bug ?
Addition of a condition that depends on the product.
opw-238143
closesodoo/odoo#62046
X-original-commit: 3b33f1d3f5cb5182d5577176640bcf7427757ed2
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Previously, the field `package_use` was in `stock_barcode_picking_batch`
as this field is only used by the picking batchs in barcode.
But to avoid some overrides and so make the code simplier, it is now
declared in `stock`.
However, this field will not be visible in the package form view until
`stock_barcode_picking_batch` is installed.
closesodoo/odoo#59925
Related: odoo/upgrade#1855
Related: odoo/enterprise#14043
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
When using reusable package in chained transfers, indicates the package
should not be propagated for the next moves `result_package_id`.
This change has no effect by itself, but it's used in enterprise by
https://github.com/odoo/enterprise/pull/13146/commits/611b2c0b188ab9906eb21feab087a1794bd2d015 when Picking Batch is enabled
and barcode app is installed.
task-2333834
X-original-commit: 6677f501d5a1717af8da08a7e235d87aeb85f862
In inventory report, when groupby setted and no data, the create button
will open a new form instead of create a new line. Since now our form
view is not editable, no record can be created.
In this commit, add a new editable form view to solve it.
Task 2310494
PR #55910closesodoo/odoo#57344
X-original-commit: 4a4e60c65049082855414941642dadce8b413475
Related: odoo/enterprise#13067
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.
Add sudo for other operations on ir.actions.*
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)
closesodoo/odoo#55768
Related: odoo/enterprise#12360
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
At bee938e (following task-id 2042303), the label of the action was
changed globaly.
The action is however shared with multiple menus like Inventory Report.
The Update Quantity label only makes sense when coming from the
product where the quantity will be updated.
Closesodoo/odoo#50523
1. Create a new location of type internal in WH/Test
2. Create a new product P with availability of 100.0 in WH/Stock
3. Create a new transfer from WH/Stock to WH/Test with 50.0 units of P,
Put in Pack and Validate
4. Create a new transfer from WH/Test to WH/Stock/Shelf 1 using the
previous package, Validate and Unpack
5. Repeat steps from 3 and 4
6. Create a new transfer from WH/Stock/Shelf 1 to Customer with 100.0 units of P
7. Review stock quant from the location WH/Stock/Shelf 1
2 quants of the same product in the location WH/Stock/Shelf 1: one
negative with -50.0 and another positive with 50.0
The step 4 creates 2 quants of 50.0 units, which are reserved at step 6.
However, when validating the transfer 100.0 units are taken from one of
the quants.
To prevent this situation, we run the quant vacuum process after
unpacking. This will merge the 2 quants of 50.0 and prevent any future
negative quant creation. We also clean zero quants, although this is not
mandatory to fix our use case.
Closes#53535
opw-2283707
closesodoo/odoo#54431
X-original-commit: f7168311f4333f7fc684e00e1c1c284981718335
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Before this commit if you have a quant that has a location linked of the type 'view' you'd get this warning
but you would not know about which location this was and figuring that out is not trivial for most people.
After this commit users get notified about which location is of the type 'view' and can directly correct it if they want to.
closesodoo/odoo#51137
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
1) removal_date in inventory report should be readonly if
product tracking is none or use_expiration_date of product
is false.
2) removal_date should be editable in inventory mode.
Fixes-2273732
closesodoo/odoo#52827
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
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.
Before this commit, `self.env.user.company_id.id` may represents different company from the current company based on context.
In this commit, we use correct company based on contextual company.
Follow up on b39173a8ffclosesodoo/odoo#52328
X-original-commit: 2314ce8b3de80ff6c4c9dec35ea6a201f885ba16
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
"Edition" is a French-English false friend word. "Edition" in English
means "version" whereas "edition" in French means "editing". This commit
updates user facing strings/documents that incorrectly use "edition" instead
of "edit" or "editing". Attempts were made to clean up English around
"edition" usage so please excuse any errors from lack of context
knowledge. Code comments and names incorrectly using "edition" were NOT
updated.
Since trying to create a record in a grouped tree view has no effect
(previously that opens a new record in form view), this commit removes
useless dynamically added default group for the quant list view.
task-2217907
If you create a quant through the inventory mode of the list view and
you don't set a quantity, the quantity is null and the quant isn't
unlinked by _unlink_zero_quants.
Also consider null quantity as 0.
We don't have the issue for the reserved_quantity field since this one
is not nullable.
closesodoo/odoo#48005
X-original-commit: 08e428458aa545b3602c56b6866a447126cf8825
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
=======
PURPOSE
=======
Improve duplicated serial number message to show more information.
=======
SPEC
=======
In this commit, we show full information about all invalide product name
and lot/sn number when the user enters duplicated ones.
- Change the sql constraint for checking duplicate sn/lot to python
constraint to support customised error message.
- Create lot in batch to show all invalide ones in error message.
=======
LINKS
=======
task 2083605
pr #44366
Related: odoo/upgrade#954
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
- Go Inventory > Master Data > Products
- Group by Category
- Go to a product
- Click on 'Update Inventory'
An error is raised because the field `categ_id` doesn't exist on
`stock.quant`.
opw-2161129
closesodoo/odoo#42964
X-original-commit: 901d60cd90f1e6ba0fd6502c04619193d3ca1c7b
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
When accessing the quantities on hand of a product, `_get_quants_action`
is called to specify the action returned.
In some cases, the action context may be updated. This led to a
traceback because the context of the action isn't a copy of the current
context but a link to the current context frozendict, which cannot be
updated.
Instead of hardcoding a domain in the action, we add a field that will
be used to apply the domain. The goal is to be able to define a static
domain in the xml so we'll be able to default on the filter while still
being able to remove it.
Let's consider this usecase:
Physical
| \
WH Subcontracting
| |
Stock 5 units
|
10 units
With the hardcoded domain, we have two problems
- the right part of the tree isn't visible
- the user can add a quant in subcontracting but it will disappear at
the creation since it isn't part of the hardcoded domain.
The complicated part of the domain is the `_get_domain_locations` call.
It will use multiple context keys, the current company and get the
hierarchy of internal locations below warehouses to see what it should
include or not.
To be able to remove a domain, it should be declared in the xml and not
hardcoded in the action. Since the domain is complex, we can't express
it. So we add a computed field "on_hand" and its search method is
overiden to call `_get_domain_locations`.
task-2061825
closesodoo/odoo#40403
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
The default `compute_sudo=True` makes sense for recomputing stored
fields that are indirectly related to a business operation. This
ensures that the recomputation of the field does not break an operation
that is not aware of the fields to recompute.
However, computing non-stored fields in superuser mode is usually not
necessary. It even leads to unexpected values: counting a partner's
sales orders does not give the same result in superuser mode as in
normal mode. That is why non-stored fields are not computed in
superuser mode by default.
[FIX] account, delivery, event, hr_recruitment, point_of_sale, stock:
adapt the model definition to make all fields with the same compute
method have the same value for `compute_sudo`.
[FIX] sale: split the computation of `invoice_ids`, `invoice_count`
(non-stored) and `invoice_status` (stored), as no code is actually
shared.
closesodoo/odoo#39195
X-original-commit: 843fd38a97f02b49dc09d7f55919072d272fd80e
Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
Adds a domain on quant `lot_id` when user changes quantity on hand of a
specific product, so user can select lot only for this product (or its
product variants if user come from a product template).
closesodoo/odoo#36467
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
In case there is a lot of stock_moves and/or lot of
stock_quants, the function _get_qty_procurement
takes a lot of time because there is no index defined
on most accessed fields.
I.E. OPW-2027183
closesodoo/odoo#36113
Signed-off-by: Richard Mathot (rim) <rim@openerp.com>
Ensure proper domains are applied and enforced on relation fields thanks
to the `check_company` attributes.
product.template
- make responsible a property field in order to ensure proper next activities when a product
is used between multiple companies
stock.putaway.rule
- added a company_id field
stock.move.line
- company_id is not related anymore since a move line can exist without a move until its validation
stock.package_level
- added a company_id field
stock.picking.type
- company_id is now required
stock.production.lot
- added a company_id field, adapted the constraint accordingly
stock.quant
- check the consistency only in inventory mode
stock.quant.package
- company_id is now empty if the package is empty
stock.picking
- company_id is now related to the one of its picking type
Added some tests.
Moved stock_traceability in the `report` directory.
Removed useless /tests/tours/route.js.
task-1985992
Before this commit, if user tries to create a new record from a empty
grouped editable list in 'Inventory Report', he/she will get the form
view open which isn't editable.
To avoid that, we remove the group filter if there is no quant, so user
can create a new quant directly in the editable list.
Task #2056651closesodoo/odoo#36221
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
Co-authored-by: jip-odoo <jip@odoo.com>
- Before the change of `sudo` and `with_user` the code was non sense, it
was doing a `self.sudo(self._uid).check_access_rights('read')` which
was doing nothing.
But now with `with_user`, doing a `self.with_user(self._uid).check_access_rights('read')` breaks the
flag `superuser`.
Meaning that if the code was called using `sudo` it was bypassing the
ACL tests.
closesodoo/odoo#35896
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.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>
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.