Commit Graph
1736 Commits
Author SHA1 Message Date
Yenthe Van Ginneken 11e17dc11b [FIX] stock_account: always use first move
Before this commit it is technically possible for "return_picking_line" to be a recordset instead of a record.
By taking the first element ([0]) we're sure it is always a record instead of a recordset to work with.

closes odoo/odoo#82578

X-original-commit: 705e60a9531fe0b042fd32a5dfc934bede15558c
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2022-01-11 17:08:54 +00:00
Touati Djamel (otd) bc6a92d0c9 [FIX] stock_account: fix user group check
Steps to reproduce the bug:
- Connect as Admin
- install stock_account
- Go to inventory > Product Variants > choose any product > click on the FORECAST button
- Traceback

Problem:
docs['product_templates'] can be False, so we can't use it to check the user's group: https://github.com/odoo/odoo/blob/15.0/addons/stock/report/report_stock_forecasted.py#L98

Opw-2728473

closes odoo/odoo#82352

X-original-commit: 227a639b34fc5121d135346a158ab17486a53d40
Signed-off-by: Arnold Moyaux <arm@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>
2022-01-06 19:31:00 +00:00
Arnold Moyaux 2d1f56381a [FIX] stock(_account): traceback with stock user on forecast report
2 issues:
- When going to the report forecast the value of the stock is computed.
However the stock user should not be able to access the valuations
- Since an access error is return the graph view is not instanciate and
the javascript code try to amend an empty result to the DOM. It results
with a traceback on top of 403 page

closes odoo/odoo#82074

X-original-commit: dbc6b1999ad478d0fdb5774624fd50ca4018be22
Related: odoo/enterprise#23185
Signed-off-by: Arnold Moyaux <arm@odoo.com>
2022-01-03 10:52:45 +00:00
Brice bib Bartoletti 078981a4c6 [FIX] stock_account:make cogs multi_company safe
The aim of this commit is to make the cogs generation multi-company
safe.

2 bugs are fixed in this forwardport commit:
- The product.valuation on the line wasn't evaluated in a company safe
way.
- cogs method weren't company safe either

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.

- If company B's product isn't in real time valuation, cogs aren't even
created.

After this commit:
Whatever the selected companies are, the cost selected will always be from
the company that created the invoice.

closes odoo/odoo#81492

Task: #2686104 and #2713607
X-original-commit: e34caf0ec33a3001bb6343e02d34a6edb5a9f609
Signed-off-by: Laurent Smet <las@odoo.com>
Signed-off-by: Brice Bartoletti <bib@odoo.com>
2021-12-15 22:31:24 +00:00
William Henrotin 56e7bcf0cb [REF] *{stock,mrp}*: rename reserved fields
This commit rename product_uom_qty into reserved_uom_qty and product_qty
into reserved_qty on stock move line to stop mistake them with the stock
move quantities fields.

Task: 2648449
Part-of: odoo/odoo#80434
2021-12-07 16:20:06 +00:00
Adrien Widart dc54341dc0 [FIX] mrp_subcontracting_account: always return PU of subcontracted SM
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#80889

X-original-commit: 0567536f8b66c71f6860041926542f88026793b1
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
2021-12-06 10:34:45 +00:00
David (dafr) 5978bb3380 [FIX] stock_account: fix multi-company stock.quant value
On Fifo costing method, the 'value' field of a stock quant was computed using quantity_svl and value_svl of the product_id.
However the method 'with_company()' wasn't used for quantity_svl, resulting in an incorrect 'value' field of stock.quant

This commit add the use of 'with_company()' method to get quantity_svl.

OPW-2652211

closes odoo/odoo#79844

X-original-commit: 0a7709611fbbc983fc5db5dd36ab7716e543bc0f
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2021-11-16 13:03:25 +00:00
William Henrotin 3a1473c75c [REF] *stock*: rename move_lines into move_ids in stock.picking
closes odoo/odoo#78732

