Skip to content
Snippets Groups Projects
  1. Dec 17, 2021
    • Benjamin Vray's avatar
      [FIX] web_editor: prevent dropping popup inside a substructure · e5041cc2
      Benjamin Vray authored
      
      Before this commit, it was possible to drag and drop a popup inside an
      oe_structure which was itself inside an other oe_structure (e.g. snippet
      parallax). It didn't make sense and moreover created bugs.
      
      After this commit, it is no longer possible to drag and drop the popup
      snippet or the newsletter popup snippet in a substructure.
      
      task-2491976
      
      closes odoo/odoo#80836
      
      Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
      Co-authored-by: default avatarqsm-odoo <qsm@odoo.com>
      e5041cc2
    • Arnold Moyaux's avatar
      [FIX] sale_mrp: quantity invoiced in cogs is different than qty delivered · e916526a
      Arnold Moyaux authored
      
      When a kit is exploded to `stock.move` the quantity is rounded half-up
      for every move. But during the invoice. The quantity to invoice on
      kit is rounded up so it could result in differences between the
      inventory valuation and the cost of the product
      
      closes odoo/odoo#81355
      
      Signed-off-by: default avatarArnold Moyaux <arm@odoo.com>
      e916526a
    • nni-odoo's avatar
      [FIX] sale_mrp: unit price calculation BoM in different UoM · 85f227b1
      nni-odoo authored
      Fix for task 2620026.
      
      _get_bom_component_qty function is only referred to once in the whole odoo app,
      which is on addons/sale_mrp/models/account_move.py#22.
      
      The result returned from this function is used as a multiplier to quantity
      to convert into the expected UoM. However, the quantity being referred to on
      _stock_account_get_anglo_saxon_price_unit (qty_invoiced, qty_to_invoice), are
      already converted into the SO Line's product's default UoM. In this function,
      it however tries to convert 1 from SO Line's UoM to BoM's UOM.
      
      With this, if Product UoM=x, SO Line UoM=y, BOM UoM=x, in the function _stock_account_get_anglo_saxon_price_unit,
      the quantities will be multiplied by the same factor twice, resulting to the incorrect computation of price_unit to follow.
      
      Part-of: odoo/odoo#81355
      85f227b1
  2. Dec 15, 2021
    • Nicolas Martinelli's avatar
      [FIX] fetchmail: do not loop endlessly · 72cd8d07
      Nicolas Martinelli authored
      
      - Set up a POP account
      - On the POP account, receive emails addressed to various recipients,
        e.g. `my_alias_1` and `my_alias_2`. Receive more than 50 emails to
        `my_alias_2`.
      - In Odoo, create a mail alias for `my_alias_1`
      - Run the fetchmail cron
      
      The cron runs endlessly until it is killed. In the logs, inconsistent
      messages are shown:
      
      ```
      ...
      Fetched 3507 email(s) on pop server xxx; -16493 succeeded, 20000 failed.
      Fetched 3507 email(s) on pop server xxx; -16543 succeeded, 20050 failed.
      ...
      ```
      
      First the message count is incorrect in the log. We fetched at most 50
      emails, not the total number of emails. Then, the endless loop is due
      to the fact that
      - we do not delete failed messages (= messages addressed to
        `my_alias_2`)
      - we always fetch messages from `num=1`
      
      If the first 50 messages fail, we fetch them endlessly until the cron is
      killed.
      
      To avoid this, we compare the number of failed messages with the number
      of messages retrieved. If all messages retrieved have failed, we stop
      the loop.
      
      After the fix, consistent messages are show in the logs and the process
      stops after the first complete failure:
      
      ```
      start checking for new emails on pop server xxx
      Fetched 50 email(s) on pop server xxx; 0 succeeded, 50 failed.
      ```
      
      Note that it doesn't solve the core of the issue; we just fail faster. A
      proper way would probably be to use an offset so we don't always start
      at `num=1`. On the other hand, it is just a matter of time before the
      cron times out: if the mailbox is full of messages which canot be
      treated, we will just spend more and more time trying to find the ones
      which can be treated.
      
      closes odoo/odoo#81115
      
      Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
      72cd8d07
    • Brice bib Bartoletti's avatar
      [FIX] stock_account:make cogs multi_company safe · 17465e2b
      Brice bib Bartoletti authored
      
      Goal:
      The aim of this commit is to make the cogs generation multi-company
      safe.
      
      Context:
      
      Considering the situation in which company A has set a product P with
      a real time valuation and company B didn't set the real time valuation
      or has set it to manual;
      Considering the user has selected both company in the switcher;
      The user post an invoice for the product P.
      
      Before this commit:
      There isn't any cogs created for the invoice which is wrong.
      
      After this commit:
      Whatever the selected companies are, the cost selected will always be from
      the company that created the invoice.
      
      closes odoo/odoo#81348
      
      Task: #2713607
      Signed-off-by: default avatarLaurent Smet <las@odoo.com>
      17465e2b
    • nurefexc's avatar
      [FIX] web: missing context during resequence · 9b665ba8
      nurefexc authored
      
      Problem 1: The context was not passed when calling the resequence function.
      Problem 2: Also, the subsequent read operation did not pass the full
      context, but only the context of the user, not the context of the action.
      A test has been added for the basic model to check that the context is properly
      given after a resequence.
      
      closes odoo/odoo#81393
      
      Signed-off-by: default avatarAaron Bohy (aab) <aab@odoo.com>
      9b665ba8
  3. Dec 13, 2021
    • rhe-odoo's avatar
      [FIX] pos_cash_rounding: Fix value under rounding · 76ccaaf0
      rhe-odoo authored
      
      It should be allowed to pay amount that are not rounded if the value is less than the rounding value.
      Ex:
      Rounding value: 0.05
      Amount to pay: 0.04
      The amount to pay should remain 0.04 and not be rounded to 0.05.
      
      This fix allows the user to pay for values under the rounding value without applying the rounding.
      
      closes odoo/odoo#81302
      
      Signed-off-by: default avatarMasereel Pierre <pim@odoo.com>
      76ccaaf0
    • anhe-odoo's avatar
      [FIX] sale_coupon: fix the unexpired_promotions filter · d2c58a9d
      anhe-odoo authored
      
      Expected behaviour
      
      When having multiple promotions with, for example, a promotion of X% for the
      first order and a promotion of Y% (Y<X), we should apply the first promotion
      on the first order and then don't get this promotion into account to choose
      the best promotion for a future order, so that we have:
      1. A promotion of X% on the first order
      2. A promotion of Y% on every other order
      
      Observed behaviour
      
      When trying to apply promotion on other order, nothing seems to happen, as
      Odoo take the already-used X% promotion into account, being the most
      interesting promotion, select it as the best promotion to apply and then
      apply it to finally get a result of a 0% discount as the promotion has
      already been used.
      
      Problem Root Cause
      
      As it can be seen in the commit, the error comes from the fact we filtered
      the available promotion with a non-strict inequality.
      
      Validation
      
      A test has been added in test_program_numbers.py to validate our fix
      
      Related issue
      
      - opw-2674681
      
      closes odoo/odoo#80192
      
      Signed-off-by: default avatarRomain Derie (rde) <rde@odoo.com>
      d2c58a9d
    • std-odoo's avatar
      [FIX] event: allow internal users to read registrations · 0cd54df5
      std-odoo authored
      
      Bug
      ===
      Since 85053a8b we limited the access
      of the registration to the event users. But now we want to limit the
      access to the internal users.
      
      So only the portal users and the public users will be concerned by this
      restriction.
      
      Task-2666823
      
      closes odoo/odoo#78235
      
      Signed-off-by: default avatarThibault Delavallee (tde) <tde@openerp.com>
      0cd54df5
    • tranngocson1996's avatar
      [IMP] hr_expense: Add hook method for inherit · d7563d25
      tranngocson1996 authored
      
      After paying the expense report, the lines are reconciled right away but
      with this old code I can't inherit the custom reconciliation lines. So I
      provide a hook method to be able to inherit and customize the lines that
      want to be reconciled.
      
      closes odoo/odoo#81267
      
      Signed-off-by: default avatarKevin Baptiste <kba@odoo.com>
      d7563d25
  4. Dec 12, 2021
  5. Dec 10, 2021
    • Brice bib Bartoletti's avatar
      [FIX] stock_account:make cogs multi_company safe · 3f777d43
      Brice bib Bartoletti authored
      
      The aim of this commit is to make the cogs generation multi-company
      safe.
      
      Before this commit:
      When posting an invoice from company B with both company A and B
      selected and A being selected as "main", the cost from company A could
      be selected instead of cost from company A to create the anglosaxon
      lines.
      
      After this commit:
      Whatever the selected companies are, the cost selected will always be from
      the company that created the invoice.
      
      closes odoo/odoo#79674
      
      Task: #2686104
      Signed-off-by: default avatarLaurent Smet <las@odoo.com>
      3f777d43
    • Raf Geens's avatar
      [FIX] base_address_city: Inherit city_id from parent contact · e4345c81
      Raf Geens authored
      
      If you create an individual contact that has a company contact as the
      parent, it will inherit certain fields from that parent, which are
      defined by `_address_fields` in `res.partner`.
      
      `base_address_city` allows enforcing picking a city from a pre-defined
      list, which gets stored in `city_id` instead of the standard free-text
      `city` field on `res.partner`. If you change `city_id`, an `onchange`
      will update `city`.
      
      `city_id` was not being inherited from the parent, which means the
      contact ends up in an inconsistent state: `city` will be set, but
      `city_id` will not.
      
      In the Colombian accounting localization, which uses the enforced city
      feature, a municipality code which is part of the record behind
      `city_id` is mandatory in certain electronic invoice XML fields that get
      sent to Carvajal. This value will incorrectly be 0 if `city_id` is not
      set on the contact due to the above issue, causing the invoice to be
      rejected.
      
      This fix lets a contact inherit the `city_id` from its parent if
      `base_address_city` is installed.
      
      opw-2638687
      
      closes odoo/odoo#81230
      
      Signed-off-by: default avatarQuentin De Paoli <qdp@odoo.com>
      e4345c81
    • Leo Tran's avatar
      [CLA] Viindoo updates Odoo's CLA · ad12b854
      Leo Tran authored
      
      closes odoo/odoo#81194
      
      Signed-off-by: default avatarMartin Trigaux (mat) <mat@odoo.com>
      ad12b854
  6. Dec 09, 2021
    • Raphael Collet's avatar
      [FIX] core: computed inversed fields partly assigned · fb4d6ee4
      Raphael Collet authored
      
      This fixes inconsistencies when dealing with fields that are computed
      and inversed by the same methods.
      
      Consider two fields F1, F2 with the same compute and inverse methods.
      Consider a record where we wrote on a dependency of the common compute
      method.  At this point, both fields F1 and F2 are marked to be computed.
      
      Now let us write on F1 only.  Here is what happens:
       - the write discards the computation of F1, but not F2
       - the inverse method of F1 is called:
          - the method accesses F2
             -> this calls the compute method, which assigns both F1 and F2
          - the method accesses F1
             -> the value of F1 has been replaced by the computation above
      
      The issue comes from a combination of factors:
       - the value of F2 must be determined by the computation;
       - the computation assigns both F1 and F2;
       - the computation is done while inversing F1 (and F2).
      
      The solution is to force the computation before actually writing on the
      fields and calling their inverse methods.  Note that this is necessary
      only when part of the fields computed by a common method are updated.
      When all fields computed by a common method are updated, the computation
      will automatically be cancelled.
      
      closes odoo/odoo#81105
      
      Signed-off-by: default avatarRaphael Collet <rco@odoo.com>
      fb4d6ee4
    • William Braeckman's avatar
      [FIX] hr_org_chart: fix employee deletion · 3ec9dcc5
      William Braeckman authored
      
      How to reproduce:
      1: create two employees (A B)  and two departments (C D)
      2: Assign A as manager of C and B as manager of D
      3: Assign C as A's department and A as A's manager
      4: Change A's department to D -> A is deleted
      
      This is due to `parent_id` being both a computed field and the source
      field for a One2many. By changing the `department_id` the `parent_id`
      also changed which results in it being report in the `onchange` method.
      For some reason however the command sent by the orm is not `UNLINK` but
      `DELETE` which results in the `active_id` being deleted.
      
      TaskId-2711428
      
      closes odoo/odoo#81122
      
      Signed-off-by: default avatarYannick Tivisse (yti) <yti@odoo.com>
      3ec9dcc5
    • Arnold Moyaux's avatar
      [FIX] stock: add an automated way to fix unreserve issue · d99e173b
      Arnold Moyaux authored
      
      It happens that the `stock.quant.reserved_quantity` and `stock.move.line.product_qty`
      for the same parameters are not equals (due to some bugs in the past)
      
      It could implies that it doesn't exist enough reserved quantity on the
      quant when a user try to unreserve a stock.move.line resulting in the
      UserError 'It is not possible to unreserve more products of %s than you
      have in stock'
      
      However on current stable version (13.0 and 14.0) a lot of PR already
      fixed a lot of issue as:
      odoo/odoo#69377
      odoo/odoo#66347
      odoo/odoo#61758
      odoo/odoo#54355
      odoo/odoo#43180
      odoo/odoo#70975
      for example (there is more than that)
      
      So the idea is to provide a way to unlock the database manually for
      stable but not in the new version to be able to analyse them and find
      possible bugs responssible for the desynchronization.
      
      The server action check all the quants and their relative move line
      to check if match correctly. If not it will remove the reservation
      from both. It could remove the reservation from some `pickings` and
      `stock.move`
      
      related to odoo/odoo#62139
      
      closes odoo/odoo#79180
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      d99e173b
    • Adrien Widart's avatar
      [FIX] stock: correctly compare float · 7f30ef42
      Adrien Widart authored
      
      Due to floating point representation, some floats may have some
      insignificant decimals. Therefore, `float_compare` should be used when
      comparing such numbers
      
      OPW-2699576
      
      closes odoo/odoo#80983
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      7f30ef42
  7. Dec 08, 2021
  8. Dec 07, 2021
    • Adrien Widart's avatar
      [FIX] sale_mrp: not include consu components in kit's COGS · 5de45100
      Adrien Widart authored
      
      When selling a storable kits, the consumable components should be
      ignored in account lines
      
      To reproduce the issue:
      (Need account_accountant,sale_management,mrp)
      1. Create a product category PC:
          - Costing Method: FIFO
          - Inventory Valuation: Automated
      2. Create 3 products P_kit, P_compo01, P_compo02
          - P_kit:
              - Type: Storable
              - Category: PC
          - P_compo01
              - Type: Storable
              - Category: PC
              - Cost: 5
          - P_compo02:
              - Type: Consumable
              - Category: PC
              - Cost: 6
      3. Update P_compo02's on hand qty: 1
      4. Create a bill of materials:
          - Product: P_kit
          - Type: Kit
          - Components:
              - 1 x P_compo01
              - 1 x P_compo02
      5. Create & Confirm a sale order SO with 1 x P_kit
      6. Process the related delivery
      7. Create & Post the related invoice
      
      Error: The journal items of the invoice are incorrect, the value of
      Expenses and Stock Interim (Delivered) are $11 instead of $5. The
      consumable components should be excluded from this value
      
      OPW-2604084
      
      closes odoo/odoo#80850
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      5de45100
    • Leo Tran's avatar
      [CLA] Viindoo signs Odoo's CLA · 567a8380
      Leo Tran authored
      
      closes odoo/odoo#80976
      
      Signed-off-by: default avatarMartin Trigaux (mat) <mat@odoo.com>
      567a8380
    • Adrien Widart's avatar
      [FIX] purchase: compute the average of the delays in report · 80e71545
      Adrien Widart authored
      
      When consulting the Purchase Analysis, the measure "Days to Confirm" may
      not be easily understandable
      
      To reproduce the issue:
      1. Create a purchase order PO:
          - Order Deadline: <today + 10 days>
          - Add 2 products
      2. Confirm PO
      3. Purchase > Reporting:
          - Measures: Days to Confirm
          - Group By: Order
      
      Error: For PO, the value of "Days to Confirm" is -20, it should be -10
      
      The report computes the sum of the delay (i.e., "Days to Confirm") of
      each purchase order line. Computing an average seems more relevant
      
      A similar flow could be reproduce with the measure "Days to Receive"
      (i.e., the difference between the Order Deadline and the Receipt Date)
      
      OPW-2678673
      
      closes odoo/odoo#80671
      
      Signed-off-by: default avatarArnold Moyaux <arm@odoo.com>
      80e71545
    • Víctor Martínez's avatar
      [FIX] stock_landed_costs: Allow to use LC without real_time · 81ad4d6a
      Víctor Martínez authored
      
      The requirement of having real_time valuation in product categories to use LC is not needed
      at all, as the information is taken from stock.valuation.layer, but it was previously
      enforced due to the leftovers of the previous algorithm.
      
      We remove such requirement in this commit, and also not creating the LC journal entry in
      such cases.
      
      TT32954
      
      closes odoo/odoo#80200
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      81ad4d6a
    • Raphael Collet's avatar
      [FIX] base: fix search on company depend fields · 9b339afa
      Raphael Collet authored
      
      This is a bunch of fixes (65 corner cases) for the search on
      company-dependent fields:
      
      Without a default value:
      - `char` fields:
          - operators `not like`/`not ilike` don't return records with unset value
          - `(..., '=', False)` doesn't return records with unset value
          - `(..., '!=', '<string>')` doesn't return records with unset value
          - `(..., 'in', [..., False])` doesn't return records with unset value
          - `(..., 'not in', value)` without `False` inside `value` doesn't return records with unset value
      - `date` and `datetime` fields:
          - `(..., '!=', <Date/datetime>)` doesn't return records with unset value
          - `(..., '=', False)` doesn't return records with unset value
      - `many2one` fields:
          - operators `not like`/`not ilike` don't return records with unset value
          - `(..., 'in', [..., False])` doesn't return records with unset value
          - `(..., 'not in', value)` without `False` inside `value` doesn't return records with unset value
      - `boolean` fields:
          - `(..., '=', False)` and `(..., '!=', True)` don't return records with unset and `False` values
      - `integer`/`float` fields:
          - `(..., '!=', <number>)` doesn't return records with unset value
      
      With a truthy default value:
      - `many2one` fields:
          - operators `not like`/`not ilike` don't return records with unset value
          - `(..., '=', False)` returns the record with the default value (which isn't `False`)
      - `boolean` fields:
          - `(..., '=', False)` doesn't return records with unset and `False` value
          - `(..., '!=', False)` returns records with unset and `False` value
      - `integer`/`float` fields:
          - all `(..., operator, value)` which include value 0, return all records with unset value, even if the default value does not satisfy the domain
      
      closes odoo/odoo#80082
      
      Signed-off-by: default avatarRaphael Collet <rco@odoo.com>
      9b339afa
  9. Dec 06, 2021
    • BVE's avatar
      [FIX] account: update default value in alias on journal type change · 9bdf129a
      BVE authored
      
      Steps to reproduce the bug:
      - Go to settings and enable “External Email Servers” option
      - Go to accounting > Configuration > journals
      - Create a new journal, Choose "purchase" type
      - save
      - Go to advanced settings tab > click on email alias
      - Note that default value = `in_invoice`
      - Create another journal, choose "Miscellaneous" type > save
      - Change the type to "purchase"
      
      Problem:
      the default value = "out_invoice", because it is not updated in the write function after changing the journal type
      In the case of type == 'purchase', the default value should be 'in_invoice', and in any other case, it should be 'out_invoice'.
      
      opw-2618357
      
      closes odoo/odoo#75358
      
      X-original-commit: 3da57964aeee99c8314195c763fe521c28fbc734
      Signed-off-by: default avatarWilliam André (wan) <wan@odoo.com>
      9bdf129a
    • Aurélien (avd)'s avatar
      [IMP] stock: improve stock_inventory action_start perfs · ba92e1da
      Aurélien (avd) authored
      
      Backport branch odoo/odoo#79587 to v13.
      
      In _get_inventory_lines_values, remove quants recordset
      as it has been unused since commit cc9324f7.
      
      Browse product.product in _get_inventory_lines_values
      outside of for loop to speedup getting the uom_id.
      
      closes odoo/odoo#80106
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      ba92e1da
    • Csaba Tóth's avatar
      [FIX] stock: missing field from a compute method dependency · b4a9e5b8
      Csaba Tóth authored
      
      The `uom_id` field from the product is used, but the field is missed from the dependency decorator. Because the `product_qty` field is stored, than it will never recalculated when i modify the uom on the product.
      
      closes odoo/odoo#80911
      
      Signed-off-by: default avatarArnold Moyaux <arm@odoo.com>
      b4a9e5b8
  10. Dec 05, 2021
  11. Dec 03, 2021
  12. Dec 02, 2021
    • root's avatar
      [FIX] base_vat: allow disabling VAT check through context · 11fd5b4d
      root authored
      
      Before this fix there is no real way to influence the VAT validation.
      This can be problematic though as in some cases external platforms push data to you
      on which you don't really have control. If an external software pushes an invalid VAT
      and your database has the option 'Verify VAT Numbers' checked on there is no way
      for you to bypass this though.
      This means that before this commit you have to always run VAT number checks on all data,
      no matter if they come through the frontend or backend.
      
      After this commit you can supply a context key 'no_vat_validation' though.
      This way you could skip doing VAT number validations on (some) records while still
      enforcing this in the UI.
      This allows you to have crons/external API's push any VAT number while enforcing full
      validation through the UI.
      
      This opens up the best of both worlds.
      
      closes odoo/odoo#80503
      
      Signed-off-by: default avatarOlivier Colson <oco@odoo.com>
      11fd5b4d
    • Martin Trigaux's avatar
      [FIX] base: ensure all attachments are in sudo · 9f0ce611
      Martin Trigaux authored
      
      >>> u1 = self.sudo(False).browse(1)
      >>> u2 = self.sudo().browse(2)
      >>> (u1 + u2).env.su
      False
      >>> (u2 + u1).env.su
      True
      
      Ensure all attachments are always in sudo
      
      Before this commit, a portal user could not go in debug asset
      
      Introduced at 3a98996e
      
      closes odoo/odoo#80754
      
      Signed-off-by: default avatarMartin Trigaux (mat) <mat@odoo.com>
      9f0ce611
    • Juan Jose Scarafia's avatar
      [IMP] l10n_ar: document types settings · 2cd1b449
      Juan Jose Scarafia authored
      1. disable document types that are not available https://www.afip.gob.ar/libro-iva-digital/documentos/Libro-IVA-Digital-Tablas-del-Sistema.pdf
      
       (remove "internal_type" value)
      2. Add prefix and purchase_aliquots for every document type that usable (has an internal_type value)
      3. Enable liquidacion primaria/secundaria de granos
      
      closes odoo/odoo#79878
      
      Signed-off-by: default avatarJosse Colpaert <jco@odoo.com>
      2cd1b449
    • Adrien Widart's avatar
      [FIX] mrp: compare float thanks to `float_compare` · ec0206fd
      Adrien Widart authored
      
      In some situations, the user can't redefine the quantity to produce of a
      MO
      
      To reproduce the issue:
      (Use demo data. Enable debug mode)
      1. In Decimal Accuracy, edit Product Unit of Measure:
          - Digits: 5
      2. Create a MO:
          - Product: [FURN_7023] Wood Panel
          - Quantity To Produce: 1000
      3. Produce 800
      4. Update the Quantity To Produce: 800
      
      Error: An error message is displayed: "You have already processed
      800.00000. Please input a quantity higher than 800.00000"
      
      Due to a floating point issue, the produced quantity is actually
      800.0000000000001 which is greater than 800. This is the reason why the
      `UserError` is raised
      
      Some similar issues might be found with the other float comparisons in
      `change_prod_qty`.
      
      OPW-2689831
      
      closes odoo/odoo#80388
      
      Signed-off-by: default avatarArnold Moyaux <arm@odoo.com>
      ec0206fd
    • Adrien Widart's avatar
      [FIX] mrp_subcontracting_account: always return PU of subcontracted SM · 89814281
      Adrien Widart authored
      When using AVCO and subcontracting without any additional cost, the
      valuation of the finished product is incorrect
      
      To reproduce the issue:
      1. Create a Product Category PC:
          - Costing Method: AVCO
      2. Create two products P_compo and P_finished:
          - Both:
              - Type: Storable
              - Category: PC
          - P_compo:
              - Cost: 10
              - Routes: Resupply Subcontractor
      3. Update P_compo's quantity: 2
      4. Create a Bill of Materials BO:
          - Product: P_finished
          - Type: Subcontracting
          - Subcontractor: a partner P
          - Component: 1 x P_compo
      5. In Inventory, create a planned Receipt R:
          - From: P
          - Operations: 1 x P_finished
      6. Mark R as To Do
      7. Process the delivery of P_compo
      8. Validate R
      9. Repeat steps 5-8
      10. Open the Inventory Valuation
      
      Error: There are two valuation lines for P_finished: one line has a
      value of $10, which is correct (this is the cost of the component).
      However, the value of the second line is $20, it should be $10 too.
      
      Here are a part of the values used to generate the related MO:
      https://github.com/odoo/odoo/blob/2d12fb8fb94c0f2acade7222cfedbec34114a8e9/addons/mrp_subcontracting_account/models/stock_picking.py#L21-L25
      In the above case, an extra cost is defined on the MO and is based on
      the unit price of the subcontracted SM. However, `_get_price_unit` will
      return an incorrect value:
      https://github.com/odoo/odoo/blob/251be6b943ea8c3f274bb0863d0af3f7c6b8d10d/addons/stock_account/models/stock_move.py#L39
      After step 8, the standard price of P_finished is $10. Also, in the
      above case, there isn't any subcontracting cost, so there isn't any unit
      price defined on the SM. Therefore, `_get_price_unit` returns the
      standard price of P_finished ($10). As a result, when computing the
      value of the finished stock move:
      https://github.com/odoo/odoo/blob/4fc2ec31861d4602357f130066ec3507b96d8dc8/addons/mrp_account/models/mrp_production.py#L39-L42
      
      
      It uses the extra cost of the MO + the component cost. This explains
      where the $20 come from.
      
      OPW-2641339
      
      closes odoo/odoo#80373
      
      Signed-off-by: default avatarWilliam Henrotin (whe) <whe@odoo.com>
      89814281
  13. Dec 01, 2021
  14. Nov 30, 2021
Loading