Commit Graph
682 Commits
Author SHA1 Message Date
Adrien Widart (awt) 5a0f546dba [FIX] purchase{,_stock,_mrp}: get unit price of AVCO kit-component
Receiving a kit's component will fail in AVCO + multi-uom

To reproduce:
1. Create a product category PC
   - Costing Method: AVCO
2. Create two products P_compo, P_kit
   - P_kit:
     - In Units
   - P_compo:
     - In L
     - Storable
     - Category PC
3. Create a BoM
   - Product: P_kit
   - Type: Kit
   - Components: 1 x P_compo
4. Create and confirm a PO with 1 x P_kit
5. Process the receipt

Error: When validating the receipt, a user error is displayed: "The
unit of measure L defined on the order line doesn't belong to the
same category [...]"

When processing the SM, we create the in-SVL. To do so, at some
point, we need the unit price of the SM, and here is where the error
comes from:
https://github.com/odoo/odoo/blob/708c3d063482e365e49a04f633c83e90e6fa4356/addons/purchase_stock/models/stock_move.py#L39
`self.product_id` is P_component, but `line.product_id` is P_kit,
hence the error with the UoM1
And there will be some similar errors with the `if` block, L40 (we
compare some SM quantities and some POL quantities: we are mixing
components and kit)

For now, in case of a kit, we will always use the `else` block (i.e.,
the unit price of the POL). This will be improved in master

OPW-3357685

closes odoo/odoo#128386

X-original-commit: 3a81eb79cad7f25843315e39da421efa2c34aaf1
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
2023-07-13 19:28:21 +02:00
Adrien Widart (awt) 4333b16d8c [FIX] purchase_stock: update RR's qty_to_order on POL's qty change
When a RR updates the qty of a POL, the qty to order of that RR will
be incorrect

To reproduce the issue:
1. Create a product
   - Storable
   - With a vendor
2. Create a RR:
   - Min 0
   - Max 0
   - Factor 1
3. Confirm a delivery with 1 x P
   - It should create a PO
4. Confirm a second delivery with 1 x P
    - The POL of the PO should be updated
5. Open the Replenishment page

Error: The qty to order of the product is 1 while it should be 0

`qty_to_order` is a computed field and one of the `depends` is the POL
related to the product. This explains why, after step 3, everything
is ok: the compute is triggered (because of the new POL) and the qty
to order becomes 0. However, step 4, the POL qty is updated -> it
does not concern any `depends` -> the compute is not triggered,
hence the error

OPW-3292297

closes odoo/odoo#128279

X-original-commit: 80521431601323c1eb7c85cafbf08e8ae0adbdd6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
2023-07-13 07:18:51 +02:00
Aurelien van Delft (avd) d534fdaa55 [IMP] purchase_stock: add ir_config_parameter to on_time_rate comp.
On-time-rate is a non-stored computed fields that can take
some time to load because some partners may have lots of
related purchase_orders. The compute function in itself
is relatively difficult to optimize further. This commit
introduces a new system parameter to reduce the timerange of
orders to consider when computing On-Time Delivery Rate.

That way, if for some customers the on_time_rate computation takes too
much time (leading to a slow FormView loading), they can reduce
the accuracy of the estimation to speedup the field's computation.

closes odoo/odoo#128199

X-original-commit: 2e766f11024e9bb905f8e98d7218cf924c43a0c9
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Aurélien van Delft (avd) <avd@odoo.com>
2023-07-13 00:46:08 +02:00
Maximilien (malb) 9ddc128d7b [IMP] sale, purchase, account: incoterm location
Before this PR, the incoterm location was not present in the account module.

This pr does multiple things:
- Add the Incoterm Location field in Accounting on Customer Invoices and Vendor
Bills. The field already exists on Sale Orders and Purchase Orders. When you
create an Invoice from a Sales Order, or a Vendor Bill from a PO, copy the value
of the field on the invoices.

- Update the PDF to display the field value if present, and remove the useless
duplication

- Remove incoterm setting on sale

- Remove useless xpath since now it is displayed directly on invoice when
incoterm field is fill.

Task-id: 3273460
Part-of: odoo/odoo#118954
2023-07-12 21:45:44 +02:00
David (dafr) 343f6143d7 [FIX] purchase_stock: get_price_unit with manual valuation
layer.account_move_id may not be defined on 'manual' valuation.
Use layer.create_date instead which is equal to layer.account_move_id.date.

# HOW TO REPRODUCE:
- Create a product P, storable in AVCO !! MANUAL !!
- Set 'Control Policy' under Purchase to 'Ordered Quantity'
- Create a PO for 10 units of P with for $1 each.
- Create Vendor Bill -> Confirm
- Receive 5 unit of P: Create backorder
- Validate backorder
==>> Traceback

OPW-3383833

closes odoo/odoo#127218

X-original-commit: b1351ee348207283dcdf7118440b31c03f0d0b4b
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: David Fesquet (dafr) <dafr@odoo.com>
2023-07-04 12:47:12 +02:00
Adrien Widart (awt) 08613dc3ae [FIX] purchase_stock,stock_account: refund price difference
If a bill has a price difference with the PO, and if the user
refunds it, it will create some errors in the inventory valuation and
the accounting entries

To reproduce the issue:
(Need account_accountant)
1. Create a product category PC
   - Costing method: FIFO
   - Inventory valuation: Automated
2. Create a product P
   - Type: Storable
   - Category: PC
3. Confirm a PO with 1 x P at $10
4. Receive P
5. Bill it at $15
   - It should create a price diff SVL, see inventory valuation
6. Refund

Errors: The inventory valuation is not impacted, it is still valued
at $15. Because of the refund, it should be $10 (i.e., the price
difference should be cancelled). Then, suppose the user creates a
new bill at $20, it won't do anything (the stock valuation will not
be impacted).

Long story short: the price difference feature, which is supposed to
impact inventory valuation/account entries, does not work if there
is a (partial/full) refund in the flow.

Now, let's think about a more complicated use case:
- Receive 12 products in several times
- Bill in several times (with different quantities than the receipts)

