Files
gzth/yuthon_stock/models/inherit_stock_picking.py
T
2025-09-01 19:50:27 +08:00

41 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
from odoo import api, fields, models
import json
class StockPicking(models.Model):
_inherit = 'stock.picking'
document_ids = fields.Many2many('ir.attachment', string="附件")
employee_id = fields.Many2one('hr.employee', string="领用人")
json_display = fields.Char(
string="物品详情",
compute='_compute_json_display',
store=True
)
@api.depends(
'move_ids_without_package.product_id',
'move_ids_without_package.product_uom_qty',
'move_ids_without_package.product_uom',
)
def _compute_json_display(self):
for record in self:
json_data = {
"template": "json_widget_stock.table_stock",
"title": f"{record.name}的明细数据",
"lines": [
{
'sequence': idx + 1,
'barcode': line.product_id.barcode or '',
'product_id': line.product_id.name or '',
'product_qty': line.product_uom_qty or '',
'price_unit': line.product_uom.name or '',
'standard_price' : line.product_id.standard_price or '',
}
for idx, line in enumerate(record.move_ids_without_package)
]
}
record.json_display = json.dumps(json_data, ensure_ascii=False)