Task: 2673000
Related: odoo/enterprise#21815
Related: odoo/upgrade#2956
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
2021-10-27 15:48:51 +00:00
Aurélien (avd) a0ea00c8dd [FIX] stock_valuation_layer: auto_join product_id to avoid bloating queries
The active field of stock_valuation_layer is related to product_id.active.
Adding auto_join = True avoids bloating search/read_group queries in
expression.parse().

closes odoo/odoo#69207

X-original-commit: 2526c640969f462c18ab8a3da7aa0a4e8ed871f8
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2021-10-21 15:47:00 +00:00
Rémy Voet (ryv) b33983d532 [REF] stock*,mrp*: clean setUp vs setUpClass
In a lot of test class, we use `setUp` instead of
`setUpClass`. `setUp` is execute for each test method and `setUpClass`
will be execute only once by Class (and use savepoint + rollback).

Then change setUp into setUpClass reduce the time to make all tests
and avoid to repeat this error for the future.

closes odoo/odoo#78082

Related: odoo/enterprise#21563
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-10-13 18:24:16 +00:00
wan 9b0baa3aa4 [FIX] *: product back2basics post-freeze fixes
This should have been a fixup of 37eb0dfbb54db1c062276cd8c172bf8dac9e557b but we needed
to freeze 🤷‍♂️

closes odoo/odoo#77344

closes odoo/odoo#77876

Related: odoo/enterprise#21425
Related: odoo/enterprise#21467
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
Signed-off-by: William André (wan) <wan@odoo.com>
2021-10-11 10:15:49 +00:00
Victor Feyens ab022ec12d [FIX] *: target v15.0 documentation with doc links
X-original-commit: acc95ec204baa1dddbe292c379a1768fe1deccbf
Part-of: odoo/odoo#77923
2021-10-07 17:59:52 +00:00
Adrien Widart c31ca41c60 [FIX] sale_stock,stock_account: ignore SVL without any qty
In some conditions, confirming an invoice will raise an Odoo Server
Error due to a division by zero.

To reproduce the issue:
(Need sale_management)
1. Create a product category PC:
    - Costing Method: Average Cost (AVCO)
    - Inventory Valuation: Automated
2. Create a product P:
    - Product Type: Storable
    - Category: PC
    - Cost: 50
3. Create a sale order SO:
    - 5 x P
4. Confirm and process the delivery D
5. Edit P:
    - Cost: 40
6. Open D and create a return R:
    - 1 x P without "Update quantities on SO/PO"
7. Process R
8. In Inventory, create a transfer T:
    - Operation Type: Receipt
    - 1 x P
9. Process T
10. Back to SO, create an invoice and post it

Error: an Odoo Server Error is raised: "ZeroDivisionError: float
division by zero"

When validating the transfer T, a stock valuation layer is created with
a zero quantity and is linked to the first SO.order_line.move_ids (i.e.,
the SM from Stock to Customer with 5 x P)
https://github.com/odoo/odoo/blob/dfab388fdf8c7597774ff1738a1b09295c12fb49/addons/stock_account/models/product.py#L439-L450

Then, when posting the invoice, this SVL is used to make a division:
https://github.com/odoo/odoo/blob/dfab388fdf8c7597774ff1738a1b09295c12fb49/addons/stock_account/models/product.py#L690-L691

In such cases, we should ignore this SVL and use the standard price:
https://github.com/odoo/odoo/blob/dfab388fdf8c7597774ff1738a1b09295c12fb49/addons/stock_account/models/product.py#L695-L699

OPW-2647921
OPW-2646419

closes odoo/odoo#77909

X-original-commit: d5eccda583e28a15e8a74a4e82f9e76ec32d0806
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-10-06 07:03:54 +00:00
Tiffany Chang (tic) b0231630bd [FIX] mrp{_account}, stock_account: fix some UX
- update MO list status colors: draft = blue, in progress = yellow +
  make the WO status colors match (waiting = blue, in progress = yellow)
  and make draft MO lines all blue (to follow current design standard)
- cleanup Activity in tree view (no label in tree + "Next Activity" in
  column selection dropdown)
