Commit Graph
420 Commits
Author SHA1 Message Date
Rémy Voet (ryv) 55bf82880c [FIX] stock_account: fix performance of _get_in_move_lines
A `stock.move` can contain thousands of `move_line_ids` (when tracked
by SN). The union of recordset (`|=`) doesn't scale well due
to the N² complexity (for 10000 SML to validate,
). Replace recordset union
by `OrderedSet` of ids + browse (linear complexity).

Before for 10000 SML to validate:
- the `_get_in_move_lines` take 14% time in the pyflame
After in the same condition:
- the `_get_in_move_lines` isn't present anymore in the pyflame

opw-2347525

X-original-commit: 0acbf6f961e4e946c9e487343ad2cc0129400b7f
2020-12-23 16:07:59 +00:00
Nicolas Martinelli 9e1849d183 [FIX] stock_account: SVL for consumable
Stock Valuation Layers are used for the MRP Cost Analysis feature.
Therefore, they are useful for consumable.

opw-2412668

closes odoo/odoo#63404

X-original-commit: c68e572f7c6f5109f1bfc40f9a44fc051f315112
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-12-15 14:28:17 +00:00
Nicolas Martinelli 0552a1246f [FIX] stock_account, stock_landed_costs: do not create SVL for consumable
The creation of a Stock Valuation Layer is useless in case of a
Consumable product. At best it is useless, at worst it causes
inconsistencies when the user switch from a Consumable to a Storable
type.

closes odoo/odoo#62936

X-original-commit: 7e9d052beabe15d932e5d403f8ca2f4837c7d24f
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-12-07 08:05:39 +00:00
Martin TrigauxandXavier Morel 49838338e0 [FIX] *: sanitize action content reading
The open_action_with_context was not using _for_xml_id, producing an
error when reading the action content.

In open_action, the action_name was taken from the context and needs
sanity checks. Ensure only actions from the account module can be
read and only if the user has access to the target model.
This is a limitation of the previous behaviour but, at the moment, all
known calls are made refering to an action from the account module.
Limit the scope of this method while the 14.0 is still early to avoid
having a door open to ready any action, and difficult to close later.

Remove old action fetching from the context in create_move that is no
longer used.

closes odoo/odoo#61602

X-original-commit: a39e94f7e4dc74e850650ac90bbc5f85af130bc8
Related: odoo/enterprise#14695
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Co-authored-by: Xavier Morel <xmo@odoo.com>
2020-11-10 16:04:29 +00:00
yhu-odoo a0868bc1ec [IMP] (mrp,stock)_account: using correct account when unbuild a MO
Currently when unbuild a MO, we create journal entries the same as
receiving components (add credit to input account) and deliver
finished product (add debit to output account). But since the
unbuild is just a revesal of the MO, the journal entries should
alse be revesals.

In this commit, when unbuild a MO, for the journal entry about the
component change, we add credit to the output account, and for the
journal entry of the finished product change, we add debit to input
account make sure the journal entries are also reversals.

Task 2312828
PR #58150

closes odoo/odoo#60730

X-original-commit: 83a3230706e1e2f4eaf9718156647821341d192b
Signed-off-by: Arnold Moyaux <amoyaux@users.noreply.github.com>
2020-10-26 11:48:02 +00:00
Robin Heinz bc67e6bf55 [IMP] point_of_sale: Add serial number on pos invoice
When we make an invoice with the point of sale, we now include the serial numbers on the invoice template if the option is ticked.

closes odoo/odoo#59516

Task-id: 2349339
Related: odoo/upgrade#1830
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-10-23 09:28:34 +00:00
Martin Trigaux 2683184aa6 [FIX] *: fix all the typos
And other reported English mistakes in source string
Courtesy of Transifex translators

And remove leftover from gengo

closes odoo/odoo#59022

