添加功能

This commit is contained in:
李鹏宇
2025-12-13 18:28:17 +08:00
parent bf03ec22ff
commit 916f7bc3b2
4 changed files with 30 additions and 7 deletions
@@ -28,6 +28,7 @@ class PurchaseWorkflow(models.Model):
document_ids = fields.Many2many('ir.attachment', string="附件")
active = fields.Boolean('启用', default=True, tracking=True)
work_end = fields.Boolean(string="审批结束", default=False, tracking=True)
purchase_order_id = fields.Many2one('purchase.order', string="采购订单", readonly=True)
purchase_type = fields.Selection([('fixed', '固定资产'), ('low', '低值易耗'), ('service', '服务')],
string="采购类型", required=True, default='fixed')
@@ -65,6 +66,7 @@ class PurchaseWorkflow(models.Model):
'company_id': rec.company_id.id,
'user_id': rec.user_id.id,
})
rec.purchase_order_id = purchase_order.id
order_lines = []
if rec.purchase_type == 'fixed':
for line in rec.fixed_line_ids:
@@ -57,6 +57,7 @@
<field name="service_start_date" string="服务开始时间" invisible="purchase_type != 'service'"/>
<field name="service_end_date" string="服务结束时间" invisible="purchase_type != 'service'"/>
<field name="service_year" string="服务年限" invisible="purchase_type != 'service'"/>
<field name="purchase_order_id" invisible="not purchase_order_id"/>
<field name="department_id" invisible="1"/>
</group>
</group>
+20 -4
View File
@@ -17,13 +17,29 @@ class StockPicking(models.Model):
store=True
)
@api.onchange('employee_id')
def _onchange_employee_id(self):
if self.employee_id:
self.department_id = self.employee_id.department_id.id
@api.onchange('user_id')
def _onchange_user_id(self):
if self.user_id:
self.department_id = self.user_id.employee_ids.department_id.id
else:
self.department_id = False
@api.constrains("department_id")
def _check_department_id(self):
if self.department_id:
location_dest_id = self.env['stock.location'].search([('name', '=', self.department_id.name)], limit=1)
if not location_dest_id:
company_id = self.user_id.company_id
location_id = self.env['stock.location'].search([('complete_name', '=', company_id.name)])
location_dest_id = self.env['stock.location'].create({
'name': self.department_id.name,
'location_id': location_id.id,
'complete_name': company_id.name,
'usage': 'internal',
'company_id': company_id.id,
})
self.location_dest_id = location_dest_id
@api.depends(
'move_ids_without_package.product_id',
'move_ids_without_package.product_uom_qty',
+7 -3
View File
@@ -13,15 +13,18 @@
<group>
<field name="user_id" string="采购人员"/>
<field name="employee_id" string="验收人" required="1"/>
<field name="certifier_id" required="1"/>
<field name="certifier_id"/>
</group>
</group>
</xpath>
<xpath expr="//field[@name='picking_type_id']" position="after">
<field name="department_id"/>
</xpath>
<xpath expr="//button[@name='button_validate']" position="attributes">
<attribute name="string">确认入库</attribute>
<xpath expr="//button[@name='button_validate' and @class='oe_highlight']" position="attributes">
<attribute name="string">确认入库</attribute>
</xpath>
<xpath expr="//button[@name='button_validate' and @class='o_btn_validate']" position="attributes">
<attribute name="string">确认入库</attribute>
</xpath>
<xpath expr="//field[@name='picking_properties']" position="attributes">
<attribute name="invisible">1</attribute>
@@ -50,6 +53,7 @@
</xpath>
<xpath expr="//field[@name='location_dest_id']" position="attributes">
<attribute name="string">目的位置</attribute>
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//field[@name='partner_id']" position="attributes">
<attribute name="string">供应商</attribute>