- make units of analytic accounting for WO = hours
- make quantity for move_raw_ids products (i.e. components for MOs)
  always have positive analytic_account_line.unit_amount (i.e. when
  changing a done move's quantity + changing a quantity twice made this
  value negative)
- make "Copy Operations" on BOM open the list view in "current" instead
  of "new" due to lack of hook to prevent form view (i.e. open BoM in
  current view) changing when clicking on lines in the new window's
  operations (also ends up being a better UX anyways since being able to
  view the operations form view is desired).

Task: 2648460
X-original-commit: 65a2d478197f5b856212225319500ca61b161809
Part-of: odoo/odoo#77897
2021-10-05 16:54:17 +00:00
Martin Trigaux ef8ad324b0 [I18N] *: export 15.0 source terms
closes odoo/odoo#76542

X-original-commit: 63e6807437295519a0f4705fb88644d6d557ca3a
Related: odoo/enterprise#20882
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-09-16 07:17:40 +00:00
Anh Thao Pham (pta) 568dd76786 [FIX] stock_account: fix access error when computing average price
- Create a product with Category configured with:
  * Costing Method: First In First Out (FIFO)
  * Inventory Valuation: Automated
- Create a PO to buy 1 unit and receive the product
- Create a SO to sell 1 unit and deliver the product
- Return the product
- Re-deliver the product
- Create invoice for SO but don't post it
- Connect with an user with "Accounting: Accountant" rights only
- Post the invoice
An access error will be triggered when trying to access stock valuation layer.

opw-2623376

closes odoo/odoo#76289

X-original-commit: cc76e76ef2d1cc5a16778bd9440911fd6ec73c9b
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
2021-09-10 05:25:53 +00:00
oco-odoo 5419fe445d [IMP] account: allow instantiating taxes from foreign charts of accounts
In multivat setup, we need to create taxes in foreign countries to map them with domestic taxes. Before this commit, this was only possible manually, even though all the necessary information lies in Odoo's account.tax.template objects created by l10n modules.

We now display a banner on top of foreign vat fiscal positions with a button allowing instantiating those templates directly from them when it's appropriate.

closes odoo/odoo#75803

Task: 2453325
Related: odoo/enterprise#20553
Signed-off-by: Quentin De Paoli (qdp) <qdp@openerp.com>
2021-09-03 02:03:43 +00:00
clesgow 79804719fe [FIX] stock_account: product_category_form inherit
Directly inheriting stock.product_category_form_view_inherit would raise
an error as group "account_property" wouldn't yet exist in the inherited
record.

Fixes 61d937f7d6

closes odoo/odoo#75822

Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-09-01 09:38:58 +00:00
Quentin Wolfs 61d937f7d6 [IMP] stock: regroup info in product_category form
The 'Logistics' and 'Inventory Valuation' blocs should be regrouped into
two columns on the product_category form

Task-2428819

Part-of: odoo/odoo#74364
2021-08-31 23:35:17 +00:00
JordiMForgeFlow 0b07210fe1 [FIX] stock_account: force company when getting computed account for move line
The parent method _get_computed_account in the account module it already forces
the company to get the correct account, but in the stock_account module the method
is overriden when dealing with anglo-saxon accounting. In the latter, the company
is not being forced, so it leads to multi-company errors.

The fix simply enforces the correct company to prevent the error.

closes odoo/odoo#75747

X-original-commit: beba7c5b377e5aaf5ccb1d52e6b8c3bcf49468d3
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-08-31 02:33:40 +00:00
yhu-odoo edacd76e21 [IMP] mrp_account: analytic accounting on MO
Add analytic accounting for MO.

Post expense entries for:
  1. raw material cost (change with consumed)
  2. work center cost (change with real duration on work order)

Task-2469742
PR #68708
2021-08-27 16:40:49 +00:00
Habib (ayh) 44029495bc [IMP] base, account, *: simplify multi currency setup
Automatically activate `group_multi_currency` if there is more than one active currency,
deactivate it if there is only one active currency

retain sale/pos feature of activating group_product_pricelist
adapt tests accordingly