X-original-commit: 26efc84c5cac47a2cc83d7b084f8b71528fec6c7
Related: odoo/enterprise#13781
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-10-05 09:36:34 +00:00
Andrea Grazioso (agr-odoo) 73db202930 [FIX] stock_account: take default credit/debit accounts from journal
Create a product category with automated inventory valuation but no
accounts defined for expense/income
Create a stored product with such category but again without expense/income
accounts.
Create an invoice with such product and a jounral on which default
credit/debit accounts are defined.
Save and Post the invoice.

Journal entries related to the inventory move (COGS) are not created
because the accounts are missing, but the system should take the default
defined on the jounral instead of skipping the operation

opw-2339168

closes odoo/odoo#58662

X-original-commit: 3019828c1c101cdbf2f7d61a751ed6d73e40005f
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
2020-09-29 12:45:14 +00:00
William Henrotin c8fa51330d [FIX] stock_account: empty move valuation
The validation of a stock move without quantity done create an empty
stock valuation layer. This is not a wanted behavior as :
1. it create record without useful information (0 value, 0 remaining
qty, 0 remaining value)
2. The landed cost value is set on a wrong layer in case of complete
backorder.

This commit bypass the valuation process on a move if it is validated
without any quantity.

opw : 2328258

closes odoo/odoo#58776

X-original-commit: 01e21735dbf3ac2fe975323cee2f4bb93e4ca747
Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-09-29 09:47:44 +00:00
Laurent Smet ca815e9a10 [FIX] account,stock_account: Fix bad bug fixes
https://github.com/odoo/odoo/commit/5309c252f6d0bc4994265a4c39259b70e7507fb1

This fix isn't working when using the 'modify' refund_method.
Also, you can't change the behavior of the whole invoices when there is only one move dealing with the auto_post feature.

https://github.com/odoo/odoo/commit/c9cd83e538a0be9d626d7587c465924146327cb2

This fix is only fixing the reversal wizard but must be done everytime a journal entry is duplicated.

closes odoo/odoo#56904

X-original-commit: 3057ee6cdd63c0adb5037041492427268b5e7549
Signed-off-by: oco-odoo <oco-odoo@users.noreply.github.com>
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-09-02 07:25:57 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.

Add sudo for other operations on ir.actions.*
2020-08-17 09:09:02 +00:00
william 82dc0cb7b9 [IMP] account: soft post entries in the future
Add an easy way to not post the entries in the future when calling
post() on it, but rather set it to be auto-posted at accounting date.
This is useful when we are creating a lot of entries in batch and some
might be in the future, some in the past, and we don't want to separate
that in two batch every time. (asset, accrual, transfer,... )
2020-08-05 11:57:10 +00:00
Jigar Vaghela 12b4a24b97 [FIX] stock_account/sale_stock: correctly valuate the product in below use case
Below is the case of product with automated valuation:
- You bought 8 units @ 10$.
- Then you deliver 10 units of the product.
- You assumed the missing 2 should go out at a value of 10$
  but you are not sure yet as it hasn't been bought in Odoo yet.
- Afterwards, you buy missing 2 units of the same product at 12$.

In this case the product has been undervalued when delivered without stock,
the vacuum entry is the following one (this entry already takes place):

Account                         | Debit   | Credit
===================================================
Stock Valuation                 | 0.00     | 4.00
Stock Interim (Delivered)       | 4.00     | 0.00

So, on delivering product with different price,
We should create additional journal items like:
Account                         | Debit    | Credit
===================================================
Stock Interim (Delivered)       | 0.00     | 4.00
Expenses Revaluation            | 4.00     | 0.00

closes odoo/odoo#52396

Task: 2224025
Closes: #52396
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-07-03 11:24:55 +00:00
Nicolas Martinelli d40cef681e [FIX] stock_account: quant currency
- Create 2 companies A & B, with different currencies
- Create a product in company B
  Set the company on the product
  Automated valuation
- Receive some stock in company B
- Switch to company A, and keep B available
- Go to Inventory > Reporting > Inventory Report

The currency on the product is the currency of the product company
instead of the currency of the current company.

The value is computed in the current company currency:

https://github.com/odoo/odoo/blob/bc3d1f2dc408fa91d42743d6a7063042e0f6c42b/addons/stock_account/models/product.py#L115

The currency should be consistent.

opw-2278751

closes odoo/odoo#53426

X-original-commit: 8aa952d18acca5a0ac3b32579e812158e641c13c
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-06-22 13:32:35 +00:00
Odoo's Mergebot e617aa91c5 [MERGE] tools: better placeholder support for _
Support two new syntaxes with `_()` method:

_("This is so %s") % 2019
_("Text with %s placeholders", 42)
_("Text with %(num)s placeholders %(symbol)s", num=42, symbol="🧀")

The main benefit is to have a fallback on the source string if formating the
translated string fails (e.g. "Foo %s" translated "Foo s%").

This PR converted most (but not all) calls to _ using placeholders to use the
new syntax. Hopefully, the remaining ones will be converted in the future and
avoid technical debt.

Use named placeholders when needed. If more than one placeholder is present in a
string, using named placeholder can be beneficial to reorder the placehodler
position (for languages like Japanese that do not use the same phrase
construction). On some sentences, it also brings clarity on the meaning of the
placeholders.

closes odoo/odoo#52155

Task-id: 1853119
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-06-18 13:51:48 +02:00
Martin Trigaux 80e97e98ce [IMP] *: use named placeholders in translated message
When more than one parameter is present in a message, it helps the
translation to use named placeholder. This way, the order can be
changed. It also helps the comprehension of the message.
2020-06-18 13:03:34 +02:00
Nicolas Martinelli fac71123c5 [FIX] stock_account: company of anglo-saxon AML
- Create 2 companies A & B
- Create a product with automatic valuation
- Switch to company A
- Create a SO for 1 unit of the product, validate and deliver
- Genrerate the invoice
- Switch to company B, but keep company A allowed
- Post the invoice

An error is raised because of inconsistent company:

> Some records are incompatible with the company...

This occurs because the anglo-saxon lines are created in accounts
belonging to company B instead of company A.

Since the product accounts are property fields, using `force_company` in
the context allows the selection of the right accounts.

opw-2276657

closes odoo/odoo#53183

X-original-commit: 603ce0f408a4479324a0905f5bc569c9f08567dd
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-06-17 16:03:26 +00:00
Martin Trigaux 6db2a81ea2 [IMP] *: use specific ir.property methods
Do not make direct CRUD to ir.property records, use appropriate
methods for that
2020-05-26 15:50:11 +02:00
Nicolas Martinelli ad5ac19218 [FIX] stock_account: return with limited access rights
- Create a SO, add a product with automated valuation
- Validate that SO
- Validate the picking
- Generate the invoice and validate
- As a limited user with only 'User' Inventory access rights, return the
  picking
- Validate the return

An `AccessError` is raised on `stock.valuation.layer`.

A regular user should be able to make a return, but not access the
accounting information. Therefore, use `sudo` where appropriate.

opw-2256074

closes odoo/odoo#51764

X-original-commit: c819a7e2fccbecce344ac74a33f0653eb8ba1027
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-25 08:11:36 +00:00
Swapnesh Shah bea1613f11 [FIX] stock,stock_account: fix undefined variable and return True
Fixes #29694
Close #47204
Fix #37554

Before this commit, There was Traceback on calling this method w/o any inventories as variable `res` was not declared but Returned or Calling this methord over RPC will raise TypeError as this method does not returns amything.

In this commit, We return True at original `post_inventory` method and Declare `res` to prevent undefined variable.

closes odoo/odoo#51320

X-original-commit: cfb2f00ae2fcbe33184d76383e3b624700101a75
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-05-15 09:14:06 +00:00
Nicolas Martinelli 65a3ffb124 [FIX] stock_account: do not consider consumable product for anglo saxon entries
This reverts commit cc8994a4ef.

opw-2153840

closes odoo/odoo#50280

closes odoo/odoo#50442