It could give something like (where `x` are products):
```
       SVL01        SVL02           SVL03
/---------------\/---------\/------------------\
  x   x   x   x   x   x   x   x   x   x   x   x
\-----------/\-----/\--/\---------------/\------/
     B01       B02   B03       B04          B05
('B' means Bill)
```
We observe that
- a bill could impact several layers
- a layers could be impacted by several bills

And here is the issue: currently in the code, we don't have a relevant
link between layers, account move lines and the quantity that links
both. The only thing we have is a link between the price difference SVL
and the account move line that has generated that SVL (see field
`account_move_line_id` on `stock.valuation.layer`). But this is
clearly not enough and is really problematic: if I refund BILL04, how
should it impact SVL02 ? Then, what if I return a part of the third
delivery before refunding BILL04 ? What if I deliver a part of the
received products before refunding several bills ? What if I refund
B02, B05, then I bill 4 products ?

-> You get the idea: we definitly need a clear link between account
move lines and stock valuation layers and that link has to give a
quantity.

Moreover, it is difficult to create an order between bills. We have
their name, their ID, but the posted time is actually a date. So, if
we mix reset & repost, a draft bill and a draft partial refund, and
so on, and if this mix happens the same day, it is very difficult to
define a clear order. But, considering the above schema, we see that
the order does matter (switch BILL02 and BILL03, the remaining
values of SVL01 and SVL02 will not be the same)

-> So, we also need a way to order the links between account move lines
and stock valuation layers.

Now, about the solution.

First, a **disclaimer**: We are in stable, we are limited by the stable
policy, and we can't let the above use cases unresolved. So, we took
some decisions to fix them and to repesct all the constraints we had.
**This is clearly a (big) patch, it should be considered as such and
will be replaced by a cleaner/better solution on master as soon as
possible**.

About the link between SVL and AML, we had the possibility to create
a new model in a new module. But this would have decreased the
impact of the fix deployment, would have created some
complications for support (different behaviours depending on whether
the module is installed or not) and would have make testing more
complicated (again, different behaviours depending on whether the
module is installed or not).

This is the reason why we decided to "replay the receipts and the
bills". That way, we know which layer is impacted by which invoices,
and vice versa. And, to set the order between all of them:
- For the layers, we use their `create_date`
- For the bills, we use a hack: each time an account move is posted,
  because its state is tracked, a tracking value is posted on the
  chatter, and this tracking value has a `create_date` (remind the
  constraints explained above and the disclaimer...)

OPW-3217215

closes odoo/odoo#126536

X-original-commit: b5e0e1057b81f7333e73ef06e88e8943709119cc
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
2023-06-29 18:20:27 +02:00
Pieter Claeys (clpi) ccb41edf2b [IMP] stock: better returns
Improve the returns process by adding the following improvements:
- Removal of the 'return' operations type. Returns of deliveries now
become receipts.
- Update of the `stock_picking_return` wizard by removing the onchange
on picking_id.
- Show returns in the sale portal, with a new 'return label' PDF report
- Enable returns for multi-step receipts on purchases

Community PR: https://github.com/odoo/odoo/pull/118568
Enterprise PR: https://github.com/odoo/enterprise/pull/39761

closes odoo/odoo#118568

Task: 3081370
Related: odoo/upgrade#4660
Related: odoo/enterprise#39761
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-06-23 18:00:05 +02:00
Samuel Degueldre 81be42d8f9 [FIX] *: ensure tour tips are correctly translated
*: account, crm, crm_iap_mine, event, hr_expense, hr_holidays,
hr_recruitment, lunch, mail, mass_mailing, point_of_sale, project,
purchase, purchase_stock, sale, survey, web, website, website_blog,
website_event, website_forum, website_sale, website_slides,
test_main_flows

In odoo/odoo#111103 the tour system was rewritten. The previous tour
system used to depend on the `root.widget` js module, and this module
was an async module that indirectly depended on `session_bind` which
would load the translations, meaning that the js module definition code
of the tours would only run after the translations were loaded. This is
no longer the case with the new tour system, this means that the module
definition code is executed as soon as the dependencies of that module
are fulfilled, which is generally befoe the translations are loaded,
causing most tour tips to not be translated.

This commit adds a hacky workaround for this problem: it creates a new
module that has a default export which is a promise, and has a legacy
alias, this creates an async module that waits for the translations to
be loaded. This module is then imported for its side-effect in all
onboarding tours, causing them to be translated correctly once again.

This commit also needs to convert the steps key in the tours internal
registry to a getter. In previous versions, the steps were directly
added as is to the internal state of the tour service, but since
odoo/odoo#122834 the steps are now mapped, and without a getter, any
edits to the steps occurring after registration will not be taken into
account. This causes issues in some modules that change original
behaviour of other modules (eg accounting makes invoices into a menu in
the accounting app instead of a top-level app in the home menu) as they
need to edit the steps of existing tours to make them work.

In a separate PR, we will implement a more proper fix by changing the
API of the tour manager so that we no longer need this workaround.

closes odoo/odoo#125284

X-original-commit: d130699ba82dc9919c9116f4b64a5e461ebb6319
Related: odoo/enterprise#42655
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Samuel Degueldre (sad) <sad@odoo.com>
2023-06-19 13:35:28 +02:00
yhu-odoo 9955064415 [FIX] purchase_stock: valuation layer wrong when different currency
To reproduce:
1. Create a storable product with ordered quantities policy for purchase and with a category set as FIFO automated
2. Create a purchase order in a different currency and set quantities for partial deliveries
3. Create a partial delivery
4. Fully invoice the purchase order
5. Create the delivery of the complementary units
6. Check the stock valuation layer
The valuation of backorder is wrong.

The value on valuation layer is in company's currency, while the value
on invoice line is in the PO's currency. When create valuation line for
backorder, we didn't convert them to same currency.

opw-3300266

closes odoo/odoo#125206

X-original-commit: c2de679fcba7f153201dde5b3aa989eb3f329910
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Yuchen Huang (yhu) <yhu@odoo.com>
2023-06-15 19:59:18 +02:00
mehjabin 900e642af0 [FIX] purchase_stock: remove duplicate field
before this commit, the field incoterm_id is defined
twice in purchase.order model, i.e., in purchase and
purchase_stock modules

