The function "_store_average_cost_price" doesn't have to update
the average cost price of a product if qty of the product in the move
is equal to zero.
opw:659329
The list_price field doesn't take the extra price of variations
into account. Actually, it's not even a field of product.product.
The lst_price, however, is defined on both product.template and
product.product and does account for the extra price of variations.
OPW 659330
Using BIGINT id instead of Text
- This doesn't change the behavior, just the variable type,
while being much more efficient.
Using `UNION ALL` instead of simple `UNION`
- This doesn't change the behavior either,
as the ids of each sub select cannot collide
Closes#9197
opw-650598
The function "open_table" is not called when triggering the action
window "Current Inventory Valuation". Then the 'history_date' is not
set in the context.
opw:649168
When invoices are created from pickings, and that the user chooses to group by
partner, we make sure to keep the Reference/Description of all the source
documents. This is exactly what is done for the Source Document field.
opw-646903
The valuation wizard is based on stock moves and currently only takes into
account the moves which have different companies in source vs destination
locations.
This is a problem because all user-created locations have a default company set
to the user's company, even the "virtual" ones. For example in the demo dataset
visible on runbot, some supplier locations have a company set and some don't.
So we have to make sure to include every move coming from/going to
outside locations based on the locations's type too.
Closes#7530
The menu entry in Warehouse > Current Inventory Valuation is a shortcut to the
same results as the wizard in Reports > Warehouse > Valuation. However when
using the "current valuation" menu entry, the list is given without grouping by
product and location, so it's basically just a glorified list of stock moves
that no Warehouse manager is going to understand.
Let's just add the same default grouping to let the results make sense.
Closes#7531
This is related to rev. 55b7f15ee2
Prevent crash when there is no line to display
in the stock valuation report
Reporting > Warehouse > Stock Valuation.
Like when there is not yet any data, or the filter gives no result
opw-643748
This is a performance revision.
Some stored functions field were recomputed uselessly.
In mrp, `hour_total` and `cycle_total` were recomputed
at each write on `mrp.production`, while they should be recomputed
only when there is a change on the `workcenter_lines` field,
or when there is a change in the `hour` or `cycle` field
of these `workcenter_lines`.
In stock, `min_date`, `max_date` and `priority` of
`stock.picking` were recomputed each time a new move
was added to the picking,
wether or not the 'expected_date' of this move
was between the `stock.picking` `min_date` and `max_date`,
and the priority not greater.
In stock, `product_qty` of `stock.move` was recomputed
at each write on the `stock.move`, while it should be
recomputed only when there is a change in `product_id`,
`product_uom` or `product_uom_qty`, as the computation
method only depends on these three fields.
In stock_account, the `invoice_state` of `stock.picking`
was recomputed each time a new `stock.move` was associated
to the picking, wether or not the `invoice_state` of the move
was already the same than the `invoice_state` of the picking.
opw-643560
Basically, computation of the `inventory_value` is now done
in batch instead of one by one.
In a real use case, the computation of the stock valuation
passed from 20+ minutes to less than a minute.
This revision contains an unusual SQL request:
`SELECT DISTINCT ON`
Basically, it returns the most recent line of table
product_price_history for each tuple
`(product_template_id, company_id)`
which is actually what we want, with good performances.
See postgresql doc for more information:
http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-DISTINCT
opw-641154
When creating an incoming shipment to be invoiced with as source location
"Transit"
and as destination location
"Stock"
Clicking on create invoice leaded to a crash.
opw-639536
This revision is related to 4fb497b653.
For a 'To be invoiced' delivery order with a move with
as source location 'Stock' and
as destination location 'Transit'
There is no way to know if it's a Customer invoice
that should be created or a Purchase Invoice.
Indeed, the transit could be used as an intermediate to ship
to the supplier, or to the customer
opw-639536
If an extra move contains a product which is not initially in the order,
the taxes set on this product must be considered according to the fiscal position
of this order.
opw:634305
When using locations of 'transit' type in pickings,
the invoice journal type was always set to "Sales",
while, for instance, for an incoming shipment,
with as source location a transit location, the invoice
journal should obviously be purchase
opw-639536
When receiving goods with average price set as costing method,
for a move from another company than the SUPERUSER_id company,
the average price updated was the one from the SUPERUSER company
instead of the one of the move.
opw-634167
When the product is a consumable, avoid to use real-time valuation, by adapting
the onchange in the views and making the valuation field invisible when the
product is a consumable / service.