Show purchase PnL graph values
This commit is contained in:
@@ -3357,19 +3357,23 @@ class PurchasePnlGraph(ModelSQL, ModelView):
|
||||
@classmethod
|
||||
def table_query(cls):
|
||||
Valuation = Pool().get('valuation.valuation')
|
||||
PurchaseLine = Pool().get('purchase.line')
|
||||
val = Valuation.__table__()
|
||||
return val.select(
|
||||
line = PurchaseLine.__table__()
|
||||
purchase = Coalesce(val.purchase, line.purchase)
|
||||
return val.join(
|
||||
line, 'LEFT', condition=val.line == line.id).select(
|
||||
Literal(0).as_('create_uid'),
|
||||
CurrentTimestamp().as_('create_date'),
|
||||
Literal(None).as_('write_uid'),
|
||||
Literal(None).as_('write_date'),
|
||||
Max(val.id).as_('id'),
|
||||
val.purchase.as_('purchase'),
|
||||
purchase.as_('purchase'),
|
||||
val.date.as_('valuation_date'),
|
||||
Sum(Coalesce(val.pnl, 0)).as_('pnl'),
|
||||
Sum(Coalesce(val.mtm, 0)).as_('mtm'),
|
||||
where=(val.purchase != None),
|
||||
group_by=[val.purchase, val.date],
|
||||
where=(purchase != None),
|
||||
group_by=[purchase, val.date],
|
||||
order_by=[val.date.asc])
|
||||
|
||||
|
||||
|
||||
@@ -5304,6 +5304,12 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(graph_field.get('labels'), 'pnl:Pnl,mtm:Mtm')
|
||||
self.assertEqual(graph_field.get('hidden_series'), 'pnl_graph')
|
||||
|
||||
value_fields = pages[pnl_index + 1].findall("field[@name='pnl_graph']")
|
||||
self.assertEqual(value_fields[1].get('mode'), 'tree')
|
||||
self.assertEqual(
|
||||
value_fields[1].get('view_ids'),
|
||||
'purchase_trade.purchase_pnl_graph_view_tree')
|
||||
|
||||
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')
|
||||
|
||||
@@ -168,6 +168,12 @@ this repository contains the full copyright notices and license terms. -->
|
||||
hidden_series="pnl_graph"
|
||||
height="360"
|
||||
colspan="4"/>
|
||||
<separator string="Pnl graph values" colspan="4"/>
|
||||
<field name="pnl_graph"
|
||||
mode="tree"
|
||||
view_ids="purchase_trade.purchase_pnl_graph_view_tree"
|
||||
height="160"
|
||||
colspan="4"/>
|
||||
</page>
|
||||
</xpath>
|
||||
<xpath expr="/form/notebook/page[@id='info']/label[@name='invoice_party']" position="before">
|
||||
|
||||
Reference in New Issue
Block a user