Task 2610735

closes odoo/odoo#74396

Related: odoo/enterprise#20106
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-08-13 14:50:44 +00:00
Xavier-Do 288595f558 [FIX] *: add explicit license to all manifest
The license is missing in most enterprise manifest so
the decision was taken to make it explicit in all cases.
When not defined, a warning will be triggered starting from
14.0 when falling back on the default LGPL-3.

closes odoo/odoo#74245

Related: odoo/design-themes#48
Related: odoo/enterprise#19862
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2021-07-26 13:09:57 +00:00
Kevin Baptiste 86aa7b78aa [IMP] *: introduce data-hotkey on form and modal views
Define `data-hotkey` on most used action buttons.

For the modals, the following keys are dedicated for "special"
actions:
 - Alt+G: add
 - Alt+V: save
 - Alt+Z: cancel

closes odoo/odoo#73275

Taskid: 2588233
Related: odoo/enterprise#19464
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2021-07-15 08:39:49 +00:00
Thierry Ducrest 569bd99781 [13.0][FIX] stock_account: average unit cost price
When the cost of a product is set to a value below the currency rounding
the average purchase cost price will be wrongly set to zero.

It can happen for product sold in large quantity, that the cost of one product
must be smaller than the smallest unit of currency.

Instead of doing the zero check with currency precision using the
product price precision, which is the one used for the `standard_price`
fields, makes more sense and fixes the problem.

opw-2601121

closes odoo/odoo#73985

X-original-commit: 251be6b943ea8c3f274bb0863d0af3f7c6b8d10d
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-07-19 15:23:02 +00:00
wan 07f5c94e05 [FIX] l10n*: remove duplicate strings
Some field strings are duplicated and raising a warning in the CI.
Solution is to remove duplicated fields and put them in a common module,
or to change the string in the field declaration and put the right one
in the view.
2021-07-19 10:14:24 +00:00
Martin Trigaux 6758868731 [I18N] *: export saas-14.4 source terms
Without demo data

closes odoo/odoo#73560

X-original-commit: 802e46541117573e028b711ea33dad9df9075a39
Related: odoo/enterprise#19602
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-07-12 10:57:37 +00:00
Brice bib Bartoletti 8524991da3 [FIX]stock_account: copy_data safer access to prop
In l10n_latam, creating a debit note with stock_account installed ends
up in stock account checking for a property in a dictionnary that may
not exist.

Using the get property will solves this issue by providing a value.

closes odoo/odoo#73221

Ticket: opw-2580992
Bug-fix: opw-2588504
X-original-commit: 423d2d4ec62312da96c66d000eaabeac4920f68f
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Brice Bartoletti <Levizar@users.noreply.github.com>
2021-07-05 11:37:13 +00:00
Andrea Grazioso (agr-odoo) 6b7c6d62de [FIX] mrp_account,point_of_sale,stock_account: fix COGS entries for invoiced kit
- Activate anglo saxon accounting
- Have a [DEMO] KIT product in a category using automated
Inventory Valuation with costing method AVCO
- The KIT is composed by C1 and C2 in the same product category
- Define a cost on both C1 and C2
- Open a POS session, order [DEMO], Invoice and complete the order
- Close Session, Validate and display Journal Items

COGS entries will be missing.
This does not occur when making the order without invoicing

opw-2481518
opw-2545758

closes odoo/odoo#72460

X-original-commit: 659b455aca7a2c7f0cb41bfd6312bca25917d8a9
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2021-06-21 15:23:37 +00:00
Djamel (otd) 4adb7014bb [FIX] stock_account: use “account_journal_id” only if the valuation is real_time
Steps to reproduce the bug:
- Go to inventory > create a new product
    -Create a new product category:
        * Select "Manual" inventory Valuation
        * Choose "First In First Out (FIFO)" costing Method
        * Be sure that in "Automated" inventory valuation, stock journal is not settled
- Save
- Update quantity of the product
- Go to Inventory > Inventory Valuation> Choose the product newly created
- Click on the "+" button to make manual valuation

