Skip to content
Permalink
Browse files

[FIX] stock_account: Multicompany wrong cost in picking validation

Steps to reproduce:
- 2 Companies Parent A, and Child B
- Create a Stockable Product FIFO/automated,
- In A leave cost as 0, in B give cost of 10
- Create an SO for product in company B
- Logged into Parent A, validate the picking for Child B

Behavior before the fix:
An error was raised saying: Error cost of 0 (but the SO had been created in B, so the price had to be 10.)

Behavior after the fix:
Now the cost of the company B is taken.

closes #32329

opw:1966322

closes #32615

Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
  • Loading branch information...
simongoffin committed Apr 11, 2019
1 parent 77a2411 commit 8d97b3b6fc3427387c6af549722926f7916e001d
Showing with 5 additions and 2 deletions.
  1. +4 −1 addons/stock_account/models/product.py
  2. +1 −1 addons/stock_account/models/stock.py
@@ -166,8 +166,11 @@ def do_change_standard_price(self, new_price, account_id):
def _get_fifo_candidates_in_move(self):
""" Find IN moves that can be used to value OUT moves.
"""
return self._get_fifo_candidates_in_move_with_company()

def _get_fifo_candidates_in_move_with_company(self, move_company_id=False):
self.ensure_one()
domain = [('product_id', '=', self.id), ('remaining_qty', '>', 0.0)] + self.env['stock.move']._get_in_base_domain()
domain = [('product_id', '=', self.id), ('remaining_qty', '>', 0.0)] + self.env['stock.move']._get_in_base_domain(move_company_id)
candidates = self.env['stock.move'].search(domain, order='date, id')
return candidates

@@ -267,7 +267,7 @@ def _run_fifo(self, move, quantity=None):

# Find back incoming stock moves (called candidates here) to value this move.
qty_to_take_on_candidates = quantity or valued_quantity
candidates = move.product_id._get_fifo_candidates_in_move()
candidates = move.product_id._get_fifo_candidates_in_move_with_company(move.company_id.id)
new_standard_price = 0
tmp_value = 0 # to accumulate the value taken on the candidates
for candidate in candidates:

0 comments on commit 8d97b3b

Please sign in to comment.
You can’t perform that action at this time.