after this commit incoterm_id field is removed
from purchase_stock module

closes odoo/odoo#123602

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-06-09 18:30:25 +02:00
Adrien Widart (awt) 8ff484574a [FIX] stock, *: write on WH with deleted routes
*: mrp{,_subcontracting{,_dropshipping}}, purchase_stock

When a route is deleted, it is no more possible to write on a warehouse

To reproduce the issue:
1. In Settings, enable "Multi Steps Route"
2. Delete the route "Buy"
3. Edit the warehouse:
   - Receipt: 3 steps

Error: a UserError is displayed because of the missing buy route,
which does not make sense, the warehouse receipt should be updated

Even worse: step 3, try to install `mrp_subcontracting` and it will
lead to a parse error. It comes from:
https://github.com/odoo/odoo/blob/3f389b4769d947b52985c0a15eae5be59b1e28f7/addons/mrp_subcontracting/data/mrp_subcontracting_data.xml#L10-L13
Again, we try to write on the warehouse -> not possible

When writing on a warehouse, we will check if we have to
create/update some rules:
https://github.com/odoo/odoo/blob/3b801a6d48f1feffd1b87a7d54731ab58e8d63e9/addons/stock/models/stock_warehouse.py#L202-L206
We will then try to get the buy route
https://github.com/odoo/odoo/blob/1b525febfab839fdb9d6ff66107a9c0c833b92be/addons/purchase_stock/models/stock.py#L35
Which will lead to the user error
https://github.com/odoo/odoo/blob/3b801a6d48f1feffd1b87a7d54731ab58e8d63e9/addons/stock/models/stock_warehouse.py#L379

sentry-4128085959

closes odoo/odoo#122743

X-original-commit: 4323e2ec5d316fe83a0184c97230d21ea122ef99
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart (awt) <awt@odoo.com>
2023-05-30 13:03:33 +02:00
kir-odoo c3b7a87462 [IMP] stock: improvements in replenishment wizard
With this commit:
========================
- Added a new field `forecasted_qty` in replenishment to display the
  forecasted qty based on a selected warehouse in the wizard
- Changed the `route_ids`(m2m) field to `route_id`(m2o) so that
   we can apply a specific route for the
  replenishment instead of the product's default routes
- Reduced the width of all the fields
- Remove the time from the scheduled date and make the unit field not editable.
- Can see vendor information with info icon field when buy is selected
- Hide the Dropship route from the Route

TaskId : 2579425

closes odoo/odoo#96948

Related: odoo/upgrade#3796
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-05-24 15:45:23 +02:00
Aurelien van Delft (avd) a55a08ef56 [FIX] purchase_stock: _compute_on_time_rate optimizations
Turn the call to filtered after the search on purchase.order.line
into a call to _search. This allows to remove filtered by adding
an additional leaf in the search domain.

Add read calls to fetch fields from db and store them in cache
on recordset batches.

Example speedup: partner with 136555 POL 6.33s -> 3.42s

opw-3277299

closes odoo/odoo#122218

X-original-commit: b3e81b092864c71a9d5d097fbfa965319acf4fba
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Van Delft Aurélien (avd) <avd@odoo.com>
2023-05-24 13:10:51 +02:00
Louis Wicket (wil) 04189318cc [I18N] *: update master translations
Currently, only stable releases see their translations updated. This has
resulted in master accumulating outdated stuff for years, which can be
confusing for users testing master on runbot.

This one-shot commit resynchronizes master translations based on the
content from 16.0 and removes empty PO files (i.e. no longer containing
translations).

closes odoo/odoo#121629

Related: odoo/enterprise#41171
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-22 17:52:07 +02:00
Arnold Moyaux a0b6b051ae [FIX] stock_account: False currency exchange on interim receipt
Usecase to reproduce:
- Set the currencies as 1€ = 2$ ($ as company currency)
- Create a PO for a product in AVCO auto with a price of 100€
- Do the receipt
- Change the rate as 1€ = 4$
- Bill the PO

Expected behavior:
- One correction account.move.line for the 200$ and the stock
interim receipt account reconciled.

Current behavior:
- An aml from the price difference with the 200$
- Another from the currency exchange also for 200$
- The line from the price diff is not reconcile

`_stock_account_anglo_saxon_reconcile_valuation` should never reconcile
account.move.line from a price difference correction without the context
key no_exchange_difference because the currency correction is already
handle in the correction layer.

closes odoo/odoo#120158

X-original-commit: b8bbd7e2a3f8f9e119b11314bcebfadb2ba75eda
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-05-17 13:38:02 +02:00
Sohail Jaidi (soja) 4d3ac4cbd8 [IMP] account,*: simplify add credit note wizard
Description of the issue/feature this PR addresses:
simplification of the credit note wizard

Current behavior before commit:
First users select reverse option (3 radio buttons):
1) refund
2) cancel
3) modify

The reverse action is triggered when the users clicks on the "reverse" button

After commit:
radio button are removed. There is now two buttons that trigger directly the reverse action with the desired option (refund or modify, cancel is not available anymore)
Also, for refund, posting the draft reverse move will also reconcile with reversed move.

task id: 3244377

closes odoo/odoo#117961

Related: odoo/enterprise#40919
Related: odoo/upgrade#4667
Signed-off-by: John Laterre (jol) <jol@odoo.com>
2023-05-17 13:37:54 +02:00
Sohail Jaidi (soja) dbd9b9dcfe [REF] account,*: going from cancel to modify in tests
After the modification of the credit note wizard the option 'cancel' is not available anymore.

Since there was no test for 'modify' and the 'refund' option was already tested, the tests are modified so that it now tests 'modify' option

task id: 3244377

Part-of: odoo/odoo#117961
2023-05-17 13:37:54 +02:00
William Henrotin 5e5d92ef79 [IMP] stock: picking flow reworked
This commit changes the process flow of stock pickings. A new picking will
always be created in immediate transfer mode and 'ready' state. From
their, it can be validated directly or 'reset to draft'. This second action
switch the immediate mode to planned mode and reset the state as draft.
From their the classical workflow is processed
confirm -> (assigned ->) validated

