odoo/odoo#180998

Created by Bugfix, Vincent Ethan
Merged at 7cd7563f6708331bb6baf0e06d07a9f9ee329e38

Statuses:

label
odoo-dev:16.0-opw-4090620-allow-quantity-zero-aml-etvi
head
7376c1ea1c19ff3b762723f68dfbda4eff857072
merged
7 months ago by Logistics, William Henrotin (whe)
odoo/odoo
16.0 #180998
17.0 #186304
saas-17.2 #186495
saas-17.4 #186514
18.0 #186791
saas-18.1
saas-18.2
saas-18.3
master #186933

[FIX] purchase_stock,stock_account: aml zero quantity case

Current behavior:
Manually adjusting a FIFO/AVCO product's cost creates a journal
items with non-zero quantity, despite there not being a logical
quantity associated with this entry.

Expected behavior:
AMLs generated for this move have 0 quantity.

Steps to reproduce:
Having accounting, purchase_stock
1. Create a storable product with average costing

  1. Create a purchase order for some of the product with some
    arbitrary price unit, receive the product

  2. In the product form, change the cost to a smaller value

  3. In the journal items pivot view, select the quantity field
    from the 'Measures' dropdown in the top left, expand the
    stock valuation journal on the left axis, observe that the
    change in cost has created 2 balancing AMLs, each with
    quantity == 1

Cause of the issue:
This case was not handled and quantity is always set to 1 if
falsy.

Fix:
Create the AMLs created in the cost change handle with
quantity=0. While it does risk being overwritten to 1 if the
display_type of the line changes, the diff is minimal and
use-case is non-critical- which makes it the best solution here.

opw-4090620