Pnl graph

This commit is contained in:
2026-07-08 14:38:36 +02:00
parent 3122255bc7
commit 858b7258d9
4 changed files with 87 additions and 21 deletions

View File

@@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
import datetime
from pathlib import Path
from contextlib import nullcontext
from decimal import Decimal
from types import SimpleNamespace
@@ -5252,6 +5253,24 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(
ShipmentIn.operator.domain, [('categories.name', '=', 'OPERATOR')])
def test_purchase_form_has_pnl_graph_tab_after_pnl(self):
'purchase form exposes a rich graph for historical PnL and MTM'
path = Path('modules/purchase_trade/view/purchase_form.xml')
root = ElementTree.parse(path).getroot()
pages = root.findall(".//xpath[@expr=\"/form/notebook/page[@id='info']\"]//page")
page_ids = [page.get('id') for page in pages]
pnl_index = page_ids.index('pnl')
self.assertEqual(page_ids[pnl_index + 1], 'pnl_graph')
graph_field = pages[pnl_index + 1].find("field[@name='pnl_graph']")
self.assertIsNotNone(graph_field)
self.assertEqual(graph_field.get('widget'), 'rich_graph')
self.assertEqual(graph_field.get('date_field'), 'valuation_date')
self.assertEqual(graph_field.get('series'), 'pnl,mtm')
self.assertEqual(graph_field.get('labels'), 'pnl:Pnl,mtm:Mtm')
self.assertIsNone(graph_field.get('hidden_series'))
def test_shipment_in_pnl_lines_use_physical_and_open_lots(self):
'shipment PnL uses valuation lines from physical and open lot links'
ShipmentIn = Pool().get('stock.shipment.in')