Task: 3256447
Part-of: odoo/odoo#117513
2023-05-17 13:37:47 +02:00
Martin Trigaux 077bbd0b0b [I18N] *: export master source terms
closes odoo/odoo#121563

Related: odoo/enterprise#41140
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2023-05-17 10:34:00 +02:00
Tom De CaluwéandPedro Manuel Calheiros Lima de Sousa 5d084bcf88 [FIX] purchase_stock: set qty_received_method to manual on uninstall
After uninstalling the stock module on a database which also has the purchase
(and purchase_stock) module installed, the qty_received_method is removed for
purchase order lines handling the reception of the products through the stock
module (qty_received_method = 'stock_moves'). Because of this, a recompute
is triggered on the qty_received, setting it to zero.

This leaves the purchase order in an invalid state (the received quantity did
not change through the uninstallation of the stock module), additionally the
problem cannot be corrected, since the receiving method is not set to manual.

Functionally, the uninstallation shouldn't update the purchase orders, instead
they should be decoupled from the associated stock moves. To this end, an
ondelete handler is added for the stock_moves selection option.

Steps to reproduce:

 - Install Purchases app
 - Install Inventory app
 - Create a purchase order with purchase lines and quantity > 0
 - Confirm the purchase order
 - Click on receive products
 - Click on validate
 - Uninstall Inventory app
 - Check that the purchase order lines have the received field set to zero and
   it is not editable

opw-3006951

closes odoo/odoo#121549

X-original-commit: cedd0603a24aa0c0e6716c2e0f49e89c870eae04
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: De Caluwé Tom (tdc) <tdc@odoo.com>
Co-authored-by: Pedro Manuel Calheiros Lima de Sousa (peso) <peso@odoo.com>
2023-05-16 18:08:10 +02:00
Pierre Paridans eef262abf4 [FIX] *: adapt QUnit tests and tours
[FIX] *: selectors in tours

[FIX][TMP] account: CogMenu selector in tours

[FIX][TMP] web*: Breadcrumb targetting in tours

Adds a `o_breadcrumb` class to target the whole breadcrumb, no matter
how much elements it contains (collapsed parts, visible path, single
name...).

add classname on last breadcrumb item

[FIX][TMP] project: View buttons selector in tours (moved away from CP)

[FIX][TMP] project: Kanban selectors in tours (quick create)

[FIX][TMP] *: SearchBar selectors in tours (toggle menu)

[FIX][TMP] *: ButtonBox selector in tours

[WIP][IMP] web: add toggleSearchBarMenu in search helpers

adapt and unskip 3 list tests

adapt and unskip calendar tests

unskip web_tour test that actually pass

post rebase fix

allow to lose cell focus after multi edition (given to searchbar) - bug reported, to check later

post rebase fixes

fix

Part-of: odoo/odoo#116641
2023-05-12 22:59:22 +02:00
Mahamadasif Ansari 212adc34ee [FIX] account_stock, purchase_stock: prevent AttributeError when confirm vendor BILL/refund with FIFO/AVCO
AttributeError "account.move.line" object has no attribute "purchase_line_id"
occurs in `stock_account` when we confirm vendor BILL or REFUND with product
costing method "first in first out" or "average cost".

With the recent reflacted changes in commit[1], the `purchase_line_id`
field is used and it belongs to `purchase`, but it is not installed and does
not depend, so it causes an error.

The above issue is solved by removing some code in commit[1] from
`stock_account` and adding it to `purchase_stock`.

committ[1] - https://github.com/odoo/odoo/pull/99411/commits/e9ce88a9372843abef7cf8fc94c4dbe5f16c5fa3#diff-e6134a1a5a13058e35f86426a96db0acac44553fa3b0ca26716390f7b19fc96cR318

sentry-3975529425

closes odoo/odoo#121070

X-original-commit: 23ba3c6684e388bcfe317e7ab9f4c9008622e2b4
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Ansari Mahamadasif (maan) <maan@odoo.com>
2023-05-11 12:01:55 +02:00
Rahul Reddiar 9e1232b4a2 [IMP] purchase_stock: added buyer field in partner form view
Currently, automatically PO is generated in that PO buyer field is empty.

So in this commit, we added buyer field in partner form view, when rfq is
generated automatically and vendor has a specific buyer then at creation
of rfq, the PO buyer field will be set according to that.

TaskID - 3151213

closes odoo/odoo#113709

Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2023-05-09 19:26:48 +02:00
Jonathan Castillo (jcs) c8a5d8e993 [FIX] purchase_stock: update documentation link
This commit updates the documentation link in the settings tooltip, as
introduced by the documentation PR
https://github.com/odoo/documentation/pull/3762/
A redirection rule is added in that doc PR to act as a fallback.

closes odoo/odoo#120535

Related: odoo/documentation#4336
Signed-off-by: Tiffany Chang <tic@odoo.com>
2023-05-04 21:32:27 +02:00
Touati Djamel (otd) 5968480dfa [FIX] stock: apply only quant with inventory quantity set
Steps to reproduce the bug:
- Create a storable product “P1”
- Create a purchase order with 3 unit of “P1”
- Confirm the PO and receive the delivery
- Go to inventory > operation > Inventory Adjustments
- Select the “quant” of “P1”:
    - quantity = 3
    - inventory_quantity = 0
- Click on “Apply”
- Apply the wizard

Problem:
The quantity is updated to 0

When the `_apply_inventory` function is called, a move is created and
validated to ensure that the quantity matches its corresponding
`inventory_quantity`:
https://github.com/odoo/odoo/blob/15.0/addons/stock/models/stock_quant.py#L606-L611

`inventory_diff_quantity` is equal to -3 in this case, since it's the
result of computing `inventory_quantity` - `quantity`, which is (0 - 3).
Since we add a minus sign to `inventory_diff_quantity`, the final result
becomes `3`.

Afterward, we call the `_update_available_quantity` function with a
minus sign as well, so the value becomes -3:
https://github.com/odoo/odoo/blob/e1cea2640fc064a56b0dba4f79e6b8a91a48b4fc/addons/stock/models/stock_move_line.py#L307