Related: odoo/enterprise#10239
Related: odoo/enterprise#10306
X-original-commit: 43fa375681f4615c0ecc28da625c0a488b38ba0f
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-04-30 08:37:42 +00:00
Goffin Simon 5b80a301db [FIX] stock_account: User not allowed to update product cost
Steps to reproduce the bug:

- Login with demo user (no accounting app access)
- Go to any product with Update Cost button and try to update it

Bug:

Error message "You don't have the access rights to post an invoice" even if
the inventory valuation was manual.

opw:2240513

closes odoo/odoo#49950

X-original-commit: edc54cdf6d39d7689902903fa637df2a709b4396
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2020-04-22 10:06:12 +00:00
Andrea Grazioso (agr-odoo) c1c3764ec3 [FIX] stock_account: avoid traceback on quantity zero
1. Install PoS and Accounting
2. In a product category activate the Inventory Valuation automated
3. Sell a quantity 0 of such product via POS

Traceback will occur when confirming the sale because the inventory
valuation do not handle zero quantity

opw-2206625

closes odoo/odoo#49417

X-original-commit: d501ddd1e80bc4e3ff90cd9b34eb43c27e55ff97
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-04-10 12:54:00 +00:00
Nicolas Martinelli 3590efa478 [FIX] stock_account: no analytic info on COGS
- Create a FIFO product, Automated
- Make some stock
- Create a SO, add the product
- On the SO, add an analytic account
- Validate the picking, create the invoice
  => the analytic info are propagated to the invoice, as expected
- Validate the invoice

The analytic info is propagated on the COGS entries, in particular the
the output account, which is incorrect.

Lost forward-port of 24c7efc8fef63437ac28883b29ed84809234ed76

closes odoo/odoo#47995

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-03-19 10:17:58 +00:00
yhu-odoo b08e3d114a [REF] stock,stock_account: archived products and quantities
PURPOSE

Keep consistent behavior of the stat buttons and the different stock
reports when archiving a product

SPECIFICATION

Currently, you can archive a product but the behavior of the different
stock reports, stat buttons isn't coherent afterwards. Here are the
different behaviors that should be improved:
1.Keep quantity on hand and forecasted quantity visible (in the stat
button + when opening it)
2.Automatically (un)archive RR and BOM if the product is (un)archived
3.Valuation report: show the archived products without the "archived"
filter (behaves already this way in the inventory and forecast reports)
4.When a product has been archived and still has quantity in stock,
include it in inventory adjustments for which counted quantity = default
to stock on hand (dont do so for archived exhausted products).

Also, revert #47478 since we don't have active field.

LINKS

Task 2178269
PR #45586
Fixes #41634

Related: odoo/upgrade#811
Related: odoo/enterprise#8513
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-03-13 08:37:26 +00:00
Simon Lejeune d944e67b46 [FIX] stock_account: _action_done performance
Validating a receipt of 90 stock moves having ~300k products in the
database goes from 7 minutes to 11 seconds thanks to the addition of
"active_test=False in the context before doing the searches on valuation
layers.

Most searches on "stock.valuation.layer" are done when validating a
move, but since this model contains an active field, the orm will
pathologically complete the searches expression by adding "id in active"
products. If the list is long, it slows down everything.

Since this field was only added to have a filter on the valuation
reports, it doesn't matter at all to ignore it in "_action_done".

It would probably have been cleaner to just remove the field but it
doesn't fit the stable policy. Nevertheless, we're going to remove the
field in master with task-2178269, as well as this patch.

opw-2209797

closes odoo/odoo#47523

X-original-commit: 466a8319547e11e2193dd8594b0e50e3c27d4b3e
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-03-12 15:36:03 +00:00
Tiffany Chang (tic) 99252f3d93 [IMP] stock/mrp: Update UX
This commit updates product, stock and manufacturing views for improved
usability. Handles view only changes of overall usability improvement
task. Specifically spec numbers:

1. Add "Run Scheduler" (from stock) to the manufacturing app under operations
5. Make "detailed operations" wizard modal have more intitutive footer
   buttons (i.e. don't say "Confirm"/"Cancel" when changes aren't
   possible.
8. Rearranging of vendor pricelist view
9. Updating of tooltip content for "property_stock_account_input_categ_id"

Task: 2041853
2020-03-05 13:04:10 +00:00
Rémy Voet (ryv) 7c55c20fce [IMP] stock_account: add button to create manual stock valuation layers
Add a way to create a munual stock valuation layer, create
a stock valuation layers implies :
- Change the stardard price with the new valuation by product unit in case of AVCO.
- Create a manual stock valuation layer with the added value.
- Update the remaining value of current valuation layer.
- If the Inventory Valuation of the product category is automated, create
related account move.

task-2123752
2020-03-04 16:07:40 +00:00
Rémy Voet (ryv) 8093b658cf [REF] stock_account: modify _change_standard_price to be batchable
The private method _change_standard_price was incorrect in batch
and didn't contain a ensure_one check.
Fix to be batched and used this new version in the write method
of product.product model.

task-2123752
2020-03-04 15:44:53 +00:00
Rémy Voet (ryv) c4d71d7d24 [REM] stock_account: clean import/condition/dead-code
For the stock_account module:
- Remove unused import
- Remove deadcode, unused _anglo_saxon_sale_move_lines method
and useless 'continue' keyword
- Fix duplicate name test (test_average_perpetual_8 defines twice)
- Make comments flake8 compliant

task-2123752
2020-03-04 15:44:53 +00:00
Victor Feyens 2556d5a024 [FIX] stock(_*): ensure properties are read with the correct company. 2020-02-27 12:19:24 +00:00
Ankita Raval d675dbaa4c [IMP] account,* : Change type field to move_type in account.move
task-id: 2028z813
2020-02-19 09:09:20 +00:00
Simon Lejeune de26f4a4e8 [FIX] stock_account: anglo saxon and corrections
Don't ignore correction layers when computing the anglo saxon price
unit. We use the `stock_valuation_layer_id` field on the layer to point
the correction layer to the corrected layer. When computing the average
price of the delivered things, ignore correction entry but take them
into account when choosing a corrected entry.

opw-2179900

closes odoo/odoo#44774

X-original-commit: 3831649b81c1271977730cdf46100f814687af61
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-02-06 17:15:18 +00:00
jbm-odoo dc1402c79b [FIX] stock_account: Avoid divide by 0
closes odoo/odoo#43188

Related: odoo/enterprise#7676
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2020-02-03 13:11:58 +00:00
Simon Lejeune aca23d578e [REF] stock, stock_account: indices for fast move unlink
Stock moves records can be unlinked in some cases, for example when
confirming a move containing a kit, the original move is unlinked and
replaced by the moves of the components of the kit.

This commit adds two indices to accelerate the unlink of stock move
records. The fields were the indices are added are foreign key on stock
move, and postgres checks the foreign keys of the rows before deleting
them.

closes odoo/odoo#44426

X-original-commit: e34a176dd438fe0f4f1a384889bfdc196f2c4b4f
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-02-01 09:49:33 +00:00
Maulik Raval 97a7cce164 [FIX]Fixed the singleton error when updating multiple category records value.
closes odoo/odoo#44320

X-original-commit: b08f658770d97be73da540eae1b439c551784310
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-01-30 14:33:40 +00:00
Simon Lejeune 9831f5603c [REF] stock_account: add a composite index on layers
closes odoo/odoo#43915

X-original-commit: 26fb669e0cca1c9efb8d9283755276551c608ce7
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-01-24 11:48:15 +00:00
Simon Lejeune 7ad5dd4d7d [FIX] stock_account: _run_fifo_vacuum
If the oldest problematic layer cannot be fixed, no need to try to fix
later one.

X-original-commit: f7ccf2b16803f05584fb094471b08f6836d892a1
2020-01-24 11:48:13 +00:00
Sylvain LE GAL 1e1e511cea [FIX] call _get_product_accounts() everywhere
closes odoo/odoo#41632

Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2020-01-23 14:29:45 +00:00
Ujas Dubal a5c4855a6b [FIX] stock_account: Added default type for 'account.move' line.
This commit will fixed the error when product has some stock quants
and product category with 'Automated' valuation method, is set to that product.

==============================

Steps to product the above mentioned error:
1. Create product with any category which has 'Manual' valuation method.
2. Update 'On Hand' quantity for the same product.
3. Create product category with valuation method set to 'Automated'.
4. Now set the above product category to the same product which you created in step 1.
5. And Click on the save button.

==============================

Also edit the test case.

closes odoo/odoo#43755

Task: 2155804
X-original-commit: c62dea6a7ce6b63f708831707811e922cd6bddd0
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-01-22 12:47:21 +00:00
Nicolas Martinelli 5afe4f8853 [FIX] stock_account: no analytic info on COGS
- Create a FIFO product, Automated
- Make some stock
- Create a SO, add the product
- On the SO, add an analytic account
- Validate the picking, create the invoice
  => the analytic info are propagated to the invoice, as expected
- Validate the invoice

The analytic info is propagated on the COGS entries, in particular the
the output account, which is incorrect.

opw-2008567

closes odoo/odoo#43690

X-original-commit: e831868fe648d3a3a4981a1cf9c135e4e4102279
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-01-21 17:07:56 +00:00
yhu-odoo 4a1dfb50b7 [REF] stock_account: valuation layer and not admin user
missing bit from rev[0], [1], and [2]

[0] 7ef11e3
[1] d6c8c34
[2] 5096e72

closes odoo/odoo#43186

Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-01-15 09:02:42 +00:00
yhu-odoo c87275a69f [FIX]stock_account: stock manager group not inherit account bill group
The inheritance of account billing group gives stock managers the access
to account module.
This commit is to remove this inheritance. When we need to access
account.move model, check if the user is a stock manager. If so, use
sudo() to get the access.

PR #43186
Task 2062611
2020-01-15 09:01:45 +00:00
Nicolas Martinelli 81b69f393b [FIX] account, stock_account: valuation multi-currency
- Set USD as company currency
- Set the EUR rate to 1.5
- Create a product A: FIFO & automated, invoicing based on delivery
- Create a pricelist in EUR
- Buy some quantity @ 100 USD
- Create a SO for 1 @ 200 EUR
- Confirm the SO, validate the picking, generate the invoice
- Do not set an invoice date
- Post the invoice

The COGS are incorrect:

                            Amount Currency         Debit        Credit
Stock Interim (Delivered)              0.00          0.00         66.67
Expense                                0.00         66.67          0.00

It should be:

                            Amount Currency         Debit        Credit
Stock Interim (Delivered)              0.00          0.00        100.00
Expense                                0.00        100.00          0.00

Commit 3a6ada5 attempted to correct the issue, but it was only
working when an invoice date was set.

In the current situation, when no invoice date is set, there is a
conversion issue. This is because of [1], which ultimately calls [2].
This triggers a recomputation of the credit and debit in [3].

After the accounting refactoring, it is assumed that all AML have the
same currency than the AM. This is for the case in [4]. In case of the
COGS, it is not the case.

Note that we could have done the conversion in Amount Currency (see
PR #42646). But that leads to a recomputation of the debit and credit
which (1) is unnecessary and (2) could lead to rounding errors.

[1] https://github.com/odoo/odoo/blob/01a24fd1df32766a9ed6cedd571ed30c75ef726b/addons/account/models/account_move.py#L2079
[2] https://github.com/odoo/odoo/blob/01a24fd1df32766a9ed6cedd571ed30c75ef726b/addons/account/models/account_move.py#L2894
[3] https://github.com/odoo/odoo/blob/01a24fd1df32766a9ed6cedd571ed30c75ef726b/addons/account/models/account_move.py#L2725-L2726
[4] https://github.com/odoo/odoo/blob/f71979a681d95d98db19a80feb59fdf684ec361f/addons/account/models/account_move.py#L337-L339

opw-2148171
opw-2162068

closes odoo/odoo#42816

X-original-commit: 0aee89780c8825fd28cc5bf44048101ac7010eac
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-01-07 08:13:41 +00:00
Simon Lejeune 28a3430de1 [REF] stock_account, mrp_account: valuation layer and not admin user
missing bit from rev[0] and [1]

[0] 7ef11e3
[1] d6c8c34ef6539dad110f1e502eaee2c03d968797

closes odoo/odoo#42621

X-original-commit: 5096e724643ca77568ce2f09a40b138561f4c20f
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2020-01-02 15:48:56 +00:00
Simon Lejeune 989a78b3fc [REF] stock_account: valuation layer and not admin user
missing bit from rev[0]

[0] 7ef11e3c96

closes odoo/odoo#42517

X-original-commit: 8ff69abc9010bb2aa05dea5a5f2e1fa545e6179c
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-12-30 17:49:26 +00:00
Pratima Gupta a431865301 [FIX] stock_account: valuation details feedback
In this -
1) Modified the label of the accounting entries which take place when
receiving/delivering/producing with products in automated inventory
valuation so that it includes information about the source document
(MO/Transfer) and the the product about which the entry is.
like - (WH/MO/0001 - Finished product)

2) Hide the Valuation stat button shown on transfer while not in debug mode.

