添加功能

This commit is contained in:
李鹏宇
2025-09-02 10:37:39 +08:00
parent 1d20a7bf0b
commit 1a0ab43b75
7 changed files with 107 additions and 3 deletions
+5
View File
@@ -15,5 +15,10 @@
],
'installable': True,
'application': True,
'assets': {
'web.assets_backend': [
'yuthon_purchase/static/xml/misc.xml'
],
}
}
@@ -1,10 +1,49 @@
# -*- coding: utf-8 -*-
from odoo import api, fields, models
import json
class InheritPurchaseOrder(models.Model):
_inherit = 'purchase.order'
json_display = fields.Char(
string="物品详情",
compute='_compute_json_display',
store=True
)
@api.depends(
'order_line.product_id',
'order_line.product_qty',
'order_line.product_uom',
'order_line.price_unit',
'order_line.price_subtotal'
)
def _compute_json_display(self):
for record in self:
json_data = {
"template": "json_widget_purchase.table_purchase",
"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 '',
'product_uom': line.product_uom.name or '',
'price_unit': line.price_unit or '',
}
for idx, line in enumerate(record.order_line)
]
}
record.json_display = json.dumps(json_data, ensure_ascii=False)
def action_refresh_json_display(self):
"""手动刷新json_display字段"""
for record in self:
record._compute_json_display()
return True
def get_no_read_count(self):
domain = [
('company_id', '=', self.env.user.company_id.id),
+39
View File
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="json_widget_purchase.table_purchase" owl="1">
<div class="mb-3">
<t t-if="lines and lines.length">
<table class="table table-striped">
<thead class="table-dark">
<tr>
<th scope="col">序号</th>
<th scope="col">产品编号</th>
<th scope="col">产品</th>
<th scope="col">数量</th>
<th scope="col">单位</th>
<th scope="col">单价</th>
</tr>
</thead>
<tbody>
<tr t-foreach="lines" t-as="line" t-key="line_index">
<td><t t-esc="line.sequence || (line_index + 1)"/></td>
<td><strong><t t-esc="line.barcode || '-'"/></strong></td>
<td><strong><t t-esc="line.product_id || '-'"/></strong></td>
<td><strong><t t-esc="line.product_qty || '-'"/></strong></td>
<td><strong><t t-esc="line.product_uom || '-'"/></strong></td>
<td><strong><t t-esc="line.price_unit || '-'"/></strong></td>
</tr>
</tbody>
</table>
</t>
<t t-else="">
<div class="alert alert-info" role="alert">
<i class="fa fa-info-circle"></i> 暂无物品数据
</div>
</t>
</div>
</t>
</templates>
@@ -17,6 +17,19 @@
<xpath expr="//field[@name='invoice_status']" position="attributes">
<attribute name="column_invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='origin']" position="after">
<field name="json_display" widget="json_template"/>
</xpath>
</field>
</record>
<record id="inherit_purchase_order_form" model="ir.ui.view">
<field name="name">purchase.order.form</field>
<field name="model">purchase.order</field>
<field name="inherit_id" ref="purchase.purchase_order_form"/>
<field name="arch" type="xml">
<xpath expr="//button[@name='action_rfq_send']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
</field>
</record>
</odoo>
@@ -38,3 +38,8 @@ class StockPicking(models.Model):
}
record.json_display = json.dumps(json_data, ensure_ascii=False)
def action_refresh_json_display(self):
"""手动刷新json_display字段"""
for record in self:
record._compute_json_display()
return True
+1 -1
View File
@@ -9,7 +9,7 @@
<thead class="table-dark">
<tr>
<th scope="col">序号</th>
<th scope="col">物业编号</th>
<th scope="col">产品编号</th>
<th scope="col">产品</th>
<th scope="col">数量</th>
<th scope="col">单位</th>
+5 -2
View File
@@ -27,10 +27,13 @@
<attribute name="string">目的位置</attribute>
</xpath>
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="string">验收人</attribute>
<attribute name="string">供应商</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="attributes">
<attribute name="string">经手人</attribute>
<attribute name="string">采购人员</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="attributes">
<attribute name="string">验收人</attribute>
</xpath>
<xpath expr="//field[@name='user_id']" position="after">
<field name="employee_id"/>