[14.0][IMP] stock_card_report, add origin to display_name on report

This commit is contained in:
Kitti U
2021-04-22 16:38:23 +07:00
parent 29d64c512c
commit ff158ea21d
3 changed files with 18 additions and 7 deletions

View File

@@ -20,6 +20,16 @@ class StockCardView(models.TransientModel):
is_initial = fields.Boolean()
product_in = fields.Float()
product_out = fields.Float()
picking_id = fields.Many2one(comodel_name="stock.picking")
def name_get(self):
result = []
for rec in self:
name = rec.reference
if rec.picking_id.origin:
name = "{} ({})".format(name, rec.picking_id.origin)
result.append((rec.id, name))
return result
class StockCardReport(models.TransientModel):
@@ -55,7 +65,8 @@ class StockCardReport(models.TransientModel):
then move.product_qty end as product_in,
case when move.location_id in %s
then move.product_qty end as product_out,
case when move.date < %s then True else False end as is_initial
case when move.date < %s then True else False end as is_initial,
move.picking_id
FROM stock_move move
WHERE (move.location_id in %s or move.location_dest_id in %s)
and move.state = 'done' and move.product_id in %s

View File

@@ -140,8 +140,8 @@
<div class="act_as_row labels">
<div class="act_as_cell">Date</div>
<div class="act_as_cell">Reference</div>
<div class="act_as_cell">Input</div>
<div class="act_as_cell">Output</div>
<div class="act_as_cell">In</div>
<div class="act_as_cell">Out</div>
<div class="act_as_cell">Balance</div>
</div>
</div>
@@ -153,7 +153,7 @@
<t t-esc="product_line.date.strftime('%Y-%m-%d')" />
</div>
<div class="act_as_cell left">
<t t-esc="product_line.reference" />
<t t-esc="product_line.display_name" />
</div>
<div class="act_as_cell right">
<t t-esc="'{0:,.3f}'.format(product_line.product_in)" />

View File

@@ -82,12 +82,12 @@ class ReportStockCardReportXlsx(models.AbstractModel):
"width": 25,
},
"3_input": {
"header": {"value": "Input"},
"header": {"value": "In"},
"data": {"value": self._render("input")},
"width": 25,
},
"4_output": {
"header": {"value": "Output"},
"header": {"value": "Out"},
"data": {"value": self._render("output")},
"width": 25,
},
@@ -177,7 +177,7 @@ class ReportStockCardReportXlsx(models.AbstractModel):
col_specs_section="data",
render_space={
"date": line.date or "",
"reference": line.reference or "",
"reference": line.display_name or "",
"input": line.product_in or 0,
"output": line.product_out or 0,
"balance": balance,