[FIX] include anglo-saxon price unit calculation in refunds.

Otherwise the anglo saxon entries won't be correct.
For example, the Interim (Delivered) account should balance
after receiving and triggering a refund on a customer rma.
This commit is contained in:
Jordi Ballester Alomar
2022-11-21 15:13:06 +01:00
parent 8a9a528ce3
commit c4b906ef35

View File

@@ -14,40 +14,40 @@ class TestRmaStockAccountPurchase(TestRmaStockAccount):
super(TestRmaStockAccountPurchase, cls).setUpClass()
cls.pol_model = cls.env["purchase.order.line"]
cls.po_model = cls.env["purchase.order"]
# Create PO:
cls.product_fifo_1.standard_price = 1234
cls.po = cls.po_model.create(
{
"partner_id": cls.partner_id.id,
}
)
cls.pol_1 = cls.pol_model.create(
{
"name": cls.product_fifo_1.name,
"order_id": cls.po.id,
"product_id": cls.product_fifo_1.id,
"product_qty": 20.0,
"product_uom": cls.product_fifo_1.uom_id.id,
"price_unit": 100.0,
"date_planned": Datetime.now(),
}
)
cls.po.button_confirm()
cls._do_picking(cls.po.picking_ids)
def test_01_cost_from_po_move(self):
"""
Test the price unit is taken from the cost of the stock move associated to
the PO
"""
# Create PO:
self.product_fifo_1.standard_price = 1234
po = self.po_model.create(
{
"partner_id": self.partner_id.id,
}
)
pol_1 = self.pol_model.create(
{
"name": self.product_fifo_1.name,
"order_id": po.id,
"product_id": self.product_fifo_1.id,
"product_qty": 20.0,
"product_uom": self.product_fifo_1.uom_id.id,
"price_unit": 100.0,
"date_planned": Datetime.now(),
}
)
po.button_confirm()
self._do_picking(po.picking_ids)
self.product_fifo_1.standard_price = 1234 # this should not be taken
supplier_view = self.env.ref("rma_purchase.view_rma_line_form")
rma_line = Form(
self.rma_line.with_context(supplier=1).with_user(self.rma_basic_user),
view=supplier_view.id,
)
rma_line.partner_id = self.po.partner_id
rma_line.purchase_order_line_id = self.pol_1
rma_line.partner_id = po.partner_id
rma_line.purchase_order_line_id = pol_1
rma_line.price_unit = 4356
rma_line = rma_line.save()
rma_line.action_rma_to_approve()
@@ -55,9 +55,9 @@ class TestRmaStockAccountPurchase(TestRmaStockAccount):
# The price is not the standard price, is the value of the incoming layer
# of the PO
rma_move_value = picking.move_lines.stock_valuation_layer_ids.value
po_move_value = self.po.picking_ids.mapped(
"move_lines.stock_valuation_layer_ids"
)[-1].value
po_move_value = po.picking_ids.mapped("move_lines.stock_valuation_layer_ids")[
-1
].value
self.assertEqual(-rma_move_value, po_move_value)
# Test the accounts used
account_move = picking.move_lines.stock_valuation_layer_ids.account_move_id