As a result, when we add `quant.quantity`, which is 3, the final result
becomes 0 (3 - 3):
https://github.com/odoo/odoo/blob/9d34c72b2c7bc187c5aac771e9e8cbddd7ead5f2/addons/stock/models/stock_quant.py#L635

Solution:
If no inventory_quantity set, ignore the apply of inventory for this
quant.

opw-3268542

closes odoo/odoo#119867

X-original-commit: 4bedeb514652f5f4a9fd8fa0914d07c8ccba3952
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-04-27 07:06:15 +02:00
Touati Djamel (otd) eac9a940a1 [FIX] purchase_stock: update po_line without purchase access right
Steps to reproduce the bug:
- Create a Storable Product “P1”:
    - Route: buy
    - Reorder Rules: Min 5, Max 0
- Set up a user with only Inventory / User Access Rights
- Using INV User, create a Delivery Order (Delivery 1) so the amount
 of Product On Hand is below the Reorder Rule Minimum
 --> this will genreate a PO created by Odoo bot

- Using the same INV User, create a new Delivery Order (Delivery 2)
so that the amount purchased on the PO will need to be changed

Problem:
This is done by the user who created the need and not Odoo bot and
as the INV User does not have Access Rights to edit Purchase Order
Lines, an Access Error is triggered.

opw-3255007

closes odoo/odoo#119866

X-original-commit: 32c48924e5045b2cad4f6fda2f0222be0683c22a
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-04-27 07:06:13 +02:00
Touati Djamel (otd) 3c3c856c2b [FIX] mrp, purchase{stock,mrp}: use route set on product in orderpoint
Steps to reproduce the bug:
- Install purchase, then mrp (in this order)
- Create a storable product “P1”
    - route: buy
    - Add a supplier
    - Add a BoM
- Create a delivery for the product “P1”
- A need is created
- Go to inventory > operation > replenishment

Problem:
An orderpoint is created with the preferred route: Manufacture instead
of buy

As the "Purchase" module was installed first, the override of
the `_set_default_route_id` function will be triggered first, the 'buy'
route will be set in the created order point because the product has a
supplier. Then, the function in the MRP module will be triggered and
since the product has a BoM, the 'buy' route will be replaced by
"Manufacture".

opw-3228971

closes odoo/odoo#119172

X-original-commit: 227d038efbadf25e3a7be7cceedd9159b71162a3
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-04-20 14:10:27 +02:00
Arnold Moyaux e1e8f33ca9 [FIX] purchase_stock: wrong supplier from orderpoint:
Use case to reproduce:
- Set "receive good in input and then stock" on the warehouse.
- Set two suppliers on a product. one from a partner (higher priority)
  and one from a child partner (lower priority).
- Set the child partner as the vendor on the replenishment report.
- Order a replenishment for the product.

It happens due to an hack that use a field on `stock.move` in order
to temporaly store the partner among the moves until the RFQ.
But this field is a many2one on `res.partner` model and not on
`product.supplierinfo`

`_run_buy` receive a partner and still use `_select_seller` with the
partner in order to find the best pricelist. But it won't use the
specific supplier price list set on the orderpoint.

In order to fix, we don't store anymore the price list partner on the
intermediate move. In run_buy we receive the orderpoint if it's the
origin of the procurement. On the orderpoint the supplierinfo is set.
So we take it from there.

opw-3180945

closes odoo/odoo#119063

X-original-commit: 3cd5b9b7688ef7e6c6fa4fce1c0ad319fb577745
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-04-20 11:57:36 +02:00
Rémy Voet (ryv) 687d0ed285 [IMP] *: change the override of read_group
The new backend version of read_group can simplify the
current overrides of read_group. Do it for each of them and
avoid making extra search (done with __domain) when it is possible.

Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Touati Djamel (otd) 9db41eda8f [FIX] purchase_stock: don't set effective_date only for return pickings
Steps to reproduce the bug:
- Create a storable product “P1”:
    - route: dropship

- Create a purchase order:
    - customer: Azure interior
    - Deliver to: Dropship
    - Dropship Address: any address
    - Receipt Date: Tomorrow
    - Product: “P1”

- Conform the Picking
- Go to the dropship transfer:
    - Validate the picking

- Go to the Scheduled Action > Purchase reminder
- Run Manually

Problem:
The reminder email for the delivery is sent While the picking is in the
'done' status.

When we run the Scheduled action, the `_send_reminder_mail` function is
triggered in which we get the orders with the `_get_orders_to_remind`
function but we filter the purchase orders which have an "effective_date"
already set:
https://github.com/odoo/odoo/blob/181c7d82e30d0848bbac7f7d0188e81aced0af07/addons/purchase_stock/models/purchase.py#L279

but as in drop-shipping, the dest location is customer and the
"effective_date" is not set:
https://github.com/odoo/odoo/blob/16.0/addons/purchase_stock/models/purchase.py#L53

opw-3246218

closes odoo/odoo#118507

X-original-commit: 1495b54aa452498c79f4178c2e38426b1b423e66
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-04-13 19:27:49 +02:00
Walid HANNICHE (waha) 82787d2b98 [FIX] purchase_stock: units rounding
Steps to reproduce:
1-create a weight unit 'jm' bigger than reference
    ratio 2.47541 rounding 0.001
2-create a stored product uom:'jm' / purchase_uom: 'kg'
3-set valuation method to automated (fifo)
4-create a replenishement for 200 (jm)
5-confirm and recieve the products
6-valuation for that stock move is null

Bug:
computations in the stock module are done with rounding method (half-up)
when computing the unit price the recieved quantity is computed with up
rounding which leads to a mismatch

Fix:
applied the same rounding method on all the Steps

opw-3213997

closes odoo/odoo#118251

X-original-commit: c305942958c73414def47ebd299227999841c6ed
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Walid Hanniche (waha) <waha@odoo.com>
2023-04-11 18:49:46 +02:00
Michael (mcm) ff0d6dd580 [REF] *: replace odoo module by native one
This commit converts almost all odoo module by native module.
The goal is to deprecate odoo.define in favor of native module and then
simplify boot.js by removing the regexp that finds module dependencies.

