Skip to content
Snippets Groups Projects
  1. Jun 23, 2023
  2. Jun 20, 2023
  3. Jun 18, 2023
  4. Jun 15, 2023
  5. Jun 12, 2023
    • Eteil Djoumatchoua(etdj)'s avatar
      [FIX] stock: Enable the creation of a transfer from a duplicated operation type · 52219871
      Eteil Djoumatchoua(etdj) authored
      
      Steps:
      1- Duplicate inventory operation - Delivery Order
      2- Process new order with duplicate
      3- Add products and try to save
      
      Issue:
      Traceback
      
      Cause:
      The ORM tries to insert a new record of stock.picking but triggers a constraint on unique(name, company_id). When creating a new transfer the name is computed from the sequence of the stock.picking.type but here when we duplicate a stock.picking.type it creates a new sequence which starts with id 1, if the there is already a transfer with uses it the constraints will be triggered. We just have to make the stock.picking.type which are duplicated use the same sequence
      
      Solution:
      Enable the copy of the sequence_id so that two ``stock.picking`` from duplicated operation types will never collide on their name.
      
      opw-3331835
      
      closes odoo/odoo#122838
      
      Signed-off-by: default avatarAdrien Widart (awt) <awt@odoo.com>
      52219871
  6. Jun 11, 2023
  7. Jun 09, 2023
    • smna-odoo's avatar
      [FIX] stock: add SM without scheduled date · 48914c3e
      smna-odoo authored
      If a user adds a new SM to a picking without any scheduled date,
      traceback will appear
      
      To reproduce the issue:
      1.  create a new picking and remove the scheduled_date.
      2.  try to add a new storable product in move lines.
      
      Error: A traceback appears: "TypeError: '>' not supported between
      instances of 'datetime.datetime' and 'bool'"
      
      On the picking form, the default SM date is the scheduled date of the
      picking:
      https://github.com/odoo/odoo/blob/2c3f53d5a0380e7de27977f56f20307ff2bccabf/addons/stock/views/stock_picking_views.xml#L358
      
      
      Therefore, in the above use case, when triggering the onchange/compute
      methods, the field `date` of the SM will not be defined. At some
      point, we need to get the forecasted quantities of the SM product
      (see the method updated by this commit) and, to do so, we compare
      the SM date with `now`. Since this date is `False`, it will lead to the
      above traceback
      
      sentry-3979281197
      
      closes odoo/odoo#124274
      
      X-original-commit: e6179a51
      Signed-off-by: default avatarAdrien Widart (awt) <awt@odoo.com>
      48914c3e
  8. Jun 07, 2023
    • Ahmed Khalaf's avatar
      [FIX] stock{_dropshipping}: dropship tracked product · 7adc661b
      Ahmed Khalaf authored
      
      To reproduce:
      
      1- Activate dropshipping from settings
      2- Create lot tracked product and enable dropship route
      3- Add a vendor in product purchase tab
      4- Create a SO with the product and confirm
      5- Go to generated PO and confirm
      6- Go to generated dropship transfer linked to SO /PO
      7- Enter a lot name for the product move line validate
      8- Go to 'Inventory>Products>Lots/Serial Numbers'
      9- Expand the dropshipped product, find the serial number used in dropship
      10- Show the 'Transfer To' field if not visible, you will find it empty
      
      Expected:
      The 'Transfer To' field should have the last partner the serial was delivered to
      in this case the customer in the SO
      
      This commit fixes the issue and adds a test (also imporves the test class)
      
      opw-3225342
      
      closes odoo/odoo#123242
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      7adc661b
    • Laurent Mignon's avatar
      [IMP] stock: Improves stock_quand_package.unpack performance · c261eb38
      Laurent Mignon authored
      
      Before this change, when a package was unpacked the SQL query into the  method was looking up all the records into the stock_quant table to find duplicate entries. This could lead to severe performance issue on large database. With this change, if the  method is called on a recordset, the SQL query will only try to find duplicate records for records with the same product's ids and location's ids than those in the recordset.
      
      closes odoo/odoo#121839
      
      Signed-off-by: default avatarTiffany Chang <tic@odoo.com>
      c261eb38
  9. Jun 06, 2023
    • althaf shaik's avatar
      [FIX] stock: return empty recordset if no rule found · 1f881ab5
      althaf shaik authored
      
      When _get_rule does not find any rule, it returns False. This
      could create some tracebacks as we mostly expect a stock.rule.
      
      It will give:
      if False in <recordset>:
      Hence a traceback:
      TypeError: unsupported operand types in: False in stock.rule()
      
      By applying these changes will resolve this issue.
      
      Sentry-4206998573
      
      closes odoo/odoo#123151
      
      X-original-commit: d6a0b981
      Signed-off-by: default avatarAdrien Widart (awt) <awt@odoo.com>
      1f881ab5
    • snd's avatar
      [FIX] stock: dont reassign package when removed in 3-steps delivery · c742f2b1
      snd authored
      
      In a 3-steps delivery with backorders, when removing the package in the 2nd step, it should be absent from the last step (OUT picking).
      However, assigning a package on the backorder of the 1st picking and creating a new backorder reassigns the package to the OUT picking.
      Settings: 3-steps delivery, packaging
      Steps:
      - create a SO of product A for 10 units
      - on PICK_1 picking: put 2 units in Done and put in a package, validate, create a backorder
      - on PACK_1 picking: remove the destination package for the 2 units, validate, create a backorder
      - on OUT picking: the stock.move.line does not have a package
      - on PICK_2 picking: put 2 units in Done and put in a package, validate, create a backorder
      - on PACK_1 picking: the package was reassigned to the destination package
      - on OUT picking: the stock.move.line has the original package that was removed before
      
      This fix ensures that a package can't be assigned on 'done' stock.move.line
      
      closes odoo/odoo#123575
      
      X-original-commit: 863dc77f3034328ee0e85848e7e673b2de0211c9
      Signed-off-by: default avatarDiez Stéphane (snd) <snd@odoo.com>
      c742f2b1
  10. Jun 04, 2023
  11. Jun 02, 2023
    • clesgow's avatar
      [FIX] stock: remove incoming warehouse address from delivery slip · 14490824
      clesgow authored
      
      Steps to reproduce:
      - Configuration -> Settings -> Activate multi-locations.
      - Configuration -> Warehouses -> Three-step delivery.
      - Generate a three-step delivery (like through a sale order).
      - Select either PICK or PACK pickings.
      - Print the delivery slip.
      - There is a "warehouse address" field with the customer's adress in it.
      
      It makes little sense to display the current warehouse for internal
      transfers, as they keep being in the same warehouse after all.
      This doesn't impact inter-warehouse transit as in this case, an outgoing
      picking is done from one warehouse to the transit location and an
      incoming picking is done from the transit location to the other
      warehouse.
      In both cases the addresses are correctly displayed and didn't use this
      'warehouse address'.
      
      opw-3335185
      
      closes odoo/odoo#123509
      
      X-original-commit: 2ff0056d
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      14490824
  12. Jun 01, 2023
    • Mathias Mathy (MAMA)'s avatar
      [FIX] stock,mrp: Wrong forecasting on widget · 0d4b95e9
      Mathias Mathy (MAMA) authored
      
      **Summary :**
      When using a great decimal precision, forecast_widget shows red
      neverthless the available quantity is sufficient.
      
      **Steps to reproduce :**
       - In Settings >> Technical >> Database Structure >> Decimal Accuracy
          - For usage __Product Unit of Measure__, set __Digits__ to **__6__**
       - Create products of type storable :
          - __Test Component__ with a __Qty on hand__ of **__76.6__** Units
          - __Test Product__
       - Create a BoM for __Test Product__, with Quantity set to **__1__** Units
          - Add component __Test Component__ with Quantity set to **__15.32__** Units
       - Create a MO for BoM __Test Product__ with a Quantity set to **__5__** Units
          - Confirm the MO.
      
      **Before :**
      Neverthless the __To Consume__ qty is set to 76.6, which is equal to the
      __Qty on hand__ of the component, the forecast widget shows red as if
      there's an insufficient quantity of the component
      
      **After :**
      With help of the Odoo's __formatFloat__ method, we round the data used
      in the comparison defining the __willBeFulfilled__.
      The forecast_widget now display properly, taking into account the digit
      precision setup in the database.
      
      opw-3281588
      
      closes odoo/odoo#123074
      
      Signed-off-by: default avatarTiffany Chang <tic@odoo.com>
      0d4b95e9
    • Aurelien van Delft (avd)'s avatar
      [FIX] stock: enable index/bitmap scan in report_stock_quantity · 5a188992
      Aurelien van Delft (avd) authored
      
      The report_stock_quantity model defines a view in its init method
      to compute quantity information related to stock. This view
      is made of two CTEs and a three-part query separated by UNION ALL.
      The first CTE, existing_sm, retrieves the stock_move data
      from the database that are later used by the remaining of the query.
      
      One of the where conditions of existing_sm is (m.state != 'done' or
      m.date >= ((now() at time zone 'utc')::date - interval '3month')).
      m.state != 'done' is translated to m.state <> 'done' by the query planner.
      This type of operator has the side-effect of turning off index scan.
      Therefore, the scanning of the existing_sm CTE performs a Seq Scan
      and applies the where conditions in a Filter node. This can be quite
      ineffecient if the stock_move table is big, and if the selectivity
      of the m.state != 'done' condition is high enough to theoretically
      justify an IndexScan.
      
      To fix that, we take the inverse of m.state != 'done', i.e. an IN cond.
      This allows postgres to use Bitmap Scan, which
      is usually better under these specific conditions.
      
      E.g. speedup: db with 7M stock_moves, select from report_stock_quantity
      with conds for state, date, product_id, warehouse_id, company_id
      4.5s -> 2.5s
      
      opw-3288364
      
      closes odoo/odoo#122911
      
      X-original-commit: aad458e5
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      Signed-off-by: default avatarVan Delft Aurélien (avd) <avd@odoo.com>
      5a188992
    • Ahmed Khalaf's avatar
      [FIX] stock: delivery address in picking reports · 5802295f
      Ahmed Khalaf authored
      
      Before this commit, when printing a The picking operation or delivery slip
      reports for outgoing transfers, both the delivery and customer address are displayed
      showing the same address.
      
      The expected behavior is to have customer address only of there is a commercial
      partner behind the delivery address, thus the customer address is hidden
      if its not the case.
      
      opw-3289441
      
      closes odoo/odoo#123177
      
      X-original-commit: ca59d082
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      Signed-off-by: default avatarAhmed Khalaf (ahkh) <ahkh@odoo.com>
      5802295f
  13. May 31, 2023
  14. May 30, 2023
    • Adrien Widart (awt)'s avatar
      [FIX] stock: clean quants after moving package · 79232a4c
      Adrien Widart (awt) authored
      When moving a package, the quant at source location is not
      automatically removed
      
      To reproduce the issue:
      1. In Settings, enable
         - Packages
         - Storage Locations
      2. Create a storable product P
      3. Update the on hand quantity
         - 1 x P at WH/Stock in package PK
      4. Create a planned delivery D with 1 x P
      5. Confirm and reserve D
         - PK should be reserved
      6. Validate
      7. Open the package
         - Its location is "Partner Locations/Customers", which make sense
      8. Inventory > Configuration > ... > Locations, open WH/Stock
      9. Current Stock
      
      Error: There is a line with PK. The quantity is 0 but still, it
      create some confusion for the user who could believe that the package
      is still in WH/Stock
      
      This issue does not occur if the user goes through the product form
      and click on the on hand quantity. The "incorrect" quant will not be
      there. This is because, when loading the action, we call
      `_quant_tasks`:
      https://github.com/odoo/odoo/blob/05a7f5c04804423cfc3a833a1b3f0b5eec3fc147/addons/stock/models/stock_quant.py#L296-L300
      This method will clean the quants (merge & unlink)
      
      However, in the above case (step 9), the action is defined on XML side:
      https://github.com/odoo/odoo/blob/7d4dfeb0e26b387dee312897264a68963f90267f/addons/stock/views/stock_location_views.xml#L24-L26
      https://github.com/odoo/odoo/blob/d956e719d43c68abe6210e3136db576aaa6f60b8/addons/stock/views/stock_quant_views.xml#L190-L196
      
      
      So, we can't make it behave as it does from the product form,
      unfortunatly.
      
      As alternative, we can try to call `_unlink_zero_quants` when we are
      moving a package (and not `_quant_tasks` for perf matters as, so far,
      we will not have any quant to merge)
      
      OPW-3292238
      
      closes odoo/odoo#122768
      
      X-original-commit: 5fb84ba5
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      79232a4c
    • Adrien Widart (awt)'s avatar
      [FIX] stock: ensure the product policy of a storage category · d159fbce
      Adrien Widart (awt) authored
      
      When processing several SMLs at once, the 'same product' policy of a
      storage category is not respected
      
      To reproduce the issue:
      1. In Settings, enable:
         - Multi-Step Routes
         - Storage Categories
         - Packages
      2. Create a Storage Category SC:
         - Allow New Product: same
      3. Create two locations L1, L2:
         - Parent: WH/Stock
         - Type: Internal
         - Storage Category: SC
      4. Create a putaway rule:
         - When in: WH/Stock
         - Package type: Pallet
         - Store to: WH/Stock
         - Having Category: SC
      5. Edit the warehouse:
         - Incoming Shipments: 2 steps
      6. Create two products P01, P02:
         - Type: Storable
      7. Create a planned receipt R:
         - To: WH/Input
         - Operations:
           - 1 x P01
           - 1 x P02
      8. Mark R as Todo
      9. Create two packages:
         - 1 x P01 in PK01 (! PK01 must be a Pallet)
         - 1 x P02 in PK02 (! PK02 must be a Pallet)
      10. Validate R
      11. Open the related internal transfer
      
      Error: Both packages are redirected to L1. Considering the product
      policy of SC, one line should be redirected to L1 and the second one
      to L2
      
      To apply the product policy, the code looks at the quants of each
      location. But it does not consider the incoming SMLs. Therefore, when
      applying the putaway rule to the first SML, it selects L1 (which
      makes sense). Then, for the second SML, because it does not see the
      first one, it considers that L1 is empty and can be selected, hence
      the error.
      
      OPW-3204924
      
      closes odoo/odoo#122742
      
      X-original-commit: 8bde894638838b449d097e7d75092aa15c646c74
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      Signed-off-by: default avatarAdrien Widart (awt) <awt@odoo.com>
      d159fbce
    • Joseph Caburnay's avatar
      [FIX] point_of_sale: random runbot error (20517) · 661ab67c
      Joseph Caburnay authored
      
      When performing the picking action in the context of savepoint, the env
      inside the action can randomly change causing an AccessError which is
      caught as UserError (in the current point_of_sale code). Flushing before
      calling a method in a savepoint will deterministically avoid this issue.
      
      Note that the weakset used to store environments was modified in #121604
      to avoid this kind of issue.
      
      When using a cr.savepoint, the transaction must be flushed but in we
      don't have any reference to the env that should be used on the cursor,
      meaning that the env is chosen in the list of existing env. This choice
      is random because Transaction.envs is using a Weakset.
      
      In some case, the chosen env does not have the correct access right
      because the context allowed_company_ids is corresponding to a company
      coming from another test, leading to an access error, hidden by the try
      except.
      Flushing the environment before creating the savepoint will help to
      prevent this issue by flushing on a well defined environment.
      
      Note that the weakset used to store environments was modified in #121604
      (master)
      
      closes odoo/odoo#121849
      
      X-original-commit: 211f2fce
      Signed-off-by: default avatarXavier Dollé (xdo) <xdo@odoo.com>
      661ab67c
  15. May 28, 2023
  16. May 27, 2023
  17. May 23, 2023
  18. May 22, 2023
    • Arnold Moyaux's avatar
      [FIX] stock: performance with 2000 serial numbers · 9b5a8e58
      Arnold Moyaux authored
      
      It takes 70s to generate a receipt with 2000 serial numbers.
      
      It happens because during the first part of the loop
      (model `stock.move.line` in the `create` method).
      It will update the initial demand of the move based on the new
      stock.move.line and their qty_done.
      Writing the initial demand of the `stock.move` will try to reassign
      it (useless in our case) and rewrite the same value on its state's field.
      The consequence is the invalidatation of the field on
      the `stock.move.line` because it's a related to the `stock.move`.
      In the second part of the loop, it check the sml state. Since it
      was invalidate upper, it recompute it. That prevent a correct prefetch
      and cause a performance issue.
      
      We fix it by writing only once the information by move. And it
      prevent the recompute later since the state is not write during the
      loop.
      
      closes odoo/odoo#121919
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      9b5a8e58
  19. May 21, 2023
  20. May 19, 2023
    • Carlos Dauden's avatar
      [FIX] stock: _log_less_quantities_than_expected call... · f154de3f
      Carlos Dauden authored
      [FIX] stock: _log_less_quantities_than_expected call _log_activity_get_documents with empty dict and raises error
      
      closes odoo/odoo#121691
      
      X-original-commit: c62bd8b3
      Signed-off-by: default avatarTiffany Chang <tic@odoo.com>
      f154de3f
    • Mylyna Hy's avatar
      [FIX] stock: show exception log when cancel backorders · 74a7309e
      Mylyna Hy authored
      Steps to Reproduce Issue for single picking:
      1. Install Sales, Inventory
      2. Create an SO and confirm
      3. Go to the transfer, assign the done value to be less than demanded
      4. Validate the transfer and cancel the backorder
      
      Current Behavior:
      There is no exception error on the SO chatter
      
      Expected Behavior:
      An exception error should be logged on the SO chatter
      
      Other Info: When cancelling a backorder for a single picking,
      the exception error about less quantity than expected is not logged on the SO.
      "process_cancel_backorder" does not call _log_less_quantities_than_expected.
      As defined in "process", the exception is only logged when validating multiple pickings at once but
      one is to backorder but the other is not.
      
      opw-3222508
      
      X-original-commit: a1dfc58eebd1badc3eea501b23861748b3762d75
      Part-of: odoo/odoo#121691
      74a7309e
    • Michele's avatar
      [IMP] stock: unreserve only quantity required if available quantity is less... · c3857908
      Michele authored
      [IMP] stock: unreserve only quantity required if available quantity is less than quantity required when action_done on stock move.
      
      Example:
      Now there is this behaviour
      Inventory quantity 4
      Reserved quantity 3
      Available quantity 1
      If i do a stock move of 2 pieces, it will unreserve ALL the stock move of the product.
      
      With this PR it will unreserve only the pieces that are required minus the available quantity not reserved , in this case 2 (new stock move) - 1 (available quantity) = 1
      
      closes odoo/odoo#121692
      
      X-original-commit: 999c2045
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      c3857908
  21. May 17, 2023
    • Arnold Moyaux's avatar
      [FIX] stock: prevent the import of stock.move.line with reserved quantity · 4763d262
      Arnold Moyaux authored
      
      Use case: Create an import file for a picking with stock.move.line directly in
      it and add some reserved quantity on the stock.move.line.
      
      The import of stock.move.line is not possible directly via a
      stock.move.line menu but it still possible on a picking or
      mrp.production import. However the create does not expect that
      and never reserve the quants. So it result with quant <-> sml
      inconcistencies in the data and the error can not reserve more
      than you have in stock.
      
      opw-3277938
      
      closes odoo/odoo#120974
      
      X-original-commit: 53af47d1
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      4763d262
  22. May 15, 2023
  23. May 14, 2023
  24. May 10, 2023
    • Touati Djamel (otd)'s avatar
      [FIX] stock: change product's company · b5ffb60f
      Touati Djamel (otd) authored
      
      Steps to reproduce the bug:
      - Connect with the company A
      - Create a consumable product “P1”
      - Create a receipt transfer with this product
      - confirm the transfer
      - Come back to the product form
      - limiter le produit que a la “Company B”
      
      Problem:
      no user error triggered
      Go to inventory > operation > transfer: a Traceback is triggered
      
      Before this commit, there is no verification while changing a product's
      company for consumable. That can lead to an issue where some operations
      cannot be done because of access errors. To avoid that, this commit
      prevents to change the product's company if some move lines for this
      product exist in another company.
      
      opw-3300559
      
      closes odoo/odoo#120969
      
      X-original-commit: a6666de7
      Signed-off-by: default avatarDjamel Touati (otd) <otd@odoo.com>
      b5ffb60f
    • Maruan Aguerdouh (magm)'s avatar
      [FIX] stock: set location as replenishment posible without warehouse · 874e4246
      Maruan Aguerdouh (magm) authored
      
      Steps to reproduce:
      
      - Install purchase, inventory and manufacturing.
      - Now create a subcontractor, with it's corresponding location, it's set
      by default.
      - Go to this new location and set it as replenishment location.
      - Now create a Request for Quotation using this subcontractor.
      - We will receive a traceback whent trying to access replenishment.
      
      Issue:
      
      We got a traceback caused by the fact that we are trying to set
      as replenishment location, a location that doesn't have a warehouse.
      
      Solution:
      
      We need to add the handling of this case, so we won't always need
      a warehouse for the orderpoint.
      
      opw-3164276
      
      closes odoo/odoo#113361
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      874e4246
  25. May 09, 2023
  26. May 07, 2023
  27. May 05, 2023
    • Andrew Gavgavian's avatar
      [FIX] stock: fix report.stock.quantity search_read · e9f0e3e7
      Andrew Gavgavian authored
      
      	Currently `report.stock.quantity` has a field defined in it called `move_ids`:
      	`move_ids = fields.One2many('stock.move',readonly=True)`
      
      	This virtual field has no corresponding inverse field so when performing a search_read on the model, it fails
      	in fields.py when trying to do:	`inverse_field = comodel._fields[inverse]`
      
      	In addition, this field is apparently not used anywhere in the source code and not queried in the SQL View.
      
      	This means the model can never be search_read by default.
      
      	Since this field is never used, it isn't stored, and the model is `_auto = False`, removing it won't break any database.
      
      closes odoo/odoo#120696
      
      X-original-commit: e3b1a887
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      Signed-off-by: default avatarAndrew Gavgavian (andg) <andg@odoo.com>
      e9f0e3e7
Loading