From 4d38a11c3ca8ba294b97ec5346c42833bffe9248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 25 Mar 2025 15:58:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=A2=E4=BB=B7?= =?UTF-8?q?=E5=8D=95=E5=88=A4=E6=96=AD=E8=A1=8C=E9=A1=B9=E7=9B=AE=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E4=B8=8D=E8=83=BD=E4=B8=BA0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 3d71b6c7..d05e6b63 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -58,19 +58,7 @@ class PurchaseOrder(models.Model): origins = [order.name for order in purchase.picking_ids] production_id = self.env['mrp.production'].search([('origin', 'in', origins)]) purchase.production_count = len(production_id) - - # def button_confirm(self): - # super().button_confirm() - # workorders = self.env['mrp.workorder'].search([('purchase_id', '=', self.id), ('state', '!=', 'cancel')]) - # for workorder in workorders: - # if workorder.routing_type == '表面工艺' and workorder.is_subcontract is True: - # move_out = workorder.move_subcontract_workorder_ids[1] - # for mo in move_out: - # if mo.state != 'done': - # mo.write({'state': 'assigned', 'production_id': False}) - # if not mo.move_line_ids: - # self.env['stock.move.line'].create(mo.get_move_line(workorder.production_id, workorder)) - # return True + origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id') origin_sale_ids = fields.Many2many('sale.order', string='销售订单号(多个)', store=True, @@ -146,4 +134,11 @@ class PurchaseOrderLine(models.Model): # 如果手动设置了 part_name,使用手动设置的值 record.part_name = record.manual_part_name if record.manual_part_number: - record.part_number = record.manual_part_number \ No newline at end of file + record.part_number = record.manual_part_number + + def write(self, vals): + if 'product_qty' in vals and vals.get('product_qty') <= 0: + raise UserError('请对【产品】中的【数量】进行输入') + if 'price_unit' in vals and vals.get('price_unit') <= 0: + raise UserError('请对【产品】中的【单价】进行输入') + return super(PurchaseOrderLine, self).write(vals) \ No newline at end of file From 03539c7ed3f8eb859a31ef4ab14fa2c716716d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 25 Mar 2025 16:20:54 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=A2=E4=BB=B7=E5=8D=95=E8=A1=8C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BB=B7=E6=A0=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index d05e6b63..3cc0d877 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -58,6 +58,15 @@ class PurchaseOrder(models.Model): origins = [order.name for order in purchase.picking_ids] production_id = self.env['mrp.production'].search([('origin', 'in', origins)]) purchase.production_count = len(production_id) + + def write(self, vals): + for record in self: + for line in record.order_line: + if line.product_qty <= 0: + raise UserError('请对【产品】中的【数量】进行输入') + if line.price_unit <= 0: + raise UserError('请对【产品】中的【单价】进行输入') + return super(PurchaseOrder, self).write(vals) origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id') @@ -134,11 +143,4 @@ class PurchaseOrderLine(models.Model): # 如果手动设置了 part_name,使用手动设置的值 record.part_name = record.manual_part_name if record.manual_part_number: - record.part_number = record.manual_part_number - - def write(self, vals): - if 'product_qty' in vals and vals.get('product_qty') <= 0: - raise UserError('请对【产品】中的【数量】进行输入') - if 'price_unit' in vals and vals.get('price_unit') <= 0: - raise UserError('请对【产品】中的【单价】进行输入') - return super(PurchaseOrderLine, self).write(vals) \ No newline at end of file + record.part_number = record.manual_part_number \ No newline at end of file From 8ec746858c97e68979b0cfa8fee3068000e6e372 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E5=B0=A7?= Date: Tue, 25 Mar 2025 16:25:05 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AF=A2=E4=BB=B7=E5=8D=95=E8=A1=8C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E4=BB=B7=E6=A0=BC=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/models/purchase_order.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sf_manufacturing/models/purchase_order.py b/sf_manufacturing/models/purchase_order.py index 3cc0d877..5ee7d8f2 100644 --- a/sf_manufacturing/models/purchase_order.py +++ b/sf_manufacturing/models/purchase_order.py @@ -60,13 +60,14 @@ class PurchaseOrder(models.Model): purchase.production_count = len(production_id) def write(self, vals): + res = super(PurchaseOrder, self).write(vals) for record in self: for line in record.order_line: if line.product_qty <= 0: raise UserError('请对【产品】中的【数量】进行输入') if line.price_unit <= 0: raise UserError('请对【产品】中的【单价】进行输入') - return super(PurchaseOrder, self).write(vals) + return res origin_sale_id = fields.Many2one('sale.order', string='销售订单号', store=True, compute='_compute_origin_sale_id')