Problem:
An error is triggered because we try to access stock_journal when it is false.

Solution:
Use “account_journal_id” only if the valuation is real_time and relax the required constraint of `account_journal_id` in case of manual inventory Valuation (which is not used in that case).

Opw-2541497

closes odoo/odoo#71660

X-original-commit: 421271934c3eed43d2edcb410d3d75757c1fb81b
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-06-07 09:40:27 +00:00
Anh Thao Pham (pta) 9ec1b599fe [FIX] stock_account: do not create aml when updating cost of consumable
- Create a Product Category: (i.e. Category X)
  * Costing Method: Average Cost (AVCO)
  * Inventory Valuation: Automated
- Create a Consumable Product with Category X (i.e. Product X)
- Create PO with Product X and receive products
- On Product X form, update Cost
- In debug mode, go to Accounting > Accounting > Journal Items
Account move lines have been created for stock valuation on cost change,
but it shouldn't for a consumable product.

opw-2510315

closes odoo/odoo#71723

X-original-commit: b8e6f77101d28d05dd3d79c5b6de56da4dd5d2e6
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
2021-06-04 07:27:17 +00:00
yhu-odoo 2915ac1226 [IMP](stock,mrp)_account: use location valuation account
Previous fix f056254d1c5153467b10d9581214ff6d1348be76 didn't take the
situation when production location has its own valuation accounts into
consideration. Fix it in this commit.

opw-2476417

closes odoo/odoo#71064

X-original-commit: 60e83f03b871605b7aa281503269f66ac3ea940b
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: Yuchen Huang <yhu-odoo@users.noreply.github.com>
2021-05-19 17:01:08 +00:00
Anh Thao Pham (pta) 39e93d8418 [FIX] stock_account: fix computation of anglo saxon price unit
- Create a product with Category configured with:
  * Costing Method: First In First Out (FIFO)
  * Inventory Valuation: Automated
- Create a PO to buy 2 units at $100 (PO1) and receive the products
- Create a SO to sell 2 units (SO1) and deliver the products
  => COGS of SO1 should be $200 ($100 * 2)
- Return 1 unit from previous delivery
  => COGS of SO1 should be $100
- Create a SO to sell 1 unit (SO2) and deliver product
  => COGS of SO2 is $100
- Create a PO to buy 1 unit at $200 (PO2) and receive the product
- Re-deliver the returned unit from SO1
  => COGS of SO1 should be $300 ($100 + $200)
- Create invoice for SO1 and post it
The journal items (account.move.line) corresponding to the COGS have an incorrect
value: $200 ($100 + $100), instead of $300 ($100 + $200)

The issue comes from the method computing the anglo saxon price unit.
It does not take into account quantities from stock moves that have been returned.

This commit computes the number of units that have been returned for each stock
moves used to compute the anglo saxon price unit and to take the result into account
during the computation (of the anglo saxon price unit).

opw-2501260

closes odoo/odoo#71346

X-original-commit: 83136c8e7569636d38e12fc45f297e4d6f22ad36
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Anh Thao PHAM <kitan191@users.noreply.github.com>
2021-05-27 14:51:04 +00:00
William Henrotin 65fd6a5ef6 [FIX] stock_account: return correct empty value for consumable
Creating an account move from a valuation layer is bypassed in
case the product is consumable. Since 7fa9ec2638, the signature
of _account_entry_move() changed. It no longer return an account move
but a list of values to create everything in batch.
Testing the product type should now return `[]` instead of `False` in
order to be added to the existing list.

closes odoo/odoo#70945

X-original-commit: 5d76ce38a8551f430449b997a875ccc3b5a728cb
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-05-18 09:09:54 +00:00
Victor Feyens 0348b95aee [FIX] *: update documentation links
Following the recent reorganisation of the documentation in 12.0+,
the majority of the documents have been moved and their old links are no longer valid.
Some redirection rules will soon be deployed, but those rules might be dropped in some years
and we want the links to still work, which is why we still replace the links to the new ones.

FW-Port of odoo/odoo#70675 (13.0)

