Organize the displayed fields to help users understand more what's going
on behind the scenes, especially with the remaining_qty and
remaining_value things.
The approach we tried with the current implementation lead to a replay
of all the next moves since a move had to be corrected, and posting an
account entry with the valuation difference.
This proved to be slow and complicated, and moreover the resulting
account entry could be very difficult to understand and justify.
So we moved away from this strategy and implemented the following points:
For FIFO
* If a move goes into negative (sent more than availabale, we do not
counterpart directly at the next in move: we valued it at the last
fifo price and only when running `_fifo_vacuum` (which is called at
every openning of the valuation report), we use some units currently
in stock and post an account entry with the difference between the
fake value and the real one used.
* When editing a done move and increasing its quantity, the new quantity
is available now and will be used at the next move out. We do not try
to replay the history to make the new values go away directly.
* When editing a done move and decreasing its quantity, it acts as a
return to the supplier at the price unit of the move.
On average price:
* Don't replay anything, if we fall under the negative stock usecase,
value at the last average price.
We restore the previous code that set the average price on the standard
price and we slightly patch it to continue to update the average price
if quantity in stock is negative.
We also add a link between stock moves and account moves. A stat button
on the stock move's form redirect directly to them. It's therefore a
little easier to understand what happened.
We remove the separate fifo and average price fields that were added in
saas17, we keep the single standard price (that should be renamed
cost_price for consistency). In the same idea, remove the cumulated
value that was stored on the move. If we need it, just recompute it
(it's not a frequent operation). We remove last_done_move_id,
last_done_remaining_qty and last_done_qty that were added in saas17 to
help in the replay method, as we just got rid of it. We also remove the
code that compensate the negative stock directy at the next in.
What the fifo vacuum does is essentially the same thing as what an out
move do: find a candidate and take units from it. In this case, the
candidates are newer than its concerned stock move. We stored on the
concerned stock move the value at which we sent it (remaining_value) and
post the difference with the real value on a real product.
Do not inline the average price calculation in `action_done`, as there's
a computed field that handle correctly the negative stock (does not
trigger division by 0). Also, complete this compute method by also
looking on transit locations and implement two fallbacks if the quantity
in stock is null: return the latest cost, if not found return the
standard price.
Also, make sure that `remaining_qty` is only set on fifo moves.
rename `_get_candidates_out_move` to `_get_fifo_candidates_out_move`
and `_get_candidates_move` to `_get_fifo_candidates_in_move` as it's
more explicit that they're only used in FIFO costing.
Fix `_update_future_cumulated_value` to filter only on internal moves
and to remove the value added in the past (self is always an out move to
which we added some value) and rename into
`update_fifo_future_cumulated_value`.
In `action_done`, rename `qty_taken_for_candidate` to
`qty_taken_for_candidate` as it's the qty we take to compensate the
candidate and not a quantity we take on the candidate (in this case,
some old out moves that we could not valuate in time because the stock
was negative). We fix the write on the value and cumulated value to
decrease the qty_taken_for_candidate*move.price_unit, because an out
move has always a negative value and we actually substract the value of
`move` which is always an in move and has always a positive value.
We fix the purchase test where negative out moves were valued positively
and add `test_fifo_negative_1` that tests the sending of goods we do not
have and the receipt encoded afterwards.
We expose a serie of functions that return domains to find in and out
moves and, as opposed as before, the transit locations who have a
company id set (i.e. the inter warehouse transit) do not impact the
valuation of a company.
We rename the `not_move` argument of `_get_latest_cumulated_value` to
`exclude_move`, which is more explicit.
This method is used to set `qty_available`, `virtual_available`,
`incoming_qty` and `outgoing_qty`.
We change the depends because only looking on stock.move is enough (all
changes on quants are made through stock moves, and we de not support to
edit directly quants anyway).
This method will call `_get_domain_locations` and we make sure that,
when the `company_owned` key is present in the context, we also return
domains to find products that are in a location that belongs to the
current user's company. This is done in order to include transit
location.
Also, remove the comment from tde. As these fields are displayed in
view, only using the context could alter the behavior.
Stock picking batch was introduced in saas-17 instead of
master as planned. However I missed one field that has been renamed on
stock picking called scheduled_date inseatd of min_date.
This commit make the inverse change in order to be compatible with saas-17
- model renamed: stock.picking.wave -> stock.picking.batch
- Class renamed: StockPickingWave -> StockPickingBatch
- .xml files: changed XML IDs according to module guidelines, reindented code and removed commented code
This commit only rename every string from picking wave to batch picking.
Model rename will only be pushed on master(saas-18) once the forward port
will be done.
Show details view should directly relfect the stock move line
related to a move. However the user was not able to update
locations and it still exists a button that allow to edit
the move line. Since the move line is the final object everything
should be directly editable and the button should not exist
This commit update the view in order to be able to edit information
directly on it.
This commit correct some variables renaming forgot in
the stock refactoring introduced by commit 0a76e158e1
It also add a invisible field for active_move_line_ids in order
to pass them to the create and avoid the error about uom_id.
The function action assign on stock move try to comprare
moves origin and moves dest in order to guess the available quanity.
However with return it happens that the group by method could return
twice the same key.
The method sorted was not correctly used because it used recordset
comparator instead of their id. Sorted on recordset use set comparaison
(superset, subset,..) as defined in models.py with method __gt__, __lt__,...
This commit change the function used on sort in order to use id but
keep the old way on groupby so that we are able to get back recordset.
This will avoid useless warning when the file does not exists and
possible false positive errors in case of invalid config in this file.
Also strip output
Cherry-pick of c955c3051c
When a picking is done and the quantity done of a move is update, the
delivered quantity of the linked sale order is not updated because it's
only updated on action_done of a move.
To fix this we override the write function of stock move in the
sale_stock module to update the delivered quantity of the corresponding
sale order line
When a picking is edited in done state, the related purchase order line
received quantity is not updated.
To fix this, we add a depends on the product_uom_qty of its stock moves
which is changed when a move is edited in 'done' state
Did you know that if you iterate on an OrderedDict in Python 2 and add
to the dict during iteration, the new items will be iterated? No? Me
neither.
And did you know that that does not work in Python 3 likely because
OrderedDict's implementation details changed? Why the fuck would
anyone do that and thus why would we care you ask?
WELL WE FUCKING DO IT TURNS OUT and that breaks
test_partial_reconcile_currencies on Python 3...
Fix it, try to make it more obvious that we're doing weird crap
instead of abusing OrderedDict in ways it was never meant to be used.
When the invoice is validated, the related timesheet are
set as invoice, and are not updateable anymore.
In order quantity, create and confirm SO, log 2 timesheet
lines and validate invoice. Your 2 timesheet lines will be
mark as invoiced. The other hour to deliver will not be linked
to the invoice (and their revenue=0), so the futur lines will
be updateable. But for the 2 first, the user will have to create
a new timesheet line, intead of updating an existing one. The
color will tell him which line is invoiced.
When the user remove the partner, the reconciliation widget try to read
information on 'res.users' without any partner id.
Open the match view when change the partner.
Remove max-height which can hide the last proposal.
P2 and P3 subprocess stdout seem to have very odd/different behaviours
in the face of mixing select and buffering.
Use raw/low-level IO (os.read) with select to try and fix that
up. Also read more than one byte at a time since os.read will not
block *if* the fd is readable, it will just get whatever data is
immediately available.
In P2, list comprehensions "leak" their variables to the surrounding
scope, in this case leading to "stl" from the first listcomp being
visible to the second one leading to code which does not break but
does not seem to make any sense.
/cc @csn-odoo
Python 3 removed "universal"
ordering. ``ResCompany.fiscalyear_lock_date`` is not required and thus
needs a fallback in case it's empty lest we try comparing a string and
None or False, which is an error.