3) on landed costs, if no valuation layer created, don't display the button.

4) default groupby is missing on the main valuation report.

Task-2153155

closes odoo/odoo#42464

X-original-commit: abd8e56e10bfc58c2f777b5aeeeb0b6b7360629f
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-12-30 10:20:01 +00:00
Simon Lejeune b08585e071 [FIX] stock_account: negative stock and vacuum
Running the vacuum in avco indeed fixed the estimated value on the
delivery but it did not update the standard price afterwards, making it
possible to have an inconsistent standard price with the actual value in
stock, as described in [0] and in the task [1].

A test was added (and validated) in the layers test file and an two old
one were fixed. test_average_perpetual_2 displayed also a different
missing bit: the vacuum should run when the user unlock and increments a
receipt.

[0] https://github.com/odoo/odoo/pull/41669
[1] 2154638

closes odoo/odoo#42292

X-original-commit: 6e4c9b8219db0c94c29f5ee145998e6f1597bb55
Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
2019-12-30 09:01:17 +00:00
Nicolas Martinelli 292971cb6c [FIX] stock_account: valuation multi-currency
- Set USD as company currency
- Set the EUR rate to 1.5
- Create a product A: FIFO & automated, invoicing based on delivery
- Create a pricelist in EUR
- Buy some quantity @ 100 USD
- Create a SO for 1 @ 200 EUR
- Confirm the SO, validate the picking, generate the invoice
- Post the invoice

The COGS are incorrect:

                            Amount Currency         Debit        Credit
Stock Interim (Delivered)            -66.67          0.00        100.00
Expense                               66.67        100.00          0.00

It should be:

                            Amount Currency         Debit        Credit
Stock Interim (Delivered)              0.00          0.00        100.00
Expense                                0.00        100.00          0.00

opw-2148171

closes odoo/odoo#42381

X-original-commit: 3a6ada5e550775e84c3d8a2f720bdd45250e2880
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-12-26 10:01:07 +00:00
Nicolas Martinelli 640011cf71 [FIX] stock_account: delete COGS when set to draft
- Create a product A, FIFO & Automated
- Create a SO, deliver and invoice
- Post the invoice
- Reset it to draft
- Post the invoice again

The COGS lines are duplicated.

Unlike the other lines, the COGS lines are only added at posting. This
is done in case several invoices are generated in draft, but validated
in an arbitrary order.

We clean up the COGS lines when resetting to draft.

opw-2153695
opw-2152465

closes odoo/odoo#41931

X-original-commit: 84cb3b9c848ed42017b3253ca70b9455c8af7307
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-12-16 11:21:58 +00:00