closes odoo/odoo#70920

X-original-commit: bc9c1eef538ba6095e74c19d5d9ed9e01625ec7c
Related: odoo/enterprise#18361
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2021-05-17 19:26:27 +00:00
Martin Trigaux 41d8b8cf68 [I18N] *: export saas-14.3 source terms
closes odoo/odoo#70673

X-original-commit: bcb9ff784e44462384b0a43a0a23eed7a1111bc5
Related: odoo/enterprise#18269
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-05-11 12:28:28 +00:00
Adrien Widart 2e95fda97d [IMP] stock_account: add hook for eligible for COGS
Let people be able to customize how to filter the condition

closes odoo/odoo#70418

Signed-off-by: Steve Van Essche <svs-odoo@users.noreply.github.com>
2021-05-06 13:22:18 +00:00
yhu-odoo 6414a4847e [FIX] stock_account: wrong account when changing cost method
Previously when changing cost method, we always add debit to Expense
account when empty svl. This results in an unneutral change for process
that should be neutral. In this commit, we change to use stock input
account to make it neutral.

Task 2481563

closes odoo/odoo#68083

Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-03-18 08:21:50 +00:00
nie 6f998adc3b [FIX] stock_account: check destination and source locations in forecast
Steps:
- Go to Inventory / Products / Products
- Create a product (2)
  - Storable Product
  - Cost: 10
- Click Update Quantity
- Create a new quantity line with 3 in On Hand Quantity
- Update the line with 1 in On Hand Quantity
- Go back to the product
- Click the "Forecasted" smart button

Bug:
The on hand value is 30 instead of 10.

Explanation:
When `location_dest_id` is the current location, it is used to specify
that a given quantity has been added to this location's stock. However,
when removing a quantity, the move goes from the current location to a
virtual one. The current location is, in this case, stored in
`location_id` and the destination is the virtual location.
This makes stock removals not appear in the on hand value since we only
filter the layers on their move's `location_dest_id`.

This commit assumes that a move always goes from or to a virtual
location and checks if the current location is in `location_dest_id` or
in `location_id`.

opw:2510911

closes odoo/odoo#70038

X-original-commit: 978853a6355e36e81752bf0714102f519a6a7931
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
Signed-off-by: backspac <backspac@users.noreply.github.com>
2021-04-28 14:52:01 +00:00
Jacky (trj) 174a10c7b8 [REF] stock_account: removed duplicated fix in _compute_average_price() from product
closes odoo/odoo#69821

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-26 09:03:25 +00:00
William Henrotin 62dcc193fe [FIX] stock_account: get unit_cost in sudo mode
Commit ad5ac19218 adds a sudo() in the
test condition but not inside the condition.

Close #69144

closes odoo/odoo#69197

X-original-commit: 7cd23a2cd464ccdfcb028b4f2c948654634b973c
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-04-13 15:53:36 +00:00
Ivan Yelizariev 0a2f1a1176 [FIX] stock_account: decrease number of queries in _run_fifo_vacuum
_run_fifo_vacuum may take significant time. This will slow down any operations
related to stock (Inventory Adjustment, POS Session closing, etc.) or even
block them due to timeout error. So, decreasing execution time is quite
desirable. This commit is doing it by decreasing number queries:

1. prefetch all_candidates before for-loop to avoid using `search` in each
iteration
2. move code about updating standard_price after the for-loop

---

opw-2499032

closes odoo/odoo#69112

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-12 12:28:36 +00:00
Arnold Moyaux bdcb3d192b [REF] stock: move stock.inventory feature into stock.quant
This commit removes stock.inventory(.line) and moves its general
functionality into stock.quant. Some features are lost during this
switch as well.

Feature Additions:
- New single list view for inventory adjustments (no more multiple
  inventory adjustment records to keep track of!)
- Improved cyclic counts (annual inventory day setting) + next inventory
  dates are immediately viewable in view (vs auto-generated inventories
  based only on location)
- Specific quants (i.e. counts) can be assigned to users for more
  flexibility (vs only able to restrict by location + product
  combinations)