task id: 3162300

closes odoo/odoo#117305

Related: odoo/enterprise#39118
Signed-off-by: Géry Debongnie <ged@odoo.com>
2023-04-03 17:07:24 +02:00
David (dafr) f9f4190e53 [FIX] purchase_stock: Prevent picking update when product_qty isn't updated
_create_or_update_picking() is a time-consuming method.
On some Purchase, all the purchase.order.line may be written with 'product_qty' in 'values', even though it did not change.

OPW-2978569

closes odoo/odoo#117387

X-original-commit: 5575fe2dedfae2e9d558ca29884d2ebead3c8bbe
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: David <dafr@odoo.com>
2023-04-03 14:56:39 +02:00
Karl Southern 5d40181178 [FIX] purchase_stock: does not use company currency when writing the price_unit
When editing a purchase order line which is not in the company currency
the price_unit on the stock.move is overwritten with the price_unit in
the currency of the purchase order.

Secondary issue this causes is that if any further quantity changes
occur on a purchase.order, any new stock.moves may not be merged. If the
quantity is reduced this results in a negative stock.move quantity which
Odoo helpfully inverses the location and destination locations.

closes odoo/odoo#116620

X-original-commit: e7dfe10c81e69e3eb82b209db25483f29eb557e6
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-03-27 11:43:09 +02:00
Arnold Moyaux fde450b599 [FIX] stock_account: reconcile kit
Kit were not reconcile because the `_stock_account_anglo_saxon_reconcile_valuation`
method try to match `account.move.line` and `stock.move` base on the
product field. However in kit case, the moves are exploded in mutliple
moves containing the kit's components. Due to that the matching is not
made.

To fix this issue we use the `purchase.order.line` that is share between
the `stock.move` and `account.move.line` to retrieve them.

closes odoo/odoo#114987

X-original-commit: f594c837c8a347abb48015d4e9bb0d5109228539
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-03-13 10:53:04 +01:00
Victor Piryns (pivi) b896b35dd2 [FIX] {sale,purchase}_stock: propagate package type to stock moves
Current behaviour:
If you have a confirmed SO, with a `sale.order.line` that has a
`product_packaging_id`, and you write a new `product_packaging_id`,
the "Delivery Order" has 2 lines, 1 move with the old qty and the old
packaging, and another line with the difference of qty and the new packaging.
Same behaviour is present on purchase side.

Expected behaviour:
If you have multiple `stock.move.line` from the same `sale.order.line`,
they should be able to merge, when you changed the `product_packaging_id`.
Ex: If you edit an SOL from 1 pack of 10 to 1 pack of 20, we should have
1 move line with qty 20 in packs of 20, instead of 2 lines, one with qty 10
in packs of 10, and another line with qty 10 in packs of 20.
Same behaviour is expected on purchase side.

Steps to reproduce:
- Install Sales and Inventory
- Activate "Product Packaging" in Settings
- Create a new product with 2 types of packaging
  - PackOf10 with quantity of 10
  - PackOf20 with quantity of 20
- Create a SO with a new line that product, quantity 10
- Confirm the SO
- Edit the SOL with 1 pack of 20 (`product_uom_qty`=20)
- The "Delivery Order" has 2 lines, instead of 1 with the new packaging

Reason for the problem:
When saving the SO/PO, a new `procurement` is created which will create
a new `stock.move.line` with the new packaging. This will prevent the
lines to merge correctly, because they have different packaging.

Fix:
When writing the `product_packaging_id` on a `sale.order.line`/`purchase.order.line`,
we directly write the package on the `stock.move.line`,
before any `procurements` are created, so the generate move lines
can correctly be merged.

Affected versions:
- 15.0
- saas-15.2
- saas-15.3
- 16.0
- master

opw-3002612

closes odoo/odoo#114866

X-original-commit: 87ed4b2f6c9c36202a1a4f3de143f638cf38d047
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
2023-03-10 08:17:08 +01:00
Laurent Smet bce02f46d3 [IMP] account: Improve perf of reconciliation
Allow to perform multiple reconciliation at once in order to:
- ...batch the creation of records as much as possible.
Creating an account.partial.reconcile force the orm to search for amls in order to invalidate the reconciliation fields like amount_residual/amount_residual_currency.
- ...reduce the number of flush inside the orm and batch the compute.
Each call to reconcile is looking for the payment's state of invoices before/after the reconciliation.
This step is costly because this will flush all the reconciliation data and then call the computes to get the fresh value of payment_state.
- ...modify more easily the way the lines are matched together.
Before this commit, the lines were split into two batches sorted by some criteria including the currency: debit and credit.
Then, we were matching them together sequentially.
Now, we make the same things except we do that first for each batch of amls sharing the same currency in order to reduce the number of cross-currencies reconciliation.
- ...allow the orm to prefetch all the partials in the reconciliation chain all at once.
The full reconcile needs to be creating on the full reconciliation graph starting on the current amls so we need to travel the matched_debit_ids/matched_credit_ids in order to find all the involved amls.
Fetching all this data at once is also reducing the number of queries made by the orm.

Let's take an example:
Suppose 10 amls: a1, a2, ..., a10
Suppose 10 amls: b1, b2, ..., b10
You want to reconcile respectively a1 with b1, ... , a10 with b10.

Before this commit, each reconciliation was done as follow:
- Check the payment_state of invoice (on 2 amls)
- Create a partial reconcile (single record)
- Create a full reconcile (single record)
- Compute the reconciliation data to compute payment_state (on 2 amls)
All of that, 10 times sequentially.

With the new '_reconcile_plan' method, we are able to give a list of recordset [a1 + b1, ..., a10 + b10]:
- Check the payment_state of invoice (on 20 amls)
- Create a partial reconcile (10 records)
- Create a full reconcile (10 records)
- Compute the reconciliation data to compute payment_state (on 20 amls)

For a reconciliation using 2000 records (a1, ..., a1000 & b1, ..., b1000), the time to reconcile it was about +-34 seconds. Now, it's about +- 3 seconds.

