添加功能

This commit is contained in:
李鹏宇
2025-12-27 17:05:16 +08:00
parent 015b5b91db
commit 6be903305e
3 changed files with 50 additions and 63 deletions
@@ -92,7 +92,7 @@
<field name="workflow_happen_date" string="发生日期" column_invisible="1"/>
<button name="delete_record" type="object" string="删除" class="btn-primary" confirm="你确定要删除吗?"
invisible="not (is_manager or approve_state == 'start') "/>
groups="soong_workflow.group_soong_workflow_manager"/>
<button name="reminders_record" type="object" string="催办" class="btn-primary"
groups="soong_workflow.group_soong_workflow_manager" invisible="approve_state in ['start', 'end']"/>
<button name="revoke_record" type="object" string="撤销" class="btn-primary"
@@ -123,7 +123,7 @@
<field name="soong_state"/>
<field name="is_manager" column_invisible="1"/>
<button name="delete_record" type="object" string="删除" class="btn-primary" confirm="你确定要删除吗?"
invisible="approve_state != 'start' and not is_manager"/>
invisible="approve_state != 'start'"/>
<button name="reminders_record" type="object" string="催办" class="btn-primary" invisible="approve_state in ['start', 'end']"/>
<button name="revoke_record" type="object" string="撤销" class="btn-primary"
groups="soong_workflow.group_soong_workflow_manager"/>
@@ -27,14 +27,11 @@ class InheritPurchaseOrder(models.Model):
document_ids = fields.Many2many('ir.attachment', string="附件")
start_date = fields.Date(string="申请日期", default=fields.Date.today())
purchase_type = fields.Selection(
[('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('day', '日常消耗品')],
[('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('book', '书籍报刊'), ('foot', '饭堂食材')],
string="采购类型", default='fixed')
pay_way = fields.Selection([('onetime', '一次性'), ('installment', '分期')], string="付款方式", default='onetime')
reason_text = fields.Text(string="申请事由")
pay_line_ids = fields.One2many('purchase.order.pay.line', 'order_id', string="付款详情")
low_line_ids = fields.One2many('purchase.low.line', 'order_id', string="低值易耗明细")
service_line_ids = fields.One2many('purchase.service.line', 'order_id', string="服务明细")
fixed_line_ids = fields.One2many('purchase.fixed.line', 'order_id', string="日常消耗品明细")
def update_state(self):
order_ids = self.env["purchase.order"].browse(
@@ -96,3 +93,34 @@ class InheritPurchaseOrder(models.Model):
if self.user_id == self.env.user:
raise UserError("您不能接收自己创建的采购订单产品")
return super(InheritPurchaseOrder, self).action_view_picking()
class InheritPurchaseOrderLine(models.Model):
_inherit = 'purchase.order.line'
purchase_type = fields.Selection(
[('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务'), ('book', '书籍报刊'), ('foot', '饭堂食材')],
string="采购类型", default='fixed')
category_ids = fields.Many2many('product.category', string="产品分类", compute='_compute_purchase_type')
@api.depends('purchase_type')
def _compute_purchase_type(self):
for record in self:
PURCHASE_TYPE_MAP = {
'fixed': '固定资产',
'low': '低值易耗',
'book': '书籍报刊',
'foot': '饭堂食材'
}
matching_categories = self.env['product.category']
target_category_name = PURCHASE_TYPE_MAP.get(record.purchase_type)
if target_category_name:
matching_categories = self.env['product.category'].search([
'|',
('name', '=', target_category_name),
'|',
('parent_id.name', '=', target_category_name),
('parent_id.parent_id.name', '=', target_category_name),
])
record.category_ids = [(6, 0, matching_categories.ids)] if matching_categories else [(5,)]
@@ -85,71 +85,30 @@
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="domain">[('is_employee', '=', False)]</attribute>
</xpath>
<xpath expr="//field[@name='product_template_id']" position="attributes">
<attribute name="domain">[('categ_id', 'in', category_ids)]</attribute>
</xpath>
<xpath expr="//page[@name='products']" position="attributes">
<attribute name="invisible">purchase_type != 'fixed'</attribute>
<attribute name="string">固定资产明细</attribute>
</xpath>
<xpath expr="//field[@name='product_type']" position="after">
<field name="purchase_type"/>
<field name="category_ids" widget="many2many_tags"/>
</xpath>
<xpath expr="//field[@name='order_line']" position="attributes">
<attribute name="context">{'default_purchase_type': purchase_type}</attribute>
</xpath>
<xpath expr="//page[@name='products']" position="after">
<page string="日常消耗品明细" invisible="purchase_type != 'day'">
<field name="fixed_line_ids">
<page string="付款详情" invisible="pay_way == 'onetime'">
<field name="pay_line_ids">
<tree editable="bottom">
<field name="purchase_id" column_invisible="1"/>
<field name="product_id" required="1"/>
<field name="brand"/>
<field name="specs"/>
<field name="product_packaging_id"/>
<field name="number"/>
<field name="unit_id"/>
<field name="price_unit"/>
<field name="taxes_id"/>
<field name="total" sum="Total"/>
<field name="name" string="描述" required="1"/>
<field name="payment_stage" required="1"/>
<field name="amount"/>
<field name="payment_date"/>
<field name="remake"/>
</tree>
</field>
</page>
<page string="低值易耗明细" invisible="purchase_type != 'low'">
<field name="low_line_ids">
<tree editable="bottom">
<field name="purchase_id" column_invisible="1"/>
<field name="product_id" string="物品名称" required="1"/>
<field name="name"/>
<field name="brand"/>
<field name="specs"/>
<field name="number"/>
<field name="unit_id"/>
<field name="price"/>
<field name="taxes_id"/>
<field name="total" sum="Total"/>
</tree>
</field>
</page>
<page string="服务明细" invisible="purchase_type != 'service'">
<field name="service_line_ids">
<tree editable="bottom">
<field name="service_id" column_invisible="1"/>
<field name="product_id" required="1"/>
<field name="name" string="描述" required="1"/>
<field name="frequency"/>
<field name="fee"/>
<field name="product_packaging_id"/>
<field name="unit_id"/>
<field name="price"/>
<field name="taxes_id"/>
<field name="total" sum="Total"/>
</tree>
</field>
</page>
<page string="付款详情" invisible="pay_way == 'onetime'">
<field name="pay_line_ids">
<tree editable="bottom">
<field name="purchase_id" column_invisible="1"/>
<field name="payment_stage" required="1"/>
<field name="amount"/>
<field name="payment_date"/>
<field name="remake"/>
</tree>
</field>
</page>
</xpath>
<xpath expr="//page[@name='purchase_delivery_invoice']" position="attributes">
<attribute name="invisible">True</attribute>