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