[REF] stock_landed_costs: adapt to new valuation
This commit is contained in:
@@ -13,11 +13,6 @@ class StockMove(models.Model):
|
||||
_inherit = 'stock.move'
|
||||
|
||||
landed_cost_value = fields.Float('Landed Cost')
|
||||
total_value = fields.Float('Total Value', compute='_compute_total_value')
|
||||
|
||||
def _compute_total_value(self):
|
||||
for move in self:
|
||||
move.total_value = move.value + move.landed_cost_value
|
||||
|
||||
|
||||
class LandedCost(models.Model):
|
||||
@@ -96,13 +91,12 @@ class LandedCost(models.Model):
|
||||
'ref': cost.name
|
||||
})
|
||||
for line in cost.valuation_adjustment_lines.filtered(lambda line: line.move_id):
|
||||
cost_to_add = line.additional_landed_cost
|
||||
# Prorate the value at what's still in stock
|
||||
cost_to_add = (line.move_id.remaining_qty / line.move_id.product_qty) * line.additional_landed_cost
|
||||
line.move_id.landed_cost_value += cost_to_add
|
||||
|
||||
# for quant in line.move_id.quant_ids:
|
||||
# if quant.location_id.usage != 'internal':
|
||||
# qty_out += quant.qty
|
||||
line._create_accounting_entries(move, 0) #TODO: qty_out like you would do with the different moves
|
||||
line.move_id.remaining_value += cost_to_add
|
||||
|
||||
line._create_accounting_entries(move, line.move_id.product_qty - line.move_id.remaining_qty)
|
||||
|
||||
move.assert_balanced()
|
||||
cost.write({'state': 'done', 'account_move_id': move.id})
|
||||
@@ -131,7 +125,7 @@ class LandedCost(models.Model):
|
||||
|
||||
for move in self.mapped('picking_ids').mapped('move_lines'):
|
||||
# it doesn't make sense to make a landed cost for a product that isn't set as being valuated in real time at real cost
|
||||
if move.product_id.valuation != 'real_time' or move.product_id.cost_method not in ('average', 'fifo'):
|
||||
if move.product_id.valuation != 'real_time' or move.product_id.cost_method != 'fifo':
|
||||
continue
|
||||
vals = {
|
||||
'product_id': move.product_id.id,
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# from . import test_stock_landed_costs_purchase
|
||||
from . import test_stock_landed_costs_purchase
|
||||
|
||||
@@ -227,7 +227,9 @@ class TestLandedCosts(TestStockLandedCostsCommon):
|
||||
# Confirm incoming shipment.
|
||||
self.picking_in.action_confirm()
|
||||
# Transfer incoming shipment
|
||||
self.picking_in.do_transfer()
|
||||
res_dict = self.picking_in.button_validate()
|
||||
wizard = self.env[(res_dict.get('res_model'))].browse(res_dict.get('res_id'))
|
||||
wizard.process()
|
||||
return self.picking_in
|
||||
|
||||
def _process_outgoing_shipment(self):
|
||||
@@ -237,7 +239,10 @@ class TestLandedCosts(TestStockLandedCostsCommon):
|
||||
# Product assign to outgoing shipments
|
||||
self.picking_out.action_assign()
|
||||
# Transfer picking.
|
||||
self.picking_out.do_transfer()
|
||||
|
||||
res_dict = self.picking_out.button_validate()
|
||||
wizard = self.env[(res_dict.get('res_model'))].browse(res_dict.get('res_id'))
|
||||
wizard.process()
|
||||
|
||||
def _create_landed_costs(self, value, picking_in):
|
||||
return self.LandedCost.create(dict(
|
||||
|
||||
Reference in New Issue
Block a user