- Counts can be requested (i.e. bulk assigned to user/for a specific
  inventory date)

Feature Removals:
- Can no longer look at previous inventory adjustments linked to a
  specific record. Each quant has a history button to show inventory
  related moves. [relevant account moves are also now harder to see via
  stock as well]

Other changes:
- Bulk of changes were for demo/test
- Some changes were done to ensure "Update Quantity"/"Inventory Report"
  views still mainly function the same as before with the exception of a
  new column added to support updating quant quantities in these views.

Task: 2440026
ENT PR: odoo/enterprise#17329
Upgrade PR: odoo/upgrade#2326

closes odoo/odoo#68409

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-04-02 11:51:38 +00:00
Hendrik 59699c3886 [FIX] stock_account: Fix shadowed 'product' variable in anglo-saxon lines
closes odoo/odoo#68373

X-original-commit: bdace2f538718a521926f0c5d073c05c40e98fac
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: Hendrik <hendrikw25@users.noreply.github.com>
2021-03-25 23:09:02 +00:00
William Henrotin 49a2363859 [FIX] stock_account: don't update unit cost
Commit f6b019fcfdd35a693e8af43ae38d10e31e96284a aims to fix the rounding
errors on AVCO valuated product when those exit stock. The issue was we
fixed the value and the unit_cost as it is rounded in the curruncy
precision. This is first wrong then useless.
The wrong part : in case the stock is empty and we make an outgoing
move, self.value = 0 so the unit_cost will be overridden to 0 while it
should stay at the standard price.
The useless part is that the unit_cost will be rerounded right after the
update to be written in database.

opw : 2380529

closes odoo/odoo#67718

X-original-commit: c2074b8c9ebf907f32a72ca6a5fadb4cd242a164
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-03-11 17:19:04 +00:00
Florent de Labarre 89dab304b0 [IMP] stock_account: add pivot view
closes odoo/odoo#66930

Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2021-02-26 14:20:55 +00:00
William Henrotin abe3d2f3e7 [FIX] stock_account: compute value in sudo
This commit makes the product's value computation in sudo mode in order
to be performed even by stock users.

closes odoo/odoo#67118

X-original-commit: a87c7fbad55d987b37a50e2b74b4dd9f9096a349
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
2021-03-02 18:39:28 +00:00
Martin Trigaux 80e168b2e7 [I18N] stock_account: forced fetch terms from Transifex
Some terms were translated two months ago but were not present in the files
Somehow the synchronisation failed at one point

X-original-commit: 88f5e5391b34b52abc92cd3edbd58a963b97dda3
2021-03-01 10:31:33 +01:00
Rémy Voet (ryv) 795ce6760c [FIX] stock_account: fix rounding adjustment
This fix (odoo/odoo#46850) was too permissive and fix too much
stock valuation issues (other than rounding error) under the hood.
The problem of the "too permissive" is will hide some errors
without get any feedback about them. Also, it changes the SVL value
without any explanation.

To avoid the first issue, apply a threshold on the rounding adjustment.
This threshold is '(quantity_out * smallest_value_of_the_currency) / 2'
(`smallest_value_of_the_currency` = `rounding` field of the related
currency).
Also to improve debugging, add a line in the description
about the rounding adjustment done in a SVL

task-2452786

closes odoo/odoo#66725

X-original-commit: a169d62e8999e90743401fcfe85200450ac6c628
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Rémy Voet <ryv-odoo@users.noreply.github.com>
2021-02-23 17:56:36 +00:00
Nasreddin (bon) d4342d733b [FIX] stock_account: display datetime with user timezone
Issue

	- Install Inventory module
	- Go to Inventory -> Reporting -> Inventory Valuation
	- Click on "Inventory At Date" button
	- Select any date

	The datetime in breadcrumb is displayed in UTC.

Solution

	Display datetime in current user timezone.

opw-2464744

closes odoo/odoo#66721

X-original-commit: 235386e4e6c8a4b55e9bee5dd901c611cd7950da
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2021-02-23 16:48:19 +00:00