closes odoo/odoo#113680

Related: odoo/enterprise#37543
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-03-07 12:24:53 +01:00
Yolann Sabaux c823f477aa [FIX] stock_account: prevent reconcile move_lines in draft
Steps to reproduce:
- create two storable products (Great Product - Super Product) - automated avco
- create rfq with the two products - confirm -receive products
- create Bill - set qty of one Great Product to 0 -> save
- create bill for the Great Product - confirm

Issue:
User Error You can only reconcile posted entries

Cause:

`_get_all_related_aml()` fetches all aml related to the `stock_moves` with the product in the bill we want to post.
It retrieves the aml of the bill in which we have put the product quantity to 0 but that it is still in draft.
And we try to reconcile this draft move_line in
https://github.com/odoo/odoo/blob/d0fdc38385f5f259da259d21e9137494e6d7c17d/addons/account/models/account_move_line.py#L2308

Solution:
filter the `product_account_moves(_lines)` so we don't take into account moves that are still in draft

opw-3180209

closes odoo/odoo#114328

X-original-commit: b1a74a1841c05e4e37643e17f6b97dfff11555cd
Signed-off-by: Adrien Widart <awt@odoo.com>
2023-03-03 17:05:43 +01:00
Adrien Widart (awt) ff75b9d4f4 [FIX] purchase_stock: add POL to existing PO if draft
To reproduce the issue:
1. In Settings:
   - Days to Purchase: 10
2. Create two products P01, P02:
   - Storable
   - With the same seller
     - Delivery Lead Time: 1.0
3. On replenishment page, create a new line:
   - Product: P01
   - Min Qty: 1.0
4. Order once
   - a RfQ is created and the order deadline is in ten days
5. Time travel to the next day
6. Repeat steps 3-4 with P02

Error: a second RfQ has been generated. However, as the first one is
still in draft state, the POL of P02 should be added to that first RfQ

When processing the orderpoint of P02, at some point, we try to find
an existing RfQ with its order deadline equal to `today + 10 days`.
Since we are the next day (step 5), the order deadline of the first
RfQ is `today + 9 days`, so we don't find it.

OPW-3047931

closes odoo/odoo#113982

X-original-commit: 8bf7f9038915be520488b2602c20929ca115a033
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2023-03-01 23:28:10 +01:00
Arnold Moyaux a022fefbaf [FIX] purchase, purchase_stock: add price difference account
Version 16.0 removed the price different account following this pull request #99411

This decision has been made because it was only used anymore by standard cost method and real time valuation.
We thought that standard was not a valid accounting method and we didn't want to maintain code for it.

But:
- Standard could be valid if you manualy complete the accounting entries
by yourself (e.g. employees/machines cost in mrp).
- It's also valid if you record the difference between standard price and
vendo price (price diff)

If you want to have an estimation of your cogs (benefits and loss) during an
accounting period. People just do a manual correction at the end but they have
a real time reporting on the situation.

It's a too big regression to be acceptable. We apologize and reintroduce it for
16.0 and future version.

This PR reintroduce the fields in purchase and the fix module in 16.0 is
not needed anymore.

closes odoo/odoo#109924

Related: odoo/upgrade#4315
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-02-13 15:15:34 +01:00
svs-odoo 4dd3104b96 [IMP] product_expiry,purchase_requisition,stock*: visual changes
- The `picking_type_id` field in the pickings form view is not openable;

- Display the `description` field (optional) in the SVL list view;

- Add the `expiration_date` field (optional) in the quant list views;

- Add a description text for the landed cost;

- Renames field `requisition_id`: "Purchase Agreement" > "Blanket Order"

- In Inventory Adjustment, hides the "Apply All" button is at least one
  record is selected;

- In `product_expiry`, renames two views to stick to the XML's coding
  guidelines: https://www.odoo.com/documentation/16.0/contributing/development/coding_guidelines.html#xml-ids-and-naming

- For the replenishment:
  - Places the field `product_id` as the first option when the user
    writes something in the searchbar;
  - Renames `route_id`: "Preferred Route" > "Route";
  - Renames the button "Automate Orders" into "Automate";
  - Set the `route_id` field as "optional=hide" until `mrp_purchase` is
    installed (in this case, it will be set as "optional=show") because
    in this case, there is at least two routes (Buy and Manufacturing).

task-3076044

Part-of: odoo/odoo#109511
2023-02-13 15:15:06 +01:00
Touati Djamel (otd) 7f0a084243 [FIX] stock, purchase_stock: apply putaway strategy even if no package
Steps to reproduce the bug:
- Enable “Storage location” option
- Create a storable product “P1”
- Create a putaway rule:
    - When in: WH/Stock
    - Store to: WH/Stock/shelf1
    - product: P1
- Go to operation types -> “Receipts orders”
    - Enable “Show Detailed operations” and
    “Pre-fill detailed operations”
- Create a purchase order:
     - Add 2unit of “P1”
     - Confirm the PO
- Go to the receipt:
     - the destination location is correctly set “WH/stock/shelf1”
     - set the qty done to 1
     - validate the delivery and create a back order

Problem:
The destination location is “WH/Stock” instead of “WH/stock/shelf1”
because the ```_apply_putaway_strategy``` function is not called on
the ```stock.move.line``` when there is no package

opw-3162934

closes odoo/odoo#112400

X-original-commit: b4c83ab2b202702e096c775ae73f4646ba93eae4
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-02-13 11:29:52 +01:00
Arnold Moyaux c68a159884 [FIX] stock,purchase,mrp: accumulative security days
Usecase to reproduce:
- Set the warehouse as 3 steps receipt
- Put a security delay of 3 days for purchase
- Set a product with a vendor and 1 days as LT
- Replenish with the orderpoint

You expect to have a schedule date for tomorrow that contains all the
product needed in the incoming 4 days.

Currenly the internal transfer from QC -> Stock is for tomorrow (ok).
The transfer from Inpur -> QC is plan for 2 days in the past. (not ok)
The PO date is plan for 5 days in the past. (not ok)

It happens because the system check at each `stock.rule` application if
purchase is part of the route. If it's then it applies the security lead
time. It's a mistake because we should apply it only the first time.

To fix it we directly set it when the orderpoint run and not during
`stock.move` creation.
However for MTO it's not that easy. We don't want to deliver too
early the customer. So we keep applying the delay during the
`stock.move` creation but only when it goes under the warehouse stock
location.

X-original-commit: 97f52bd40d97109a7983549d252476959ddceada
Part-of: odoo/odoo#112325
2023-02-09 20:03:59 +01:00
Mathias Mathy (MAMA) 0a43740481 [REF] Stock: report_stock_forecasted to owl
Refactoring of report_stock_forecasted to owl
Since it wasn't really a report (no print action),
it changed from a report to a client action.
Task: 2885757
See Upgrade : odoo/upgrade#3926
See Enterprise : odoo/enterprise#32116

closes odoo/odoo#101247

Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-02-06 14:16:26 +01:00
Touati Djamel (otd) c9f62d0b8b [FIX] purchase_stock: compare the quantities with float_compare
Steps to reproduce the bug:
- Create a storable product “P1”
- Create a PO with 7000 unit of P1
    - Receive for example “3,483.43”
    - Create a backorder
- Create a bill for received product
- Try to confirm the second picking

Problem:
Traceback is triggered, because the reaming quantity is 0 and we use it
in the division:

https://github.com/odoo/odoo/blob/16.0/addons/purchase_stock/models/stock_move.py#L57

In this use case we compare “3483.43” and ”3483.4300000003” but in fact
`”line.qty_invoiced == received_qyt”` so we should not go through this
part of the code:
https://github.com/odoo/odoo/blob/16.0/addons/purchase_stock/models/stock_move.py#L40

So as we used `float_round` in the calculation of `qty_invoiced`, we
have to use `float_compare` when comparing it with another value

https://github.com/odoo/odoo/blob/383947646f5652804bd6bbc764380a890e6f4a8d/addons/stock/models/stock_move.py#L1168

opw-3162603

closes odoo/odoo#111840

X-original-commit: 5899abdea4a622d11f0e7472b489616e08b74523
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2023-02-03 16:32:18 +01:00
Denis Ledoux b4a7996e96 [IMP] base, *: change the API of init hooks to pass env
This is mostly a cleaning/refactoring change.

The current API for init hooks (pre, post, uninstall) is to pass
`cr, registry`.
But the first thing which was done by most
post init and uninstall hooks was to create an env using
the cr passed
e.g.
`env = api.Environment(cr, SUPERUSER_ID, {})`
and the `registry` argument was unused in all these hooks,
completely.

By changing the API of hooks to pass `env` instead
of `cr, registry`, we gain in average two lines in every
hooks:
- the line creating the env `env = api.Environment(cr, SUPERUSER_ID, {})`
- the line importing `api` and `SUPERUSER_ID`

Therefore removing ~250 lines of repeated code lines accross odoo/odoo and
odoo/enterprise.
In addition to these lines removed,
it also ease the API of init hooks for Odoo developers,
who are used to that `env` and not so much how to create an `env`
from a cursor.

Part-of: odoo/odoo#108254
2023-02-01 10:25:01 +01:00
Andrea Grazioso (agr-odoo) a660e8ab3e [FIX] purchase_stock: price difference currency conversion date
Have a product P configured with:
* Product Type: Storable Product
* Product category:
    * costing method: standard
    * Inventory Valuation Automated
    * Price Difference Account: "500000 Cost of Goods Sold"
* Cost $100

Activate Multicurrency:
* USD main currency, CZK foreign currency
* On CZK set the rates
    * date1, Unit per USD: 30
    * date2, Unit per USD: 25 (date2 > date1)
    * date3, Unit per USD: 26 (date3 > date2)

Create a purchase order:
* Date: date2
* Currency: CZK
* Order line:
    * Product P
    * Quantity 10
    * Unit price 3000
Confirm, receive product on date2 (svl needs to be in date2)
Create the vendor bill with:
* Bill date: date 1
* Accounting date: date 3
Confirm the bill

Issue

Check the bill journal items. Price difference account is debited with 4000 czk.
This amount is not correct.
The valuation layer price unit is 100$
At the receipt date the price unit should be 2500czk
The price unit difference 3000-2500 = 500czk
Price difference 500*10 = 5000czk
The issue occur because the price difference unit is converted at bill
accounting date, resulting in 4000czk

opw-3063809

closes odoo/odoo#111199

X-original-commit: bbc0b003f6ff08a50196e07b66083ee7e8896150
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2023-01-27 14:03:32 +01:00
Arnold Moyaux 607824fa50 [FIX] purchase_stock: cogs without stock.move
Usecase to reproduce:
- Create a product with real time valuation and AVCO or FIFO
- Create an invoice for this product without stock.move
- Validate the invoice

Traceback

It happens because it tries to check if there is a difference between
the invoice line value and the value of associated stock.move. However
in this case there is no purchase line to do the link.

Since we can't associate a picking to an invoice line magicaly. We skip
this part and let the user do his own journal entries

closes odoo/odoo#110906

X-original-commit: 8ea41cba3911fb8bcc351a4c53d2aa6c5bf7bdde
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2023-01-25 12:24:52 +01:00
Arnold Moyaux 6877473e22 [FIX] purchase_stock: wrong deadline
Usecase to reproduce:
- Product A with Vendor supplier lead time=1day
- Product B with same Vendor supplier lead time=4days
- Launch the replenishment report for both products at the same time

Current Behavior:
The expected arrival is correct but the order date deadline is today - 3
days

Wanted Behavior:
Same but the order date dead line is today

It happens because it does the minimum of expected arrivals - max of
supplier delays. However the supplier delays are already correctly
apply on each procurement (correct expected arrival). To know the
correct order deadline we should instead take the minimum date planned
with the related supplier delay.

opw-2822588

closes odoo/odoo#110779

X-original-commit: 9364f4fbc3966373a33c32b1325b3b22cc6c5f2e
Signed-off-by: Arnold Moyaux (arm) <arm@odoo.com>
2023-01-24 10:20:36 +01:00